diff options
author | Deniz Bahadir <dbahadir@benocs.com> | 2020-09-22 12:04:26 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-09-23 14:05:55 (GMT) |
commit | 2f76e7429b96ae05e5f63d6458555a06b19c62e5 (patch) | |
tree | 8496837a64a4165fa340017e45d6fc43bcaa780b /Source | |
parent | d575ecc9dedd214ebd941913b81124a674be5008 (diff) | |
download | CMake-2f76e7429b96ae05e5f63d6458555a06b19c62e5.zip CMake-2f76e7429b96ae05e5f63d6458555a06b19c62e5.tar.gz CMake-2f76e7429b96ae05e5f63d6458555a06b19c62e5.tar.bz2 |
OBJECT libraries: Properly recognize if sources depend on configuration
Fixes: #21198
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 5 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 18 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 12 |
3 files changed, 26 insertions, 9 deletions
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index d3308e2..4ca7405 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1664,9 +1664,8 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode if (context->EvaluateForBuildsystem) { // Use object file directory with buildsystem placeholder. obj_dir = gt->ObjectDirectory; - // Here we assume that the set of object files produced - // by an object library does not vary with configuration - // and do not set HadContextSensitiveCondition to true. + context->HadContextSensitiveCondition = + gt->HasContextDependentSources(); } else { // Use object file directory with per-config location. obj_dir = gt->GetObjectDirectory(context->Config); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index d9b2f66..8589ab1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -276,8 +276,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) , DebugLinkDirectoriesDone(false) , DebugPrecompileHeadersDone(false) , DebugSourcesDone(false) - , SourcesAreContextDependent(true) , UtilityItemsDone(false) + , SourcesAreContextDependent(Tribool::Indeterminate) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -692,7 +692,7 @@ void cmGeneratorTarget::ClearSourcesCache() { this->AllConfigSources.clear(); this->KindedSourcesMap.clear(); - this->SourcesAreContextDependent = true; + this->SourcesAreContextDependent = Tribool::Indeterminate; this->Objects.clear(); this->VisitedConfigsForObjects.clear(); } @@ -1653,10 +1653,13 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths( uniqueSrcs, debugSources); } + // Determine if sources are context-dependent or not. if (!contextDependentDirectSources && !(contextDependentInterfaceSources && numFilesBefore < files.size()) && !(contextDependentObjects && numFilesBefore2 < files.size())) { - this->SourcesAreContextDependent = false; + this->SourcesAreContextDependent = Tribool::False; + } else { + this->SourcesAreContextDependent = Tribool::True; } return files; @@ -1731,9 +1734,9 @@ cmGeneratorTarget::GetSourceFilesWithoutObjectLibraries( cmGeneratorTarget::KindedSources const& cmGeneratorTarget::GetKindedSources( std::string const& config) const { - // If we already processed one configuration and found no dependenc + // If we already processed one configuration and found no dependency // on configuration then always use the one result. - if (!this->SourcesAreContextDependent) { + if (this->SourcesAreContextDependent == Tribool::False) { return this->KindedSourcesMap.begin()->second; } @@ -7518,6 +7521,11 @@ bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& config, return false; } +bool cmGeneratorTarget::HasContextDependentSources() const +{ + return this->SourcesAreContextDependent == Tribool::True; +} + bool cmGeneratorTarget::IsExecutableWithExports() const { return (this->GetType() == cmStateEnums::EXECUTABLE && diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 4741b2a..8e0def7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -713,6 +713,10 @@ public: bool GetImplibGNUtoMS(std::string const& config, std::string const& gnuName, std::string& out, const char* newExt = nullptr) const; + /** Can only ever return true if GetSourceFilePaths() was called before. + Otherwise, this is indeterminate and false will be assumed/returned! */ + bool HasContextDependentSources() const; + bool IsExecutableWithExports() const; /** Return whether or not the target has a DLL import library. */ @@ -1069,8 +1073,14 @@ private: mutable bool DebugLinkDirectoriesDone; mutable bool DebugPrecompileHeadersDone; mutable bool DebugSourcesDone; - mutable bool SourcesAreContextDependent; mutable bool UtilityItemsDone; + enum class Tribool + { + False = 0x0, + True = 0x1, + Indeterminate = 0x2 + }; + mutable Tribool SourcesAreContextDependent; bool ComputePDBOutputDir(const std::string& kind, const std::string& config, std::string& out) const; |