diff options
author | Brad King <brad.king@kitware.com> | 2020-01-13 15:34:11 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-13 15:34:18 (GMT) |
commit | 041e58d195587ddc9aa6d87148ea9c3ab63310d1 (patch) | |
tree | 47b02da5df58b99df0e49872ccce4c1252b84774 /Source | |
parent | 320ad3f31f7184e82e6fe38afa69d0066d796788 (diff) | |
parent | e8032e202e23436cc4301b7ded23c3fdce1161b2 (diff) | |
download | CMake-041e58d195587ddc9aa6d87148ea9c3ab63310d1.zip CMake-041e58d195587ddc9aa6d87148ea9c3ab63310d1.tar.gz CMake-041e58d195587ddc9aa6d87148ea9c3ab63310d1.tar.bz2 |
Merge topic 'ninja-cross-build-disable'
e8032e202e Ninja Multi-Config: Make cross-config building opt-in
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4205
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 14 |
3 files changed, 25 insertions, 4 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) { diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index fdd9dda..3545f1e 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -395,6 +395,8 @@ public: return this->Configs[config].ByproductsForCleanTarget; } + bool EnableCrossConfigBuild() const; + protected: void Generate() override; diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 360ef3c..517241e 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); |