From 30c882827ec6f7b26fe07e5fba42f1a7400e9b36 Mon Sep 17 00:00:00 2001 From: Clemens Wasser Date: Sat, 17 Jun 2023 13:10:50 +0200 Subject: C{Make,Test}Lib: Precompile common expensive headers --- Source/CMakeLists.txt | 56 ++++++++++++++++++++++++++++++++++++++++++++ Source/cmGeneratorTarget.cxx | 4 ++-- Source/cmUuid.cxx | 10 ++++---- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index a79366e..708aec7 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -929,6 +929,44 @@ if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux") ) endif() +if(CMake_BUILD_PCH) + target_precompile_headers(CMakeLib PRIVATE + "$<$:>" + "$<$:>" + "$<$:>" + "$<$:>" + "$<$:>" + "$<$:>" + "$<$:cmMakefile.h>" + "$<$:cmGlobalGenerator.h>" + "$<$:cmLocalGenerator.h>" + "$<$:cmGeneratorTarget.h>" + "$<$:cmGeneratorExpression.h>" + "$<$:cmArgumentParser.h>" + "$<$:cmake.h>" + "$<$:cmCMakePath.h>" + "$<$:cmDebuggerPipeConnection.h>" + "$<$:cmCurl.h>") + + set_source_files_properties( + "LexerParser/cmFortranLexer.cxx" + PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + + if(WIN32) + target_precompile_headers(CMakeLib PRIVATE + "$<$:>" + "$<$:cmVSSetupHelper.h>") + set_source_files_properties("LexerParser/cmFortranParser.cxx" PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + else() + set_source_files_properties( + "LexerParser/cmCommandArgumentLexer.cxx" + "LexerParser/cmGccDepfileLexer.cxx" + "LexerParser/cmExprLexer.cxx" + "LexerParser/cmDependsJavaLexer.cxx" + PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + endif() +endif() + # Temporary variable for tools targets set(_tools) @@ -1041,6 +1079,24 @@ target_include_directories( ) target_link_libraries(CTestLib PUBLIC CMakeLib) +if(CMake_BUILD_PCH) + target_precompile_headers(CTestLib PRIVATE + "cmDuration.h" + "cmMakefile.h" + "cmSystemTools.h" + "cmGlobalGenerator.h" + "cmake.h" + "CTest/cmCTestGenericHandler.h" + "" + "") + + if(WIN32) + target_precompile_headers(CTestLib PRIVATE "cmCurl.h" "CTest/cmCTestMultiProcessHandler.h") + else() + set_source_files_properties("LexerParser/cmCTestResourceGroupsLexer.cxx" PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + endif() +endif() + # # Build CPackLib # diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 357d0a6..bce409b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1493,9 +1493,9 @@ std::string AddLangSpecificInterfaceIncludeDirectories( } std::string directories; - if (const auto* interface = target->GetLinkInterfaceLibraries( + if (const auto* link_interface = target->GetLinkInterfaceLibraries( config, root, LinkInterfaceFor::Usage)) { - for (const cmLinkItem& library : interface->Libraries) { + for (const cmLinkItem& library : link_interface->Libraries) { if (const cmGeneratorTarget* dependency = library.Target) { if (cm::contains(dependency->GetAllConfigCompileLanguages(), lang)) { auto* lg = dependency->GetLocalGenerator(); diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx index 6688668..5f5d3e4 100644 --- a/Source/cmUuid.cxx +++ b/Source/cmUuid.cxx @@ -104,20 +104,20 @@ std::string cmUuid::BinaryToString(const unsigned char* input) const size_t bytes = kUuidGroups[i]; for (size_t j = 0; j < bytes; ++j) { - unsigned char byte = input[inputIndex++]; - output += this->ByteToHex(byte); + unsigned char inputByte = input[inputIndex++]; + output += this->ByteToHex(inputByte); } } return output; } -std::string cmUuid::ByteToHex(unsigned char byte) const +std::string cmUuid::ByteToHex(unsigned char inputByte) const { std::string result(" "); for (int i = 0; i < 2; ++i) { - unsigned char rest = byte % 16; - byte /= 16; + unsigned char rest = inputByte % 16; + inputByte /= 16; char c = (rest < 0xA) ? static_cast('0' + rest) : static_cast('a' + (rest - 0xA)); result.at(1 - i) = c; -- cgit v0.12