diff options
author | Brad King <brad.king@kitware.com> | 2020-07-06 13:27:29 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-07-06 13:28:11 (GMT) |
commit | a4cfc7d03cc9988fff89f4a1fcc9e495c609d243 (patch) | |
tree | 678a9b9eec45efe687bfc333485680a4c7fa8971 /Source/cmMakefile.cxx | |
parent | ab46e71eeb7da390a5b18176d1fbf95233fa0e3e (diff) | |
parent | 7a969fe21d736b6c6755b5dc7a105f1427242cdd (diff) | |
download | CMake-a4cfc7d03cc9988fff89f4a1fcc9e495c609d243.zip CMake-a4cfc7d03cc9988fff89f4a1fcc9e495c609d243.tar.gz CMake-a4cfc7d03cc9988fff89f4a1fcc9e495c609d243.tar.bz2 |
Merge topic 'refactor-generator-configs'
7a969fe21d cmMakefile: Refactor API to better handle empty config values
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4957
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 2866975..4b595a6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1435,8 +1435,8 @@ void cmMakefile::InitializeFromParent(cmMakefile* parent) if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) { cmProp p = parent->GetProperty("COMPILE_DEFINITIONS"); this->SetProperty("COMPILE_DEFINITIONS", p ? p->c_str() : nullptr); - std::vector<std::string> configs; - this->GetConfigurations(configs); + std::vector<std::string> configs = + this->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig); for (std::string const& config : configs) { std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config)); @@ -3250,25 +3250,28 @@ void cmMakefile::RemoveVariablesInString(std::string& source, } } -std::string cmMakefile::GetConfigurations(std::vector<std::string>& configs, - bool singleConfig) const +std::string cmMakefile::GetDefaultConfiguration() const { if (this->GetGlobalGenerator()->IsMultiConfig()) { - this->GetDefExpandList("CMAKE_CONFIGURATION_TYPES", configs); - return ""; - } - const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); - if (singleConfig && !buildType.empty()) { - configs.push_back(buildType); + return std::string{}; } - return buildType; + return this->GetSafeDefinition("CMAKE_BUILD_TYPE"); } -std::vector<std::string> cmMakefile::GetGeneratorConfigs() const +std::vector<std::string> cmMakefile::GetGeneratorConfigs( + GeneratorConfigQuery mode) const { std::vector<std::string> configs; - GetConfigurations(configs); - if (configs.empty()) { + if (this->GetGlobalGenerator()->IsMultiConfig() || + mode == cmMakefile::OnlyMultiConfig) { + this->GetDefExpandList("CMAKE_CONFIGURATION_TYPES", configs); + } else { + const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE"); + if (!buildType.empty()) { + configs.emplace_back(buildType); + } + } + if (mode == cmMakefile::IncludeEmptyConfig && configs.empty()) { configs.emplace_back(); } return configs; |