summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalNinjaGenerator.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-02-04 16:06:46 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-02-04 19:13:07 (GMT)
commit16a4ba5b311669000d83c99b1b985597205d3d69 (patch)
treed488198bc202d2daa0ef63a11fc47d81e420f801 /Source/cmGlobalNinjaGenerator.cxx
parent2ac835b9f9a7a4dec16c498a51c0dbc3d64844bc (diff)
downloadCMake-16a4ba5b311669000d83c99b1b985597205d3d69.zip
CMake-16a4ba5b311669000d83c99b1b985597205d3d69.tar.gz
CMake-16a4ba5b311669000d83c99b1b985597205d3d69.tar.bz2
Ninja Multi-Config: Use build.ninja if cmake --build has no --config
If cmake --build is called with no --config argument, and a build.ninja file is available, use that instead of defaulting to the Debug config.
Diffstat (limited to 'Source/cmGlobalNinjaGenerator.cxx')
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx41
1 files changed, 30 insertions, 11 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index f7694ff..ff1e5d6 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -800,8 +800,7 @@ cmGlobalNinjaGenerator::GenerateBuildCommand(
makeCommand.Add("-j", std::to_string(jobs));
}
- this->AppendNinjaFileArgument(makeCommand,
- config.empty() ? "Debug" : config);
+ this->AppendNinjaFileArgument(makeCommand, config);
makeCommand.Add(makeOptions.begin(), makeOptions.end());
for (const auto& tname : targetNames) {
@@ -2559,8 +2558,10 @@ void cmGlobalNinjaMultiGenerator::CloseBuildFileStreams()
void cmGlobalNinjaMultiGenerator::AppendNinjaFileArgument(
GeneratedMakeCommand& command, const std::string& config) const
{
- command.Add("-f");
- command.Add(GetNinjaConfigFilename(config));
+ if (!config.empty()) {
+ command.Add("-f");
+ command.Add(GetNinjaConfigFilename(config));
+ }
}
std::string cmGlobalNinjaMultiGenerator::GetNinjaImplFilename(
@@ -2601,11 +2602,30 @@ void cmGlobalNinjaMultiGenerator::GetQtAutoGenConfigs(
bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
{
- auto configsVec = this->Makefiles.front()->GetGeneratorConfigs();
+ return this->ReadCacheEntriesForBuild(*this->Makefiles.front()->GetState());
+}
+
+std::string cmGlobalNinjaMultiGenerator::GetDefaultBuildConfig() const
+{
+ if (this->DefaultFileConfig.empty()) {
+ return "Debug";
+ }
+ return "";
+}
+
+bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
+ const cmState& state)
+{
+ std::vector<std::string> configsVec;
+ cmExpandList(state.GetSafeCacheEntryValue("CMAKE_CONFIGURATION_TYPES"),
+ configsVec);
+ if (configsVec.empty()) {
+ configsVec.emplace_back();
+ }
std::set<std::string> configs(configsVec.cbegin(), configsVec.cend());
- this->DefaultFileConfig = this->Makefiles.front()->GetSafeDefinition(
- "CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG");
+ this->DefaultFileConfig =
+ state.GetSafeCacheEntryValue("CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG");
if (!this->DefaultFileConfig.empty() &&
!configs.count(this->DefaultFileConfig)) {
std::ostringstream msg;
@@ -2618,9 +2638,8 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
}
std::vector<std::string> crossConfigsVec;
- cmExpandList(
- this->Makefiles.front()->GetSafeDefinition("CMAKE_NMC_CROSS_CONFIGS"),
- crossConfigsVec);
+ cmExpandList(state.GetSafeCacheEntryValue("CMAKE_NMC_CROSS_CONFIGS"),
+ crossConfigsVec);
auto crossConfigs = ListSubsetWithAll(configs, crossConfigsVec);
if (!crossConfigs) {
std::ostringstream msg;
@@ -2633,7 +2652,7 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
this->CrossConfigs = *crossConfigs;
auto defaultConfigsString =
- this->Makefiles.front()->GetSafeDefinition("CMAKE_NMC_DEFAULT_CONFIGS");
+ state.GetSafeCacheEntryValue("CMAKE_NMC_DEFAULT_CONFIGS");
if (defaultConfigsString.empty()) {
defaultConfigsString = this->DefaultFileConfig;
}