summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaNormalTargetGenerator.cxx
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-01-10 21:31:29 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-01-10 21:31:29 (GMT)
commite8032e202e23436cc4301b7ded23c3fdce1161b2 (patch)
tree9269877224bb3d6d70972887965d5d331fe11e3b /Source/cmNinjaNormalTargetGenerator.cxx
parent75e109a5b304ed502894f5e0ea791b327f6d1963 (diff)
downloadCMake-e8032e202e23436cc4301b7ded23c3fdce1161b2.zip
CMake-e8032e202e23436cc4301b7ded23c3fdce1161b2.tar.gz
CMake-e8032e202e23436cc4301b7ded23c3fdce1161b2.tar.bz2
Ninja Multi-Config: Make cross-config building opt-in
Many users will want to use the Ninja Multi-Config generator like a traditional Visual Studio-style multi-config generator, which doesn't mix configurations - custom commands are built using target executables of the same configuration the command is for. We do not want to force these people to generate an N*N build matrix when they only need N*1, especially if they have lots of targets. Add a new variable, CMAKE_NINJA_CROSS_CONFIG_ENABLE, to opt-in to the cross-config build matrix.
Diffstat (limited to 'Source/cmNinjaNormalTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 987f241..8dbe1a3 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -72,6 +72,10 @@ void cmNinjaNormalTargetGenerator::Generate(const std::string& config)
// Write the build statements
bool firstForConfig = true;
for (auto const& fileConfig : this->GetConfigNames()) {
+ if (fileConfig != config &&
+ !this->GetGlobalGenerator()->EnableCrossConfigBuild()) {
+ continue;
+ }
this->WriteObjectBuildStatements(config, fileConfig, firstForConfig);
firstForConfig = false;
}
@@ -84,12 +88,18 @@ void cmNinjaNormalTargetGenerator::Generate(const std::string& config)
this->WriteDeviceLinkStatement(config);
firstForConfig = true;
for (auto const& fileConfig : this->GetConfigNames()) {
+ if (fileConfig != config &&
+ !this->GetGlobalGenerator()->EnableCrossConfigBuild()) {
+ continue;
+ }
this->WriteLinkStatement(config, fileConfig, firstForConfig);
firstForConfig = false;
}
}
- this->GetGlobalGenerator()->AddTargetAlias(
- this->GetTargetName(), this->GetGeneratorTarget(), "all");
+ if (this->GetGlobalGenerator()->EnableCrossConfigBuild()) {
+ this->GetGlobalGenerator()->AddTargetAlias(
+ this->GetTargetName(), this->GetGeneratorTarget(), "all");
+ }
// Find ADDITIONAL_CLEAN_FILES
this->AdditionalCleanFiles(config);