diff options
author | Brad King <brad.king@kitware.com> | 2024-05-02 13:44:36 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-05-02 13:44:48 (GMT) |
commit | 721b86c02b9923901baf5d79c479f2626d74f1ce (patch) | |
tree | ee8d0e7bde551b8dd26a64bd2e9e72c084a21ba4 | |
parent | f0b40d451e9f26b50a4df8234aa24de000198929 (diff) | |
parent | ef006ebd9b11945cfb1b93f85d9ff85a077e8991 (diff) | |
download | CMake-721b86c02b9923901baf5d79c479f2626d74f1ce.zip CMake-721b86c02b9923901baf5d79c479f2626d74f1ce.tar.gz CMake-721b86c02b9923901baf5d79c479f2626d74f1ce.tar.bz2 |
Merge topic 'pch-single-arch'
ef006ebd9b PCH: Use per-arch .pch files only when building multiple Apple architectures
99bfb430ee cmNinjaTargetGenerator: Remove unused Apple architecture list
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !9483
-rw-r--r-- | Source/cmFileAPICodemodel.cxx | 9 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 14 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 2 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 13 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 11 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 26 |
6 files changed, 34 insertions, 41 deletions
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 869b94a..b9daffb 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -1384,14 +1384,11 @@ CompileData Target::BuildCompileData(cmSourceFile* sf) } // Add precompile headers compile options. - std::vector<std::string> architectures = - this->GT->GetAppleArchs(this->Config, fd.Language); - if (architectures.empty()) { - architectures.emplace_back(); - } + std::vector<std::string> pchArchs = + this->GT->GetPchArchs(this->Config, fd.Language); std::unordered_map<std::string, std::string> pchSources; - for (const std::string& arch : architectures) { + for (const std::string& arch : pchArchs) { const std::string pchSource = this->GT->GetPchSource(this->Config, fd.Language, arch); if (!pchSource.empty()) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 38f25d7..75f3b6d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4370,6 +4370,20 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetPrecompileHeaders( return list; } +std::vector<std::string> cmGeneratorTarget::GetPchArchs( + std::string const& config, std::string const& lang) const +{ + std::vector<std::string> pchArchs; + if (!this->GetGlobalGenerator()->IsXcode()) { + pchArchs = this->GetAppleArchs(config, lang); + } + if (pchArchs.size() < 2) { + // We do not need per-arch PCH files when building for one architecture. + pchArchs = { {} }; + } + return pchArchs; +} + std::string cmGeneratorTarget::GetPchHeader(const std::string& config, const std::string& language, const std::string& arch) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index b2c383a..5c7201d 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -599,6 +599,8 @@ public: std::vector<BT<std::string>> GetPrecompileHeaders( const std::string& config, const std::string& language) const; + std::vector<std::string> GetPchArchs(std::string const& config, + std::string const& lang) const; std::string GetPchHeader(const std::string& config, const std::string& language, const std::string& arch = std::string()) const; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 7a41113..ffd41d2 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2721,15 +2721,10 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) continue; } - std::vector<std::string> architectures; - if (!this->GetGlobalGenerator()->IsXcode()) { - architectures = target->GetAppleArchs(config, lang); - } - if (architectures.empty()) { - architectures.emplace_back(); - } else { + std::vector<std::string> pchArchs = target->GetPchArchs(config, lang); + if (pchArchs.size() > 1) { std::string useMultiArchPch; - for (const std::string& arch : architectures) { + for (const std::string& arch : pchArchs) { const std::string pchHeader = target->GetPchHeader(config, lang, arch); if (!pchHeader.empty()) { @@ -2746,7 +2741,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) } } - for (const std::string& arch : architectures) { + for (const std::string& arch : pchArchs) { const std::string pchSource = target->GetPchSource(config, lang, arch); const std::string pchHeader = target->GetPchHeader(config, lang, arch); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 960b358..d5c50bc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -672,15 +672,12 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( std::string const configUpper = cmSystemTools::UpperCase(config); // Add precompile headers dependencies - std::vector<std::string> architectures = - this->GeneratorTarget->GetAppleArchs(config, lang); - if (architectures.empty()) { - architectures.emplace_back(); - } + std::vector<std::string> pchArchs = + this->GeneratorTarget->GetPchArchs(config, lang); std::string filterArch; std::unordered_map<std::string, std::string> pchSources; - for (const std::string& arch : architectures) { + for (const std::string& arch : pchArchs) { const std::string pchSource = this->GeneratorTarget->GetPchSource(config, lang, arch); if (pchSource == source.GetFullPath()) { @@ -692,7 +689,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( } if (!pchSources.empty() && !source.GetProperty("SKIP_PRECOMPILE_HEADERS")) { - for (const std::string& arch : architectures) { + for (const std::string& arch : pchArchs) { std::string const& pchHeader = this->GeneratorTarget->GetPchHeader(config, lang, arch); depends.push_back(pchHeader); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c52a012..c61f445 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -189,14 +189,11 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject( const std::string& config, const std::string& objectFileName) { std::unordered_map<std::string, std::string> pchSources; - std::vector<std::string> architectures = - this->GeneratorTarget->GetAppleArchs(config, language); - if (architectures.empty()) { - architectures.emplace_back(); - } + std::vector<std::string> pchArchs = + this->GeneratorTarget->GetPchArchs(config, language); std::string filterArch; - for (const std::string& arch : architectures) { + for (const std::string& arch : pchArchs) { const std::string pchSource = this->GeneratorTarget->GetPchSource(config, language, arch); if (pchSource == source->GetFullPath()) { @@ -1500,14 +1497,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( // Add precompile headers dependencies std::vector<std::string> depList; - std::vector<std::string> architectures = - this->GeneratorTarget->GetAppleArchs(config, language); - if (architectures.empty()) { - architectures.emplace_back(); - } + std::vector<std::string> pchArchs = + this->GeneratorTarget->GetPchArchs(config, language); std::unordered_set<std::string> pchSources; - for (const std::string& arch : architectures) { + for (const std::string& arch : pchArchs) { const std::string pchSource = this->GeneratorTarget->GetPchSource(config, language, arch); @@ -1517,7 +1511,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } if (!pchSources.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) { - for (const std::string& arch : architectures) { + for (const std::string& arch : pchArchs) { depList.push_back( this->GeneratorTarget->GetPchHeader(config, language, arch)); if (pchSources.find(source->GetFullPath()) == pchSources.end()) { @@ -1841,12 +1835,6 @@ void cmNinjaTargetGenerator::WriteCxxModuleBmiBuildStatement( std::vector<std::string> depList; - std::vector<std::string> architectures = - this->GeneratorTarget->GetAppleArchs(config, language); - if (architectures.empty()) { - architectures.emplace_back(); - } - bmiBuild.OrderOnlyDeps.push_back(this->OrderDependsTargetForTarget(config)); // For some cases we scan to dynamically discover dependencies. |