Commit 90285836 authored by Brad King's avatar Brad King

Merge branch 'backport-3.16-pch-fix-bad-ClearSourcesCache'

parents e6479495 fa7b041e
......@@ -3555,8 +3555,6 @@ std::string cmGeneratorTarget::GetPchFileObject(const std::string& config,
}
std::string& filename = inserted.first->second;
this->AddSource(pchSource, true);
auto pchSf = this->Makefile->GetOrCreateSource(
pchSource, false, cmSourceFileLocationKind::Known);
......
......@@ -1609,7 +1609,23 @@ bool cmGlobalGenerator::AddAutomaticSources()
continue;
}
lg->AddUnityBuild(gt.get());
lg->AddPchDependencies(gt.get());
// Targets that re-use a PCH are handled below.
if (!gt->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
lg->AddPchDependencies(gt.get());
}
}
}
for (const auto& lg : this->LocalGenerators) {
for (const auto& gt : lg->GetGeneratorTargets()) {
if (gt->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
gt->GetType() == cmStateEnums::UTILITY ||
gt->GetType() == cmStateEnums::GLOBAL_TARGET) {
continue;
}
// Handle targets that re-use a PCH from an above-handled target.
if (gt->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
lg->AddPchDependencies(gt.get());
}
}
}
// The above transformations may have changed the classification of sources.
......
......@@ -5,6 +5,11 @@ if(CMAKE_C_COMPILE_OPTIONS_USE_PCH)
add_definitions(-DHAVE_PCH_SUPPORT)
endif()
# Add this before the target from which we will reuse the PCH
# to test that generators can handle reversed ordering.
add_library(foo foo.c)
target_include_directories(foo PUBLIC include)
add_library(empty empty.c)
target_precompile_headers(empty PRIVATE
<stdio.h>
......@@ -12,8 +17,6 @@ target_precompile_headers(empty PRIVATE
)
target_include_directories(empty PUBLIC include)
add_library(foo foo.c)
target_include_directories(foo PUBLIC include)
target_precompile_headers(foo REUSE_FROM empty)
# should not cause problems if configured multiple times
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment