diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2020-04-02 12:16:43 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2020-04-02 15:51:19 (GMT) |
commit | f593b354da2e9637e9b869688934f0ba2544ebed (patch) | |
tree | 605f4a05ad9773e658fd14974f7000f769a90014 /Source/cmNinjaTargetGenerator.cxx | |
parent | be154ea1e3efcd1a13952701337378a01ca0cd19 (diff) | |
download | CMake-f593b354da2e9637e9b869688934f0ba2544ebed.zip CMake-f593b354da2e9637e9b869688934f0ba2544ebed.tar.gz CMake-f593b354da2e9637e9b869688934f0ba2544ebed.tar.bz2 |
PCH: Add support for multi architecture iOS projects
Fixes: #20497
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 8833fa4..ed74cf9 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -7,6 +7,8 @@ #include <iterator> #include <map> #include <ostream> +#include <unordered_map> +#include <unordered_set> #include <utility> #include <cm/memory> @@ -157,7 +159,26 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject( cmSourceFile const* source, const std::string& language, const std::string& config) { - std::string flags = this->GetFlags(language, config); + std::vector<std::string> architectures; + std::unordered_map<std::string, std::string> pchSources; + this->GeneratorTarget->GetAppleArchs(config, architectures); + if (architectures.empty()) { + architectures.emplace_back(); + } + + std::string filterArch; + for (const std::string& arch : architectures) { + const std::string pchSource = + this->GeneratorTarget->GetPchSource(config, language, arch); + if (pchSource == source->GetFullPath()) { + filterArch = arch; + } + if (!pchSource.empty()) { + pchSources.insert(std::make_pair(pchSource, arch)); + } + } + + std::string flags = this->GetFlags(language, config, filterArch); // Add Fortran format flags. if (language == "Fortran") { @@ -181,14 +202,12 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject( } // Add precompile headers compile options. - const std::string pchSource = - this->GeneratorTarget->GetPchSource(config, language); - - if (!pchSource.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) { + if (!pchSources.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) { std::string pchOptions; - if (source->GetFullPath() == pchSource) { - pchOptions = - this->GeneratorTarget->GetPchCreateCompileOptions(config, language); + auto pchIt = pchSources.find(source->GetFullPath()); + if (pchIt != pchSources.end()) { + pchOptions = this->GeneratorTarget->GetPchCreateCompileOptions( + config, language, pchIt->second); } else { pchOptions = this->GeneratorTarget->GetPchUseCompileOptions(config, language); @@ -1050,12 +1069,30 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( // Add precompile headers dependencies std::vector<std::string> depList; - const std::string pchSource = - this->GeneratorTarget->GetPchSource(config, language); - if (!pchSource.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) { - depList.push_back(this->GeneratorTarget->GetPchHeader(config, language)); - if (source->GetFullPath() != pchSource) { - depList.push_back(this->GeneratorTarget->GetPchFile(config, language)); + std::vector<std::string> architectures; + this->GeneratorTarget->GetAppleArchs(config, architectures); + if (architectures.empty()) { + architectures.emplace_back(); + } + + std::unordered_set<std::string> pchSources; + for (const std::string& arch : architectures) { + const std::string pchSource = + this->GeneratorTarget->GetPchSource(config, language, arch); + + if (!pchSource.empty()) { + pchSources.insert(pchSource); + } + } + + if (!pchSources.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) { + for (const std::string& arch : architectures) { + depList.push_back( + this->GeneratorTarget->GetPchHeader(config, language, arch)); + if (pchSources.find(source->GetFullPath()) == pchSources.end()) { + depList.push_back( + this->GeneratorTarget->GetPchFile(config, language, arch)); + } } } @@ -1208,8 +1245,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(), vars); - if (!pchSource.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) { - if (source->GetFullPath() == pchSource) { + if (!pchSources.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) { + auto pchIt = pchSources.find(source->GetFullPath()); + if (pchIt != pchSources.end()) { this->addPoolNinjaVariable("JOB_POOL_PRECOMPILE_HEADER", this->GetGeneratorTarget(), vars); } |