mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-20 04:24:36 +08:00
pchreuse: defer dependency addition until generation time
Note that this does lose the backtrace information. It also, however, makes `PRECOMPILE_HEADERS_REUSE_FROM` a non-magic property now. Previously, appending to the property would miss all of its behaviors (or leave existing setup in-place which is no longer relevant post-append). Rather than making a policy to block appending, just defer all logic to generation time.
This commit is contained in:
@@ -1008,6 +1008,10 @@ std::set<cmLinkItem> const& cmGeneratorTarget::GetUtilityItems() const
|
||||
cmLinkItem(i.Value.first, i.Value.second, i.Backtrace));
|
||||
}
|
||||
}
|
||||
if (cmGeneratorTarget const* reuseTarget = this->GetPchReuseTarget()) {
|
||||
this->UtilityItems.insert(
|
||||
cmLinkItem(reuseTarget, false, cmListFileBacktrace()));
|
||||
}
|
||||
}
|
||||
return this->UtilityItems;
|
||||
}
|
||||
|
@@ -1911,7 +1911,6 @@ MAKE_PROP(COMPILE_DEFINITIONS);
|
||||
MAKE_PROP(COMPILE_FEATURES);
|
||||
MAKE_PROP(COMPILE_OPTIONS);
|
||||
MAKE_PROP(PRECOMPILE_HEADERS);
|
||||
MAKE_PROP(PRECOMPILE_HEADERS_REUSE_FROM);
|
||||
MAKE_PROP(CUDA_CUBIN_COMPILATION);
|
||||
MAKE_PROP(CUDA_FATBIN_COMPILATION);
|
||||
MAKE_PROP(CUDA_OPTIX_COMPILATION);
|
||||
@@ -2147,11 +2146,6 @@ void cmTarget::SetProperty(std::string const& prop, cmValue value)
|
||||
this->impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
|
||||
return;
|
||||
}
|
||||
} else if (prop == propPRECOMPILE_HEADERS_REUSE_FROM) {
|
||||
this->impl->Properties.SetProperty(prop, value);
|
||||
if (value) {
|
||||
this->AddUtility(*value, false, this->impl->Makefile);
|
||||
}
|
||||
} else if (prop == propC_STANDARD || prop == propCXX_STANDARD ||
|
||||
prop == propCUDA_STANDARD || prop == propHIP_STANDARD ||
|
||||
prop == propOBJC_STANDARD || prop == propOBJCXX_STANDARD) {
|
||||
|
@@ -0,0 +1,2 @@
|
||||
((Classic Intel)?Warning #672: the command line options do not match those used[^
|
||||
]*)?
|
60
Tests/RunCMake/PrecompileHeaders/PchReuseAppend.cmake
Normal file
60
Tests/RunCMake/PrecompileHeaders/PchReuseAppend.cmake
Normal file
@@ -0,0 +1,60 @@
|
||||
enable_language(CXX)
|
||||
|
||||
if(CMAKE_CXX_COMPILE_OPTIONS_USE_PCH)
|
||||
add_definitions(-DHAVE_PCH_SUPPORT)
|
||||
endif()
|
||||
|
||||
######################################################################
|
||||
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/pch.cxx [=[
|
||||
void nothing()
|
||||
{
|
||||
}
|
||||
]=])
|
||||
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/string.hxx [=[
|
||||
#include <string.h>
|
||||
|
||||
namespace std {
|
||||
struct string
|
||||
{
|
||||
char storage[20];
|
||||
|
||||
string(const char* s) {
|
||||
strcpy(storage, s);
|
||||
}
|
||||
|
||||
const char* c_str() const {
|
||||
return storage;
|
||||
}
|
||||
};
|
||||
}
|
||||
]=])
|
||||
|
||||
add_library(pch-generator ${CMAKE_BINARY_DIR}/pch.cxx)
|
||||
target_precompile_headers(pch-generator PRIVATE ${CMAKE_BINARY_DIR}/string.hxx)
|
||||
|
||||
######################################################################
|
||||
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/message.cxx [=[
|
||||
#include "message.hxx"
|
||||
|
||||
#ifndef HAVE_PCH_SUPPORT
|
||||
#include "string.hxx"
|
||||
#endif
|
||||
|
||||
const char* message()
|
||||
{
|
||||
static std::string greeting("hi there");
|
||||
return greeting.c_str();
|
||||
}
|
||||
]=])
|
||||
|
||||
file(WRITE ${CMAKE_BINARY_DIR}/message.hxx [=[
|
||||
const char* message();
|
||||
]=])
|
||||
|
||||
add_library(reuse_append ${CMAKE_BINARY_DIR}/message.cxx)
|
||||
target_include_directories(reuse_append PRIVATE ${CMAKE_BINARY_DIR})
|
||||
set_property(TARGET reuse_append PROPERTY PRECOMPILE_HEADERS_REUSE_FROM "pch-")
|
||||
set_property(TARGET reuse_append APPEND_STRING PROPERTY PRECOMPILE_HEADERS_REUSE_FROM "generator")
|
@@ -34,6 +34,7 @@ run_build_verbose(PchReuseFromUseUpdatedProps)
|
||||
run_build_verbose(PchReuseConsistency)
|
||||
run_cmake(PchReuseFromCycle)
|
||||
run_cmake(PchReuseWithoutPch)
|
||||
run_build_verbose(PchReuseAppend)
|
||||
run_cmake(PchMultilanguage)
|
||||
run_build_verbose(PchReuseDeclarationOrder)
|
||||
if(RunCMake_GENERATOR MATCHES "Make|Ninja")
|
||||
|
Reference in New Issue
Block a user