mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
PCH: Fix Xcode non-pch language exclusion
Fix a regression caused by commit bbcdac4e5d (PCH: Fix all-language
precompile header support in Xcode, 2021-08-07, v3.22.0-rc1~140^2).
Fixes: #23138
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
@@ -29,4 +29,5 @@ if(RunCMake_GENERATOR MATCHES "Make|Ninja")
|
||||
endif()
|
||||
run_test(PchReuseFromObjLib)
|
||||
run_test(PchIncludedAllLanguages)
|
||||
run_test(PchIncludedOneLanguage)
|
||||
run_test(PchLibObjLibExe)
|
||||
|
||||
Reference in New Issue
Block a user