diff options
author | Brad King <brad.king@kitware.com> | 2022-04-12 12:11:58 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-04-12 12:11:58 (GMT) |
commit | 5ac0c541b498f255e1d0aefa767b87d958e1fbbc (patch) | |
tree | a85d85b7a1ace54eca746470bb0314b835aaf9ad | |
parent | 8242631e63e0444372cd4f8f7b36ea440fe67a35 (diff) | |
parent | 476c6a89109d9737715c74bf3458628b665c4c8d (diff) | |
download | CMake-5ac0c541b498f255e1d0aefa767b87d958e1fbbc.zip CMake-5ac0c541b498f255e1d0aefa767b87d958e1fbbc.tar.gz CMake-5ac0c541b498f255e1d0aefa767b87d958e1fbbc.tar.bz2 |
Merge branch 'xcode-pch' into release-3.22
Merge-request: !7166
-rw-r--r-- | Source/cmLocalGenerator.cxx | 10 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake | 17 | ||||
-rw-r--r-- | Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake | 1 | ||||
-rw-r--r-- | Tests/RunCMake/RunCMake.cmake | 2 |
4 files changed, 25 insertions, 5 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index fc5e6e5..feea49f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2510,12 +2510,12 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) static const std::array<std::string, 4> langs = { { "C", "CXX", "OBJC", "OBJCXX" } }; - bool haveAnyPch = false; + std::set<std::string> pchLangSet; if (this->GetGlobalGenerator()->IsXcode()) { for (const std::string& lang : langs) { const std::string pchHeader = target->GetPchHeader(config, lang, ""); if (!pchHeader.empty()) { - haveAnyPch = true; + pchLangSet.emplace(lang); } } } @@ -2560,9 +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) { + if (this->GetGlobalGenerator()->IsXcode() && !pchLangSet.empty()) { for (auto* sf : sources) { - sf->SetProperty("SKIP_PRECOMPILE_HEADERS", "ON"); + if (pchLangSet.find(sf->GetLanguage()) == pchLangSet.end()) { + sf->SetProperty("SKIP_PRECOMPILE_HEADERS", "ON"); + } } } continue; diff --git a/Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake b/Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake new file mode 100644 index 0000000..dd582ac --- /dev/null +++ b/Tests/RunCMake/PrecompileHeaders/PchIncludedOneLanguage.cmake @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.16) +project(PchIncludedAllLanguages C CXX) + +if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH) + add_definitions(-DHAVE_PCH_SUPPORT) +endif() + +add_executable(main + main.cpp + empty.c + pch-included.cpp +) + +target_precompile_headers(main PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/pch.h>) + +enable_testing() +add_test(NAME main COMMAND main) diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake index ca5b52e..29611ae 100644 --- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake +++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake @@ -29,4 +29,5 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja") endif() run_test(PchReuseFromObjLib) run_test(PchIncludedAllLanguages) +run_test(PchIncludedOneLanguage) run_test(PchLibObjLibExe) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 3363a57..5e66a52 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -157,7 +157,7 @@ function(run_cmake test) "|[^\n]*install_name_tool: warning: changes being made to the file will invalidate the code signature in:" "|[^\n]*xcodebuild[^\n]*DVTPlugInManager" "|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type" - "|[^\n]*objc[^\n]*: Class AMSupportURL[^\n]* One of the two will be used. Which one is undefined." + "|[^\n]*objc[^\n]*: Class [^\n]* One of the two will be used. Which one is undefined." "|[^\n]*is a member of multiple groups" "|[^\n]*offset in archive not a multiple of 8" "|[^\n]*from Time Machine by path" |