diff options
author | Justin Goshi <jgoshi@microsoft.com> | 2019-09-03 17:25:44 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-09-10 14:45:41 (GMT) |
commit | 1f6a436bf4188007b87d2582367cde8f970d5e1f (patch) | |
tree | 42f54124bf8b08c8ff3087d43b5aab7675b9b8c9 /Source | |
parent | 5355a60fd02417a004c6b4b6b8848ce0ff1ea9fa (diff) | |
download | CMake-1f6a436bf4188007b87d2582367cde8f970d5e1f.zip CMake-1f6a436bf4188007b87d2582367cde8f970d5e1f.tar.gz CMake-1f6a436bf4188007b87d2582367cde8f970d5e1f.tar.bz2 |
cmLocalGenerator: Add AddCompileOptions overload with backtraces
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 43 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 3 |
2 files changed, 38 insertions, 8 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index bd5e5a2..44ba79a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -833,6 +833,16 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, const std::string& lang, const std::string& config) { + std::vector<BT<std::string>> tmpFlags; + this->AddCompileOptions(tmpFlags, target, lang, config); + this->AppendFlags(flags, tmpFlags); +} + +void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags, + cmGeneratorTarget* target, + const std::string& lang, + const std::string& config) +{ std::string langFlagRegexVar = std::string("CMAKE_") + lang + "_FLAG_REGEX"; if (const char* langFlagRegexStr = @@ -843,20 +853,28 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, cmSystemTools::ParseWindowsCommandLine(targetFlags, opts); // Re-escape these flags since COMPILE_FLAGS were already parsed // as a command line above. - this->AppendCompileOptions(flags, opts, langFlagRegexStr); + std::string compileOpts; + this->AppendCompileOptions(compileOpts, opts, langFlagRegexStr); + if (!compileOpts.empty()) { + flags.emplace_back(std::move(compileOpts)); + } } - std::vector<std::string> targetCompileOpts; - target->GetCompileOptions(targetCompileOpts, config, lang); + std::vector<BT<std::string>> targetCompileOpts = + target->GetCompileOptions(config, lang); // COMPILE_OPTIONS are escaped. this->AppendCompileOptions(flags, targetCompileOpts, langFlagRegexStr); } else { // Use all flags. if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) { // COMPILE_FLAGS are not escaped for historical reasons. - this->AppendFlags(flags, targetFlags); + std::string compileFlags; + this->AppendFlags(compileFlags, targetFlags); + if (!compileFlags.empty()) { + flags.emplace_back(std::move(compileFlags)); + } } - std::vector<std::string> targetCompileOpts; - target->GetCompileOptions(targetCompileOpts, config, lang); + std::vector<BT<std::string>> targetCompileOpts = + target->GetCompileOptions(config, lang); // COMPILE_OPTIONS are escaped. this->AppendCompileOptions(flags, targetCompileOpts); } @@ -885,7 +903,12 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, return; } } - this->AddCompilerRequirementFlag(flags, target, lang); + + std::string compReqFlag; + this->AddCompilerRequirementFlag(compReqFlag, target, lang); + if (!compReqFlag.empty()) { + flags.emplace_back(std::move(compReqFlag)); + } // Add compile flag for the MSVC compiler only. cmMakefile* mf = this->GetMakefile(); @@ -906,7 +929,11 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, std::string isJMCEnabled = cge->Evaluate(this, config); if (cmIsOn(isJMCEnabled)) { std::vector<std::string> optVec = cmExpandedList(jmc); - this->AppendCompileOptions(flags, optVec); + std::string jmcFlags; + this->AppendCompileOptions(jmcFlags, optVec); + if (!jmcFlags.empty()) { + flags.emplace_back(std::move(jmcFlags)); + } } } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index ec97ac2..52f8ac8 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -288,6 +288,9 @@ public: void AddCompileOptions(std::string& flags, cmGeneratorTarget* target, const std::string& lang, const std::string& config); + void AddCompileOptions(std::vector<BT<std::string>>& flags, + cmGeneratorTarget* target, const std::string& lang, + const std::string& config); std::string GetProjectName() const; |