mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-28 18:09:42 -05:00
PCH: Report error when setting COMPILE_PDB_NAME property
Reusable precompile headers require specific COMPILE_PDB_NAME property values. Report error if the user tries to set a different value.
This commit is contained in:
@@ -355,6 +355,42 @@ bool cmGlobalGenerator::CheckTargetsForType() const
|
|||||||
return failed;
|
return failed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmGlobalGenerator::CheckTargetsForPchCompilePdb() const
|
||||||
|
{
|
||||||
|
if (!this->GetLanguageEnabled("C") && !this->GetLanguageEnabled("CXX")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool failed = false;
|
||||||
|
for (cmLocalGenerator* generator : this->LocalGenerators) {
|
||||||
|
for (cmGeneratorTarget* target : generator->GetGeneratorTargets()) {
|
||||||
|
if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
|
||||||
|
target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
|
||||||
|
target->GetType() == cmStateEnums::TargetType::UTILITY ||
|
||||||
|
cmIsOn(target->GetProperty("ghs_integrity_app"))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string reuseFrom =
|
||||||
|
target->GetSafeProperty("PRECOMPILE_HEADERS_REUSE_FROM");
|
||||||
|
const std::string compilePdb =
|
||||||
|
target->GetSafeProperty("COMPILE_PDB_NAME");
|
||||||
|
|
||||||
|
if (!reuseFrom.empty() && reuseFrom != compilePdb) {
|
||||||
|
const std::string e = cmStrCat(
|
||||||
|
"PRECOMPILE_HEADERS_REUSE_FROM property is set on target (\"",
|
||||||
|
target->GetName(),
|
||||||
|
"\"). Reusable precompile headers requires the COMPILE_PDB_NAME"
|
||||||
|
" property to have the value \"",
|
||||||
|
reuseFrom, "\"\n");
|
||||||
|
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e,
|
||||||
|
target->GetBacktrace());
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return failed;
|
||||||
|
}
|
||||||
|
|
||||||
bool cmGlobalGenerator::IsExportedTargetsFile(
|
bool cmGlobalGenerator::IsExportedTargetsFile(
|
||||||
const std::string& filename) const
|
const std::string& filename) const
|
||||||
{
|
{
|
||||||
@@ -1398,6 +1434,10 @@ bool cmGlobalGenerator::Compute()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->CheckTargetsForPchCompilePdb()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
for (cmLocalGenerator* localGen : this->LocalGenerators) {
|
for (cmLocalGenerator* localGen : this->LocalGenerators) {
|
||||||
localGen->ComputeHomeRelativeOutputPath();
|
localGen->ComputeHomeRelativeOutputPath();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -610,6 +610,7 @@ private:
|
|||||||
|
|
||||||
bool CheckTargetsForMissingSources() const;
|
bool CheckTargetsForMissingSources() const;
|
||||||
bool CheckTargetsForType() const;
|
bool CheckTargetsForType() const;
|
||||||
|
bool CheckTargetsForPchCompilePdb() const;
|
||||||
|
|
||||||
void CreateLocalGenerators();
|
void CreateLocalGenerators();
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ run_cmake(VsPackageReferences)
|
|||||||
run_cmake(VsDpiAware)
|
run_cmake(VsDpiAware)
|
||||||
run_cmake(VsDpiAwareBadParam)
|
run_cmake(VsDpiAwareBadParam)
|
||||||
run_cmake(VsPrecompileHeaders)
|
run_cmake(VsPrecompileHeaders)
|
||||||
|
run_cmake(VsPrecompileHeadersReuseFromCompilePDBName)
|
||||||
|
|
||||||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05)
|
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.05)
|
||||||
run_cmake(VsJustMyCode)
|
run_cmake(VsJustMyCode)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
1
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
CMake Error at VsPrecompileHeadersReuseFromCompilePDBName.cmake:6 \(add_library\):
|
||||||
|
PRECOMPILE_HEADERS_REUSE_FROM property is set on target \("b"\). Reusable
|
||||||
|
precompile headers requires the COMPILE_PDB_NAME property to have the value
|
||||||
|
"a"
|
||||||
|
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
CMakeLists.txt:3 \(include\)
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
project(VsPrecompileHeadersReuseFromCompilePDBName CXX)
|
||||||
|
|
||||||
|
add_library(a SHARED empty.cxx)
|
||||||
|
target_precompile_headers(a PRIVATE <windows.h>)
|
||||||
|
|
||||||
|
add_library(b SHARED empty.cxx)
|
||||||
|
target_precompile_headers(b REUSE_FROM a)
|
||||||
|
|
||||||
|
set_target_properties(b PROPERTIES COMPILE_PDB_NAME b)
|
||||||
Reference in New Issue
Block a user