diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-08-04 21:43:56 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-08-26 17:45:51 (GMT) |
commit | db4cb92bda8b43c3d66d27533622bb802e823589 (patch) | |
tree | 4d539c364581b8299becd9b7c0f7dd97713f0197 | |
parent | e6ccbf6f30fb7b893b00a7c26fa165065eed4323 (diff) | |
download | CMake-db4cb92bda8b43c3d66d27533622bb802e823589.zip CMake-db4cb92bda8b43c3d66d27533622bb802e823589.tar.gz CMake-db4cb92bda8b43c3d66d27533622bb802e823589.tar.bz2 |
cmGeneratorTarget: Move compile options processing from cmTarget.
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 128 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 6 | ||||
-rw-r--r-- | Source/cmGhsMultiTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 89 | ||||
-rw-r--r-- | Source/cmTarget.h | 7 |
6 files changed, 154 insertions, 88 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 7ba2863..77e352f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -261,7 +261,8 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t), SourceFileFlagsConstructed(false), PolicyWarnedCMP0022(false), - DebugIncludesDone(false) + DebugIncludesDone(false), + DebugCompileOptionsDone(false) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -271,11 +272,17 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) t->GetIncludeDirectoriesEntries(), t->GetIncludeDirectoriesBacktraces(), this->IncludeDirectoriesEntries); + + CreatePropertyGeneratorExpressions( + t->GetCompileOptionsEntries(), + t->GetCompileOptionsBacktraces(), + this->CompileOptionsEntries); } cmGeneratorTarget::~cmGeneratorTarget() { cmDeleteAll(this->IncludeDirectoriesEntries); + cmDeleteAll(this->CompileOptionsEntries); cmDeleteAll(this->LinkInformation); this->LinkInformation.clear(); } @@ -2245,6 +2252,125 @@ cmGeneratorTarget::GetIncludeDirectories(const std::string& config, } //---------------------------------------------------------------------------- +static void processCompileOptionsInternal(cmGeneratorTarget const* tgt, + const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries, + std::vector<std::string> &options, + UNORDERED_SET<std::string> &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, const char *logName, + std::string const& language) +{ + cmMakefile *mf = tgt->Target->GetMakefile(); + + for (std::vector<cmGeneratorTarget::TargetPropertyEntry*>::const_iterator + it = entries.begin(), end = entries.end(); it != end; ++it) + { + std::vector<std::string> entryOptions; + cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf, + config, + false, + tgt->Target, + dagChecker, + language), + entryOptions); + std::string usedOptions; + for(std::vector<std::string>::iterator + li = entryOptions.begin(); li != entryOptions.end(); ++li) + { + std::string const& opt = *li; + + if(uniqueOptions.insert(opt).second) + { + options.push_back(opt); + if (debugOptions) + { + usedOptions += " * " + opt + "\n"; + } + } + } + if (!usedOptions.empty()) + { + mf->GetCMakeInstance()->IssueMessage(cmake::LOG, + std::string("Used compile ") + logName + + std::string(" for target ") + + tgt->GetName() + ":\n" + + usedOptions, (*it)->ge->GetBacktrace()); + } + } +} + +//---------------------------------------------------------------------------- +static void processCompileOptions(cmGeneratorTarget const* tgt, + const std::vector<cmGeneratorTarget::TargetPropertyEntry*> &entries, + std::vector<std::string> &options, + UNORDERED_SET<std::string> &uniqueOptions, + cmGeneratorExpressionDAGChecker *dagChecker, + const std::string& config, bool debugOptions, + std::string const& language) +{ + processCompileOptionsInternal(tgt, entries, options, uniqueOptions, + dagChecker, config, debugOptions, "options", + language); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetCompileOptions(std::vector<std::string> &result, + const std::string& config, + const std::string& language) const +{ + UNORDERED_SET<std::string> uniqueOptions; + + cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), + "COMPILE_OPTIONS", 0, 0); + + std::vector<std::string> debugProperties; + const char *debugProp = + this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOptions = !this->DebugCompileOptionsDone + && std::find(debugProperties.begin(), + debugProperties.end(), + "COMPILE_OPTIONS") + != debugProperties.end(); + + if (this->Makefile->IsConfigured()) + { + this->DebugCompileOptionsDone = true; + } + + processCompileOptions(this, + this->CompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + std::vector<cmGeneratorTarget::TargetPropertyEntry*> + linkInterfaceCompileOptionsEntries; + + AddInterfaceEntries( + this, config, "INTERFACE_COMPILE_OPTIONS", + linkInterfaceCompileOptionsEntries); + + processCompileOptions(this, + linkInterfaceCompileOptionsEntries, + result, + uniqueOptions, + &dagChecker, + config, + debugOptions, + language); + + cmDeleteAll(linkInterfaceCompileOptionsEntries); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GenerateTargetManifest( const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 513884f..1fb8cfe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -217,6 +217,10 @@ public: std::vector<std::string> GetIncludeDirectories( const std::string& config, const std::string& lang) const; + void GetCompileOptions(std::vector<std::string> &result, + const std::string& config, + const std::string& language) const; + bool IsSystemIncludeDirectory(const std::string& dir, const std::string& config) const; @@ -407,6 +411,7 @@ private: bool usage_requirements_only) const; std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries; + std::vector<TargetPropertyEntry*> CompileOptionsEntries; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, @@ -421,6 +426,7 @@ private: mutable OutputNameMapType OutputNameMap; mutable bool PolicyWarnedCMP0022; mutable bool DebugIncludesDone; + mutable bool DebugCompileOptionsDone; public: std::vector<cmTarget const*> const& diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 7af17cd..790e68b 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -558,7 +558,7 @@ bool cmGhsMultiTargetGenerator::IsNotKernel(std::string const &config, { bool output; std::vector<std::string> options; - this->Target->GetCompileOptions(options, config, language); + this->GeneratorTarget->GetCompileOptions(options, config, language); output = options.end() == std::find(options.begin(), options.end(), "-kernel"); return output; @@ -587,7 +587,7 @@ bool cmGhsMultiTargetGenerator::DetermineIfDynamicDownload( { std::vector<std::string> options; bool output = false; - this->Target->GetCompileOptions(options, config, language); + this->GeneratorTarget->GetCompileOptions(options, config, language); for (std::vector<std::string>::const_iterator options_i = options.begin(); options_i != options.end(); ++options_i) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index edb644d..89515ff 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1094,6 +1094,10 @@ void cmLocalGenerator::AddCompileOptions( ) { std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX"; + + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if(const char* langFlagRegexStr = this->Makefile->GetDefinition(langFlagRegexVar)) { @@ -1104,7 +1108,7 @@ void cmLocalGenerator::AddCompileOptions( { cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); } - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector<std::string>::const_iterator i = opts.begin(); i != opts.end(); ++i) { @@ -1125,7 +1129,7 @@ void cmLocalGenerator::AddCompileOptions( this->AppendFlags(flags, targetFlags); } std::vector<std::string> opts; - target->GetCompileOptions(opts, config, lang); + gtgt->GetCompileOptions(opts, config, lang); for(std::vector<std::string>::const_iterator i = opts.begin(); i != opts.end(); ++i) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 06d21cc..9e13ea0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -141,7 +141,6 @@ public: std::vector<cmListFileBacktrace> IncludeDirectoriesBacktraces; std::vector<std::string> CompileOptionsEntries; std::vector<cmListFileBacktrace> CompileOptionsBacktraces; - std::vector<TargetPropertyEntry*> CompileOptionsItems; std::vector<std::string> CompileFeaturesEntries; std::vector<cmListFileBacktrace> CompileFeaturesBacktraces; std::vector<TargetPropertyEntry*> CompileFeaturesItems; @@ -176,7 +175,6 @@ cmTarget::cmTarget() this->IsApple = false; this->IsImportedTarget = false; this->BuildInterfaceIncludesAppended = false; - this->DebugCompileOptionsDone = false; this->DebugCompileFeaturesDone = false; this->DebugCompileDefinitionsDone = false; this->DebugSourcesDone = false; @@ -424,11 +422,6 @@ void CreatePropertyGeneratorExpressions( void cmTarget::Compute() { CreatePropertyGeneratorExpressions( - this->Internal->CompileOptionsEntries, - this->Internal->CompileOptionsBacktraces, - this->Internal->CompileOptionsItems); - - CreatePropertyGeneratorExpressions( this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); @@ -1322,6 +1315,16 @@ cmBacktraceRange cmTarget::GetIncludeDirectoriesBacktraces() const return cmMakeRange(this->Internal->IncludeDirectoriesBacktraces); } +cmStringRange cmTarget::GetCompileOptionsEntries() const +{ + return cmMakeRange(this->Internal->CompileOptionsEntries); +} + +cmBacktraceRange cmTarget::GetCompileOptionsBacktraces() const +{ + return cmMakeRange(this->Internal->CompileOptionsBacktraces); +} + #if defined(_WIN32) && !defined(__CYGWIN__) //---------------------------------------------------------------------------- void @@ -1967,77 +1970,6 @@ static void processCompileOptionsInternal(cmTarget const* tgt, } //---------------------------------------------------------------------------- -static void processCompileOptions(cmTarget const* tgt, - const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, - std::vector<std::string> &options, - UNORDERED_SET<std::string> &uniqueOptions, - cmGeneratorExpressionDAGChecker *dagChecker, - const std::string& config, bool debugOptions, - std::string const& language) -{ - processCompileOptionsInternal(tgt, entries, options, uniqueOptions, - dagChecker, config, debugOptions, "options", - language); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetCompileOptions(std::vector<std::string> &result, - const std::string& config, - const std::string& language) const -{ - UNORDERED_SET<std::string> uniqueOptions; - - cmGeneratorExpressionDAGChecker dagChecker(this->GetName(), - "COMPILE_OPTIONS", 0, 0); - - std::vector<std::string> debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOptions = !this->DebugCompileOptionsDone - && std::find(debugProperties.begin(), - debugProperties.end(), - "COMPILE_OPTIONS") - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompileOptionsDone = true; - } - - processCompileOptions(this, - this->Internal->CompileOptionsItems, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - std::vector<cmTargetInternals::TargetPropertyEntry*> - linkInterfaceCompileOptionsEntries; - - this->Internal->AddInterfaceEntries( - this, config, "INTERFACE_COMPILE_OPTIONS", - linkInterfaceCompileOptionsEntries); - - processCompileOptions(this, - linkInterfaceCompileOptionsEntries, - result, - uniqueOptions, - &dagChecker, - config, - debugOptions, - language); - - cmDeleteAll(linkInterfaceCompileOptionsEntries); -} - -//---------------------------------------------------------------------------- static void processCompileDefinitions(cmTarget const* tgt, const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries, std::vector<std::string> &options, @@ -4166,7 +4098,6 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 13e4f2d..05b6aec 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -375,9 +375,6 @@ public: void AppendBuildInterfaceIncludes(); - void GetCompileOptions(std::vector<std::string> &result, - const std::string& config, - const std::string& language) const; void GetCompileFeatures(std::vector<std::string> &features, const std::string& config) const; @@ -402,6 +399,9 @@ public: cmStringRange GetIncludeDirectoriesEntries() const; cmBacktraceRange GetIncludeDirectoriesBacktraces() const; + cmStringRange GetCompileOptionsEntries() const; + cmBacktraceRange GetCompileOptionsBacktraces() const; + #if defined(_WIN32) && !defined(__CYGWIN__) const LinkLibraryVectorType &GetLinkLibrariesForVS6() const { return this->LinkLibrariesForVS6;} @@ -516,7 +516,6 @@ private: bool IsApple; bool IsImportedTarget; bool BuildInterfaceIncludesAppended; - mutable bool DebugCompileOptionsDone; mutable bool DebugCompileDefinitionsDone; mutable bool DebugSourcesDone; mutable bool DebugCompileFeaturesDone; |