diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-01-10 21:31:29 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-01-10 21:31:29 (GMT) |
commit | e8032e202e23436cc4301b7ded23c3fdce1161b2 (patch) | |
tree | 9269877224bb3d6d70972887965d5d331fe11e3b /Source/cmGlobalNinjaGenerator.cxx | |
parent | 75e109a5b304ed502894f5e0ea791b327f6d1963 (diff) | |
download | CMake-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/cmGlobalNinjaGenerator.cxx')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 35b4f91..ea66e3d 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1274,7 +1274,7 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) } // Add target for all configs - if (this->IsMultiConfig()) { + if (this->EnableCrossConfigBuild()) { build.ExplicitDeps.clear(); for (auto const& config : configs) { build.ExplicitDeps.push_back(this->BuildAlias( @@ -1710,6 +1710,9 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) config)); } for (auto const& fileConfig : configs) { + if (fileConfig != config && !this->EnableCrossConfigBuild()) { + continue; + } if (this->IsMultiConfig()) { build.Variables["FILE_ARG"] = cmStrCat( "-f ", cmGlobalNinjaMultiGenerator::GetNinjaFilename(fileConfig)); @@ -1718,7 +1721,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os) } } - if (this->IsMultiConfig()) { + if (this->EnableCrossConfigBuild()) { build.Outputs.front() = this->BuildAlias( this->NinjaOutputPath(this->GetCleanTargetName()), "all"); build.ExplicitDeps.clear(); @@ -2192,6 +2195,12 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( return true; } +bool cmGlobalNinjaGenerator::EnableCrossConfigBuild() const +{ + return this->IsMultiConfig() && + this->Makefiles.front()->IsOn("CMAKE_NINJA_CROSS_CONFIG_ENABLE"); +} + int cmcmd_cmake_ninja_dyndep(std::vector<std::string>::const_iterator argBeg, std::vector<std::string>::const_iterator argEnd) { |