diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 4 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 15 |
2 files changed, 17 insertions, 2 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 648708a..4bad7ab 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4087,7 +4087,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, if (this->GetGlobalGenerator()->IsXcode()) { file << "#ifndef CMAKE_SKIP_PRECOMPILE_HEADERS\n"; } - if (language == "CXX") { + if (language == "CXX" && !this->GetGlobalGenerator()->IsXcode()) { file << "#ifdef __cplusplus\n"; } for (auto const& header_bt : headers) { @@ -4105,7 +4105,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config, firstHeaderOnDisk = header_bt.Value; } } - if (language == "CXX") { + if (language == "CXX" && !this->GetGlobalGenerator()->IsXcode()) { file << "#endif // __cplusplus\n"; } if (this->GetGlobalGenerator()->IsXcode()) { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 5fe5c75..8be015e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2510,6 +2510,16 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) static const std::array<std::string, 4> langs = { { "C", "CXX", "OBJC", "OBJCXX" } }; + bool haveAnyPch = false; + if (this->GetGlobalGenerator()->IsXcode()) { + for (const std::string& lang : langs) { + const std::string pchHeader = target->GetPchHeader(config, lang, ""); + if (!pchHeader.empty()) { + haveAnyPch = true; + } + } + } + for (const std::string& lang : langs) { auto langSources = std::count_if( sources.begin(), sources.end(), [lang](cmSourceFile* sf) { @@ -2550,6 +2560,11 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) const std::string pchHeader = target->GetPchHeader(config, lang, arch); if (pchSource.empty() || pchHeader.empty()) { + if (this->GetGlobalGenerator()->IsXcode() && haveAnyPch) { + for (auto* sf : sources) { + sf->SetProperty("SKIP_PRECOMPILE_HEADERS", "ON"); + } + } continue; } |