summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmCommonTargetGenerator.cxx4
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx2
-rw-r--r--Source/cmGeneratorTarget.cxx15
-rw-r--r--Source/cmGeneratorTarget.h2
-rw-r--r--Source/cmMakefile.cxx19
-rw-r--r--Source/cmMakefile.h5
-rw-r--r--Source/cmTarget.cxx76
-rw-r--r--Source/cmTarget.h11
-rw-r--r--Source/cmcmd.cxx24
10 files changed, 115 insertions, 45 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 5868ad7..f8e31cc 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 26)
-set(CMake_VERSION_PATCH 20230215)
+set(CMake_VERSION_PATCH 20230216)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index a63c162..1705763 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -176,7 +176,9 @@ std::vector<std::string> cmCommonTargetGenerator::GetLinkedTargetDirectories(
// We can ignore the INTERFACE_LIBRARY items because
// Target->GetLinkInformation already processed their
// link interface and they don't have any output themselves.
- && linkee->GetType() != cmStateEnums::INTERFACE_LIBRARY &&
+ && (linkee->GetType() != cmStateEnums::INTERFACE_LIBRARY
+ // Synthesized targets may have relevant rules.
+ || linkee->IsSynthetic()) &&
((lang == "CXX"_s && linkee->HaveCxx20ModuleSources()) ||
(lang == "Fortran"_s && linkee->HaveFortranSources(config))) &&
emitted.insert(linkee).second) {
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 33c057d..c6ebad5 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -85,7 +85,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*prop);
cmTarget dummyHead("try_compile_dummy_exe", cmStateEnums::EXECUTABLE,
- cmTarget::VisibilityNormal, tgt->Target->GetMakefile(),
+ cmTarget::Visibility::Normal, tgt->Target->GetMakefile(),
cmTarget::PerConfig::Yes);
cmGeneratorTarget gDummyHead(&dummyHead, tgt->GetLocalGenerator());
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index f83be26..be6456b 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1237,6 +1237,16 @@ bool cmGeneratorTarget::IsInBuildSystem() const
return false;
}
+bool cmGeneratorTarget::IsNormal() const
+{
+ return this->Target->IsNormal();
+}
+
+bool cmGeneratorTarget::IsSynthetic() const
+{
+ return this->Target->IsSynthetic();
+}
+
bool cmGeneratorTarget::IsImported() const
{
return this->Target->IsImported();
@@ -7105,6 +7115,11 @@ cmGeneratorTarget::OutputInfo const* cmGeneratorTarget::GetOutputInfo(
return nullptr;
}
+ // Synthetic targets don't have output.
+ if (this->IsSynthetic()) {
+ return nullptr;
+ }
+
// Only libraries and executables have well-defined output files.
if (!this->HaveWellDefinedOutputFiles()) {
std::string msg = cmStrCat("cmGeneratorTarget::GetOutputInfo called for ",
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index afd9da4..e46c719 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -50,6 +50,8 @@ public:
cmGlobalGenerator* GetGlobalGenerator() const;
bool IsInBuildSystem() const;
+ bool IsNormal() const;
+ bool IsSynthetic() const;
bool IsImported() const;
bool IsImportedGloballyVisible() const;
bool CanCompileSources() const;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 0ad0e6e..d963a5a 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -2115,12 +2115,21 @@ cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type,
return &this->CreateNewTarget(name, type).first;
}
+cmTarget* cmMakefile::AddSynthesizedTarget(cmStateEnums::TargetType type,
+ const std::string& name)
+{
+ return &this
+ ->CreateNewTarget(name, type, cmTarget::PerConfig::Yes,
+ cmTarget::Visibility::Generated)
+ .first;
+}
+
std::pair<cmTarget&, bool> cmMakefile::CreateNewTarget(
const std::string& name, cmStateEnums::TargetType type,
- cmTarget::PerConfig perConfig)
+ cmTarget::PerConfig perConfig, cmTarget::Visibility vis)
{
- auto ib = this->Targets.emplace(
- name, cmTarget(name, type, cmTarget::VisibilityNormal, this, perConfig));
+ auto ib =
+ this->Targets.emplace(name, cmTarget(name, type, vis, this, perConfig));
auto it = ib.first;
if (!ib.second) {
return std::make_pair(std::ref(it->second), false);
@@ -4203,8 +4212,8 @@ cmTarget* cmMakefile::AddImportedTarget(const std::string& name,
// Create the target.
std::unique_ptr<cmTarget> target(
new cmTarget(name, type,
- global ? cmTarget::VisibilityImportedGlobally
- : cmTarget::VisibilityImported,
+ global ? cmTarget::Visibility::ImportedGlobally
+ : cmTarget::Visibility::Imported,
this, cmTarget::PerConfig::Yes));
// Add to the set of available imported targets.
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 3866aca..7b19c97 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -241,10 +241,13 @@ public:
std::pair<cmTarget&, bool> CreateNewTarget(
const std::string& name, cmStateEnums::TargetType type,
- cmTarget::PerConfig perConfig = cmTarget::PerConfig::Yes);
+ cmTarget::PerConfig perConfig = cmTarget::PerConfig::Yes,
+ cmTarget::Visibility vis = cmTarget::Visibility::Normal);
cmTarget* AddNewTarget(cmStateEnums::TargetType type,
const std::string& name);
+ cmTarget* AddSynthesizedTarget(cmStateEnums::TargetType type,
+ const std::string& name);
/** Create a target instance for the utility. */
cmTarget* AddNewUtilityTarget(const std::string& utilityName,
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index e8d66cc..91d5de6 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -629,10 +629,9 @@ public:
bool IsDLLPlatform;
bool IsAIX;
bool IsAndroid;
- bool IsImportedTarget;
- bool ImportedGloballyVisible;
bool BuildInterfaceIncludesAppended;
bool PerConfig;
+ cmTarget::Visibility TargetVisibility;
std::set<BT<std::pair<std::string, bool>>> Utilities;
std::vector<cmCustomCommand> PreBuildCommands;
std::vector<cmCustomCommand> PreLinkCommands;
@@ -667,6 +666,8 @@ public:
cmTargetInternals();
+ bool IsImported() const;
+
bool CheckImportedLibName(std::string const& prop,
std::string const& value) const;
@@ -914,9 +915,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
this->impl->IsDLLPlatform = false;
this->impl->IsAIX = false;
this->impl->IsAndroid = false;
- this->impl->IsImportedTarget =
- (vis == VisibilityImported || vis == VisibilityImportedGlobally);
- this->impl->ImportedGloballyVisible = vis == VisibilityImportedGlobally;
+ this->impl->TargetVisibility = vis;
this->impl->BuildInterfaceIncludesAppended = false;
this->impl->PerConfig = (perConfig == PerConfig::Yes);
@@ -939,7 +938,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
// Save the backtrace of target construction.
this->impl->Backtrace = this->impl->Makefile->GetBacktrace();
- if (!this->IsImported()) {
+ if (this->IsNormal()) {
// Initialize the INCLUDE_DIRECTORIES property based on the current value
// of the same directory property:
this->impl->IncludeDirectories.CopyFromDirectory(
@@ -988,7 +987,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
if (this->impl->TargetType != cmStateEnums::UTILITY &&
this->impl->TargetType != cmStateEnums::GLOBAL_TARGET) {
metConditions.insert(TargetProperty::InitCondition::NormalTarget);
- if (!this->IsImported()) {
+ if (this->IsNormal()) {
metConditions.insert(
TargetProperty::InitCondition::NormalNonImportedTarget);
}
@@ -1091,7 +1090,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
}
}
- if (this->IsImported() || mf->GetPropertyAsBool("SYSTEM")) {
+ if (!this->IsNormal() || mf->GetPropertyAsBool("SYSTEM")) {
this->SetProperty("SYSTEM", "ON");
}
@@ -1863,8 +1862,8 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value)
return;
}
/* no need to change anything if value does not change */
- if (!this->impl->ImportedGloballyVisible) {
- this->impl->ImportedGloballyVisible = true;
+ if (!this->IsImportedGloballyVisible()) {
+ this->impl->TargetVisibility = Visibility::ImportedGlobally;
this->GetGlobalGenerator()->IndexTarget(this);
}
} else if (cmHasLiteralPrefix(prop, "IMPORTED_LIBNAME") &&
@@ -2555,14 +2554,65 @@ bool cmTarget::IsAIX() const
return this->impl->IsAIX;
}
+bool cmTarget::IsNormal() const
+{
+ switch (this->impl->TargetVisibility) {
+ case Visibility::Normal:
+ return true;
+ case Visibility::Generated:
+ case Visibility::Imported:
+ case Visibility::ImportedGlobally:
+ return false;
+ }
+ assert(false && "unknown visibility (IsNormal)");
+ return false;
+}
+
+bool cmTarget::IsSynthetic() const
+{
+ switch (this->impl->TargetVisibility) {
+ case Visibility::Generated:
+ return true;
+ case Visibility::Normal:
+ case Visibility::Imported:
+ case Visibility::ImportedGlobally:
+ return false;
+ }
+ assert(false && "unknown visibility (IsSynthetic)");
+ return false;
+}
+
+bool cmTargetInternals::IsImported() const
+{
+ switch (this->TargetVisibility) {
+ case cmTarget::Visibility::Imported:
+ case cmTarget::Visibility::ImportedGlobally:
+ return true;
+ case cmTarget::Visibility::Normal:
+ case cmTarget::Visibility::Generated:
+ return false;
+ }
+ assert(false && "unknown visibility (IsImported)");
+ return false;
+}
+
bool cmTarget::IsImported() const
{
- return this->impl->IsImportedTarget;
+ return this->impl->IsImported();
}
bool cmTarget::IsImportedGloballyVisible() const
{
- return this->impl->ImportedGloballyVisible;
+ switch (this->impl->TargetVisibility) {
+ case Visibility::ImportedGlobally:
+ return true;
+ case Visibility::Normal:
+ case Visibility::Generated:
+ case Visibility::Imported:
+ return false;
+ }
+ assert(false && "unknown visibility (IsImportedGloballyVisible)");
+ return false;
}
bool cmTarget::IsPerConfig() const
@@ -2858,7 +2908,7 @@ bool cmTargetInternals::CheckImportedLibName(std::string const& prop,
std::string const& value) const
{
if (this->TargetType != cmStateEnums::INTERFACE_LIBRARY ||
- !this->IsImportedTarget) {
+ !this->IsImported()) {
this->Makefile->IssueMessage(
MessageType::FATAL_ERROR,
prop +
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 38bd036..95539fa 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -46,11 +46,12 @@ class BTs;
class cmTarget
{
public:
- enum Visibility
+ enum class Visibility
{
- VisibilityNormal,
- VisibilityImported,
- VisibilityImportedGlobally
+ Normal,
+ Generated,
+ Imported,
+ ImportedGlobally,
};
enum class PerConfig
@@ -205,6 +206,8 @@ public:
//! Return whether or not we are targeting AIX.
bool IsAIX() const;
+ bool IsNormal() const;
+ bool IsSynthetic() const;
bool IsImported() const;
bool IsImportedGloballyVisible() const;
bool IsPerConfig() const;
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 21d0cc9..d57b78b 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -50,10 +50,10 @@
#endif
#include <array>
+#include <chrono>
#include <cstdio>
#include <cstdlib>
#include <cstring>
-#include <ctime>
#include <iostream>
#include <memory>
#include <sstream>
@@ -1104,27 +1104,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args,
if (args[1] == "time" && args.size() > 2) {
std::vector<std::string> command(args.begin() + 2, args.end());
- clock_t clock_start;
- clock_t clock_finish;
- time_t time_start;
- time_t time_finish;
-
- time(&time_start);
- clock_start = clock();
int ret = 0;
+ auto time_start = std::chrono::steady_clock::now();
cmSystemTools::RunSingleCommand(command, nullptr, nullptr, &ret);
+ auto time_finish = std::chrono::steady_clock::now();
- clock_finish = clock();
- time(&time_finish);
-
- double clocks_per_sec = static_cast<double>(CLOCKS_PER_SEC);
- std::cout << "Elapsed time: "
- << static_cast<long>(time_finish - time_start) << " s. (time)"
- << ", "
- << static_cast<double>(clock_finish - clock_start) /
- clocks_per_sec
- << " s. (clock)"
- << "\n";
+ std::chrono::duration<double> time_elapsed = time_finish - time_start;
+ std::cout << "Elapsed time (seconds): " << time_elapsed.count() << "\n";
return ret;
}