summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-06-23 15:19:41 (GMT)
committerKitware Robot <kwrobot@kitware.com>2023-06-23 15:20:00 (GMT)
commit994e88ec387a521e498c4b0ae71fd3a663473a45 (patch)
tree94e30845cdad7bef91054ec5c66e2df82a2a6a04
parent09df135b606a019b63ecfbb59cf08b2aa1bd4f5c (diff)
parentaba5bab62ea2dbd218e88f2d430c975abb65949d (diff)
downloadCMake-994e88ec387a521e498c4b0ae71fd3a663473a45.zip
CMake-994e88ec387a521e498c4b0ae71fd3a663473a45.tar.gz
CMake-994e88ec387a521e498c4b0ae71fd3a663473a45.tar.bz2
Merge topic 'build-pch'
aba5bab62e ci: Add nightly job to build CMake with PCH on macOS 44f08e94ff ci: Add nightly job to build CMake with PCH on Windows e0eb97e923 libuv: Precompile common expensive headers e2efa89c7f cmcppdap: Precompile common expensive headers 9d7921d388 liblzma: Precompile common expensive headers 6aaefdb3be libarchive: Precompile common expensive headers a8d91e2719 curl: Precompile common expensive headers 59277bccd3 bzip: Precompile common expensive headers ... Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8571
-rw-r--r--.gitlab-ci.yml18
-rw-r--r--.gitlab/ci/configure_macos_arm64_pch.cmake7
-rw-r--r--.gitlab/ci/configure_windows_vs2022_x64_pch.cmake2
-rw-r--r--.gitlab/os-macos.yml6
-rw-r--r--.gitlab/os-windows.yml7
-rw-r--r--CMakeLists.txt6
-rw-r--r--Source/CMakeLists.txt56
-rw-r--r--Source/cmDebuggerVariablesHelper.cxx14
-rw-r--r--Source/cmFileLock.cxx12
-rw-r--r--Source/cmFileLock.h6
-rw-r--r--Source/cmFileLockResult.cxx4
-rw-r--r--Source/cmFileLockResult.h8
-rw-r--r--Source/cmFileLockWin32.cxx2
-rw-r--r--Source/cmGeneratedFileStream.cxx6
-rw-r--r--Source/cmGeneratedFileStream.h10
-rw-r--r--Source/cmGeneratorTarget.cxx4
-rw-r--r--Source/cmGlobalGenerator.cxx8
-rw-r--r--Source/cmGlobalGenerator.h7
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.h7
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx12
-rw-r--r--Source/cmGlobalNinjaGenerator.h6
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h6
-rw-r--r--Source/cmMakefileTargetGenerator.cxx8
-rw-r--r--Source/cmUuid.cxx10
-rw-r--r--Source/cm_codecvt.cxx12
-rw-r--r--Source/cm_codecvt.hxx13
-rw-r--r--Source/cm_codecvt_Encoding.hxx12
-rw-r--r--Tests/CMakeLib/CMakeLists.txt4
-rw-r--r--Utilities/cmbzip2/CMakeLists.txt4
-rw-r--r--Utilities/cmcppdap/CMakeLists.txt4
-rw-r--r--Utilities/cmcurl/lib/CMakeLists.txt4
-rw-r--r--Utilities/cmlibarchive/libarchive/CMakeLists.txt4
-rw-r--r--Utilities/cmliblzma/CMakeLists.txt4
-rw-r--r--Utilities/cmlibuv/CMakeLists.txt4
34 files changed, 208 insertions, 89 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 297afda..d8806c3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -826,6 +826,15 @@ b:macos-arm64-ninja:
variables:
CMAKE_CI_JOB_CONTINUOUS: "true"
+b:macos-arm64-pch:
+ extends:
+ - .macos_arm64_pch
+ - .cmake_build_macos
+ - .macos_arm64_tags
+ - .run_manually
+ variables:
+ CMAKE_CI_JOB_NIGHTLY: "true"
+
t:macos-x86_64-ninja:
extends:
- .macos_x86_64_ninja
@@ -998,6 +1007,15 @@ b:windows-vs2022-x64-ninja:
- .windows_x86_64_tags_nonconcurrent_vs2022
- .run_manually
+b:windows-vs2022-x64-pch:
+ extends:
+ - .windows_vs2022_x64_pch
+ - .cmake_build_windows
+ - .windows_x86_64_tags_nonconcurrent_vs2022
+ - .run_manually
+ variables:
+ CMAKE_CI_JOB_NIGHTLY: "true"
+
t:windows-vs2022-x64-ninja:
extends:
- .windows_vs2022_x64_ninja
diff --git a/.gitlab/ci/configure_macos_arm64_pch.cmake b/.gitlab/ci/configure_macos_arm64_pch.cmake
new file mode 100644
index 0000000..e2676ba
--- /dev/null
+++ b/.gitlab/ci/configure_macos_arm64_pch.cmake
@@ -0,0 +1,7 @@
+set(CMake_BUILD_PCH "ON" CACHE BOOL "")
+
+# sccache does not forward the PCH '-Xarch_arm64 "-include/..."' flag correctly.
+set(configure_no_sccache 1)
+
+include("${CMAKE_CURRENT_LIST_DIR}/configure_macos_common.cmake")
+include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")
diff --git a/.gitlab/ci/configure_windows_vs2022_x64_pch.cmake b/.gitlab/ci/configure_windows_vs2022_x64_pch.cmake
new file mode 100644
index 0000000..2a2eed7
--- /dev/null
+++ b/.gitlab/ci/configure_windows_vs2022_x64_pch.cmake
@@ -0,0 +1,2 @@
+set(CMake_BUILD_PCH "ON" CACHE BOOL "")
+include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_common.cmake")
diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml
index 09d7598..fbba288 100644
--- a/.gitlab/os-macos.yml
+++ b/.gitlab/os-macos.yml
@@ -38,6 +38,12 @@
CMAKE_CONFIGURATION: macos_arm64_ninja
CTEST_NO_WARNINGS_ALLOWED: 1
+.macos_arm64_pch:
+ extends: .macos_arm64_ninja
+
+ variables:
+ CMAKE_CONFIGURATION: macos_arm64_pch
+
.macos_x86_64_makefiles:
extends: .macos_build
diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml
index 026f2f4..422e147 100644
--- a/.gitlab/os-windows.yml
+++ b/.gitlab/os-windows.yml
@@ -55,6 +55,13 @@
VCVARSPLATFORM: "arm64"
VCVARSVERSION: "14.36.32532"
+.windows_vs2022_x64_pch:
+ extends:
+ - .windows_vs2022_x64_ninja
+
+ variables:
+ CMAKE_CONFIGURATION: windows_vs2022_x64_pch
+
.windows_vs2022_x64_ninja:
extends:
- .windows_build_ninja
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1d50ca..2823ca4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -131,6 +131,8 @@ if(CMake_BUILD_LTO)
endif()
endif()
+option(CMake_BUILD_PCH "Compile CMake with precompiled headers" OFF)
+
# Check whether to build support for the debugger mode.
if(NOT CMake_TEST_EXTERNAL_CMAKE)
if(NOT DEFINED CMake_ENABLE_DEBUGGER)
@@ -153,7 +155,6 @@ endif()
# simply to improve readability of the main script
#-----------------------------------------------------------------------
macro(CMAKE_HANDLE_SYSTEM_LIBRARIES)
- # Options have dependencies.
include(CMakeDependentOption)
# Allow the user to enable/disable all system utility library options by
@@ -324,6 +325,9 @@ configure_file(.clang-tidy .clang-tidy COPYONLY)
option(CMake_RUN_IWYU "Run include-what-you-use with the compiler." OFF)
if(CMake_RUN_IWYU)
+ if(CMake_BUILD_PCH)
+ message(FATAL_ERROR "CMake_RUN_IWYU and CMake_BUILD_PCH are ON, but they are incompatible!")
+ endif()
find_program(IWYU_COMMAND NAMES include-what-you-use iwyu)
if(NOT IWYU_COMMAND)
message(FATAL_ERROR "CMake_RUN_IWYU is ON but include-what-you-use is not found!")
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
+ "$<$<COMPILE_LANGUAGE:CXX>:<string$<ANGLE-R>>"
+ "$<$<COMPILE_LANGUAGE:CXX>:<iostream$<ANGLE-R>>"
+ "$<$<COMPILE_LANGUAGE:CXX>:<sstream$<ANGLE-R>>"
+ "$<$<COMPILE_LANGUAGE:CXX>:<iomanip$<ANGLE-R>>"
+ "$<$<COMPILE_LANGUAGE:CXX>:<cm/memory$<ANGLE-R>>"
+ "$<$<COMPILE_LANGUAGE:CXX>:<cm3p/cppdap/protocol.h$<ANGLE-R>>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmMakefile.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmGlobalGenerator.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmLocalGenerator.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmGeneratorTarget.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmGeneratorExpression.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmArgumentParser.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmake.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmCMakePath.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmDebuggerPipeConnection.h>"
+ "$<$<COMPILE_LANGUAGE:CXX>:cmCurl.h>")
+
+ set_source_files_properties(
+ "LexerParser/cmFortranLexer.cxx"
+ PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
+
+ if(WIN32)
+ target_precompile_headers(CMakeLib PRIVATE
+ "$<$<COMPILE_LANGUAGE:CXX>:<cm3p/uv.h$<ANGLE-R>>"
+ "$<$<COMPILE_LANGUAGE:CXX>: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"
+ "<sstream>"
+ "<cm3p/uv.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/cmDebuggerVariablesHelper.cxx b/Source/cmDebuggerVariablesHelper.cxx
index 1322b20..b2e85f2 100644
--- a/Source/cmDebuggerVariablesHelper.cxx
+++ b/Source/cmDebuggerVariablesHelper.cxx
@@ -10,7 +10,7 @@
#include <map>
#include <sstream>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmDebuggerStackFrame.h"
#include "cmDebuggerVariables.h"
@@ -578,17 +578,17 @@ std::shared_ptr<cmDebuggerVariables> cmDebuggerVariablesHelper::CreateIfAny(
return {};
}
- auto makeFileEncodingString = [](codecvt::Encoding encoding) {
+ auto makeFileEncodingString = [](codecvt_Encoding encoding) {
switch (encoding) {
- case codecvt::Encoding::None:
+ case codecvt_Encoding::None:
return "None";
- case codecvt::Encoding::UTF8:
+ case codecvt_Encoding::UTF8:
return "UTF8";
- case codecvt::Encoding::UTF8_WITH_BOM:
+ case codecvt_Encoding::UTF8_WITH_BOM:
return "UTF8_WITH_BOM";
- case codecvt::Encoding::ANSI:
+ case codecvt_Encoding::ANSI:
return "ANSI";
- case codecvt::Encoding::ConsoleOutput:
+ case codecvt_Encoding::ConsoleOutput:
return "ConsoleOutput";
default:
return "Unknown";
diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx
index 5d197d2..548e327 100644
--- a/Source/cmFileLock.cxx
+++ b/Source/cmFileLock.cxx
@@ -12,11 +12,7 @@
cmFileLock::cmFileLock(cmFileLock&& other) noexcept
{
this->File = other.File;
-#if defined(_WIN32)
- other.File = INVALID_HANDLE_VALUE;
-#else
- other.File = -1;
-#endif
+ other.File = (decltype(other.File))-1;
this->Filename = std::move(other.Filename);
}
@@ -32,11 +28,7 @@ cmFileLock::~cmFileLock()
cmFileLock& cmFileLock::operator=(cmFileLock&& other) noexcept
{
this->File = other.File;
-#if defined(_WIN32)
- other.File = INVALID_HANDLE_VALUE;
-#else
- other.File = -1;
-#endif
+ other.File = (decltype(other.File))-1;
this->Filename = std::move(other.Filename);
return *this;
diff --git a/Source/cmFileLock.h b/Source/cmFileLock.h
index 94baea1..0f2e7d9 100644
--- a/Source/cmFileLock.h
+++ b/Source/cmFileLock.h
@@ -7,7 +7,7 @@
#include <string>
#if defined(_WIN32)
-# include <windows.h> // HANDLE
+using HANDLE = void*;
#endif
class cmFileLockResult;
@@ -53,8 +53,8 @@ private:
cmFileLockResult LockWithTimeout(unsigned long timeoutSec);
#if defined(_WIN32)
- HANDLE File = INVALID_HANDLE_VALUE;
- BOOL LockFile(DWORD flags);
+ HANDLE File = (HANDLE)-1;
+ int LockFile(int flags);
#else
int File = -1;
int LockFile(int cmd, int type) const;
diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx
index b7f7f38..632c0e9 100644
--- a/Source/cmFileLockResult.cxx
+++ b/Source/cmFileLockResult.cxx
@@ -5,6 +5,10 @@
#include <cerrno>
#include <cstring>
+#ifdef _WIN32
+# include <Windows.h>
+#endif
+
cmFileLockResult cmFileLockResult::MakeOk()
{
return { OK, 0 };
diff --git a/Source/cmFileLockResult.h b/Source/cmFileLockResult.h
index 8a58d1f..e252de7 100644
--- a/Source/cmFileLockResult.h
+++ b/Source/cmFileLockResult.h
@@ -6,10 +6,6 @@
#include <string>
-#if defined(_WIN32)
-# include <windows.h> // DWORD
-#endif
-
/**
* @brief Result of the locking/unlocking file.
* @note See @c cmFileLock
@@ -17,11 +13,7 @@
class cmFileLockResult
{
public:
-#if defined(_WIN32)
- using Error = DWORD;
-#else
using Error = int;
-#endif
/**
* @brief Successful lock/unlock.
diff --git a/Source/cmFileLockWin32.cxx b/Source/cmFileLockWin32.cxx
index 7bee5f2..244ade2 100644
--- a/Source/cmFileLockWin32.cxx
+++ b/Source/cmFileLockWin32.cxx
@@ -78,7 +78,7 @@ cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
}
}
-BOOL cmFileLock::LockFile(DWORD flags)
+int cmFileLock::LockFile(int flags)
{
const DWORD reserved = 0;
const unsigned long len = static_cast<unsigned long>(-1);
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 133bf5f..e669f68 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -16,7 +16,7 @@
cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding)
{
#ifndef CMAKE_BOOTSTRAP
- if (encoding != codecvt::None) {
+ if (encoding != codecvt_Encoding::None) {
this->imbue(std::locale(this->getloc(), new codecvt(encoding)));
}
#else
@@ -35,13 +35,13 @@ cmGeneratedFileStream::cmGeneratedFileStream(std::string const& name,
cmSystemTools::ReportLastSystemError("");
}
#ifndef CMAKE_BOOTSTRAP
- if (encoding != codecvt::None) {
+ if (encoding != codecvt_Encoding::None) {
this->imbue(std::locale(this->getloc(), new codecvt(encoding)));
}
#else
static_cast<void>(encoding);
#endif
- if (encoding == codecvt::UTF8_WITH_BOM) {
+ if (encoding == codecvt_Encoding::UTF8_WITH_BOM) {
// Write the BOM encoding header into the file
char magic[] = { static_cast<char>(0xEF), static_cast<char>(0xBB),
static_cast<char>(0xBF) };
diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h
index bfc121f..a26616d 100644
--- a/Source/cmGeneratedFileStream.h
+++ b/Source/cmGeneratedFileStream.h
@@ -8,7 +8,7 @@
#include "cmsys/FStream.hxx"
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
// This is the first base class of cmGeneratedFileStream. It will be
// created before and destroyed after the ofstream portion and can
@@ -77,13 +77,13 @@ class cmGeneratedFileStream
{
public:
using Stream = cmsys::ofstream;
- using Encoding = codecvt::Encoding;
+ using Encoding = codecvt_Encoding;
/**
* This constructor prepares a default stream. The open method must
* be used before writing to the stream.
*/
- cmGeneratedFileStream(Encoding encoding = codecvt::None);
+ cmGeneratedFileStream(codecvt_Encoding encoding = codecvt_Encoding::None);
/**
* This constructor takes the name of the file to be generated. It
@@ -92,7 +92,7 @@ public:
* second argument is set to true.
*/
cmGeneratedFileStream(std::string const& name, bool quiet = false,
- Encoding encoding = codecvt::None);
+ codecvt_Encoding encoding = codecvt_Encoding::None);
/**
* The destructor checks the stream status to be sure the temporary
@@ -151,5 +151,5 @@ public:
* Write a specific string using an alternate encoding.
* Afterward, the original encoding is restored.
*/
- void WriteAltEncoding(std::string const& data, Encoding encoding);
+ void WriteAltEncoding(std::string const& data, codecvt_Encoding encoding);
};
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 1148386..50bbfb1 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1492,9 +1492,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/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 5175aae..3d7d5a7 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -24,10 +24,6 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
-#if defined(_WIN32) && !defined(__CYGWIN__)
-# include <windows.h>
-#endif
-
#include "cmAlgorithms.h"
#include "cmCPackPropertiesGenerator.h"
#include "cmComputeTargetDepends.h"
@@ -142,6 +138,10 @@ cmGlobalGenerator::~cmGlobalGenerator()
{
this->ClearGeneratorMembers();
}
+codecvt_Encoding cmGlobalGenerator::GetMakefileEncoding() const
+{
+ return codecvt_Encoding::None;
+}
#if !defined(CMAKE_BOOTSTRAP)
Json::Value cmGlobalGenerator::GetJson() const
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 9aefaff..bc59514 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -19,7 +19,7 @@
#include <cmext/algorithm>
#include <cmext/string_view>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmBuildOptions.h"
#include "cmCustomCommandLines.h"
@@ -120,10 +120,7 @@ public:
}
/** Get encoding used by generator for makefile files */
- virtual codecvt::Encoding GetMakefileEncoding() const
- {
- return codecvt::None;
- }
+ virtual codecvt_Encoding GetMakefileEncoding() const;
#if !defined(CMAKE_BOOTSTRAP)
/** Get a JSON object describing the generator. */
diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h
index 436ebca..bc8fc34 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.h
+++ b/Source/cmGlobalNMakeMakefileGenerator.h
@@ -7,7 +7,7 @@
#include <string>
#include <vector>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmGlobalGeneratorFactory.h"
#include "cmGlobalUnixMakefileGenerator3.h"
@@ -38,9 +38,10 @@ public:
static std::string GetActualName() { return "NMake Makefiles"; }
/** Get encoding used by generator for makefile files */
- codecvt::Encoding GetMakefileEncoding() const override
+ codecvt_Encoding GetMakefileEncoding() const override
{
- return this->NMakeSupportsUTF8 ? codecvt::UTF8_WITH_BOM : codecvt::ANSI;
+ return this->NMakeSupportsUTF8 ? codecvt_Encoding::UTF8_WITH_BOM
+ : codecvt_Encoding::ANSI;
}
/** Get the documentation entry for this generator. */
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index e20f157..65851f3 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -566,7 +566,7 @@ std::unique_ptr<cmLocalGenerator> cmGlobalNinjaGenerator::CreateLocalGenerator(
cm::make_unique<cmLocalNinjaGenerator>(this, mf));
}
-codecvt::Encoding cmGlobalNinjaGenerator::GetMakefileEncoding() const
+codecvt_Encoding cmGlobalNinjaGenerator::GetMakefileEncoding() const
{
return this->NinjaExpectedEncoding;
}
@@ -799,7 +799,7 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures()
if (this->NinjaSupportsCodePage) {
this->CheckNinjaCodePage();
} else {
- this->NinjaExpectedEncoding = codecvt::ANSI;
+ this->NinjaExpectedEncoding = codecvt_Encoding::ANSI;
}
#endif
}
@@ -830,9 +830,9 @@ void cmGlobalNinjaGenerator::CheckNinjaCodePage()
lineView.substr(cmStrLen("Build file encoding: "));
if (encoding == "UTF-8") {
// Ninja expects UTF-8. We use that internally. No conversion needed.
- this->NinjaExpectedEncoding = codecvt::None;
+ this->NinjaExpectedEncoding = codecvt_Encoding::None;
} else {
- this->NinjaExpectedEncoding = codecvt::ANSI;
+ this->NinjaExpectedEncoding = codecvt_Encoding::ANSI;
}
found = true;
break;
@@ -842,10 +842,10 @@ void cmGlobalNinjaGenerator::CheckNinjaCodePage()
this->GetCMakeInstance()->IssueMessage(
MessageType::WARNING,
"Could not determine Ninja's code page, defaulting to UTF-8");
- this->NinjaExpectedEncoding = codecvt::None;
+ this->NinjaExpectedEncoding = codecvt_Encoding::None;
}
} else {
- this->NinjaExpectedEncoding = codecvt::ANSI;
+ this->NinjaExpectedEncoding = codecvt_Encoding::ANSI;
}
}
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index bfbe57f..95d64e3 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -16,7 +16,7 @@
#include <cm/optional>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmBuildOptions.h"
#include "cmGeneratedFileStream.h"
@@ -192,7 +192,7 @@ public:
bool IsNinja() const override { return true; }
/** Get encoding used by generator for ninja files */
- codecvt::Encoding GetMakefileEncoding() const override;
+ codecvt_Encoding GetMakefileEncoding() const override;
static cmDocumentationEntry GetDocumentation();
@@ -590,7 +590,7 @@ private:
bool NinjaSupportsMetadataOnRegeneration = false;
bool NinjaSupportsCodePage = false;
- codecvt::Encoding NinjaExpectedEncoding = codecvt::None;
+ codecvt_Encoding NinjaExpectedEncoding = codecvt_Encoding::None;
bool DiagnosedCxxModuleNinjaSupport = false;
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 48c840b..76713fa 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -10,7 +10,7 @@
#include <string>
#include <vector>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmGlobalGenerator.h"
#include "cmTargetDepend.h"
@@ -119,9 +119,9 @@ public:
/** Get encoding used by generator for generated source files
*/
- codecvt::Encoding GetMakefileEncoding() const override
+ codecvt_Encoding GetMakefileEncoding() const override
{
- return codecvt::ANSI;
+ return codecvt_Encoding::ANSI;
}
class TargetSet : public std::set<cmGeneratorTarget const*>
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 5f27856..1dd48b3 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -17,7 +17,7 @@
#include <cmext/algorithm>
#include <cmext/string_view>
-#include "cm_codecvt.hxx"
+#include "cm_codecvt_Encoding.hxx"
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h"
@@ -2129,12 +2129,12 @@ std::string cmMakefileTargetGenerator::CreateResponseFile(
// FIXME: Find a better way to determine the response file encoding,
// perhaps using tool-specific platform information variables.
// For now, use the makefile encoding as a heuristic.
- codecvt::Encoding responseEncoding =
+ codecvt_Encoding responseEncoding =
this->GlobalGenerator->GetMakefileEncoding();
// Non-MSVC tooling doesn't understand BOM encoded files.
- if (responseEncoding == codecvt::UTF8_WITH_BOM &&
+ if (responseEncoding == codecvt_Encoding::UTF8_WITH_BOM &&
(language == "CUDA" || !this->Makefile->IsOn("MSVC"))) {
- responseEncoding = codecvt::UTF8;
+ responseEncoding = codecvt_Encoding::UTF8;
}
// Create the response file.
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<char>('0' + rest)
: static_cast<char>('a' + (rest - 0xA));
result.at(1 - i) = c;
diff --git a/Source/cm_codecvt.cxx b/Source/cm_codecvt.cxx
index 12877b8..7b3349b 100644
--- a/Source/cm_codecvt.cxx
+++ b/Source/cm_codecvt.cxx
@@ -13,19 +13,19 @@
# include "cm_utf8.h"
#endif
-codecvt::codecvt(Encoding e)
+codecvt::codecvt(codecvt_Encoding e)
#if defined(_WIN32)
: m_codepage(0)
#endif
{
switch (e) {
- case codecvt::ConsoleOutput:
+ case codecvt_Encoding::ConsoleOutput:
#if defined(_WIN32)
m_noconv = false;
m_codepage = GetConsoleOutputCP();
break;
#endif
- case codecvt::ANSI:
+ case codecvt_Encoding::ANSI:
#if defined(_WIN32)
m_noconv = false;
m_codepage = CP_ACP;
@@ -33,10 +33,10 @@ codecvt::codecvt(Encoding e)
#endif
// We don't know which ANSI encoding to use for other platforms than
// Windows so we don't do any conversion there
- case codecvt::UTF8:
- case codecvt::UTF8_WITH_BOM:
+ case codecvt_Encoding::UTF8:
+ case codecvt_Encoding::UTF8_WITH_BOM:
// Assume internal encoding is UTF-8
- case codecvt::None:
+ case codecvt_Encoding::None:
// No encoding
default:
this->m_noconv = true;
diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx
index f628de7..eb98e98 100644
--- a/Source/cm_codecvt.hxx
+++ b/Source/cm_codecvt.hxx
@@ -7,21 +7,14 @@
#include <cwchar>
#include <locale>
+#include "cm_codecvt_Encoding.hxx"
+
class codecvt : public std::codecvt<char, char, mbstate_t>
{
public:
- enum Encoding
- {
- None,
- UTF8,
- UTF8_WITH_BOM,
- ANSI,
- ConsoleOutput,
- };
-
#ifndef CMAKE_BOOTSTRAP
- codecvt(Encoding e);
+ codecvt(codecvt_Encoding e);
protected:
~codecvt() override;
diff --git a/Source/cm_codecvt_Encoding.hxx b/Source/cm_codecvt_Encoding.hxx
new file mode 100644
index 0000000..b91ad8f
--- /dev/null
+++ b/Source/cm_codecvt_Encoding.hxx
@@ -0,0 +1,12 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+
+enum class codecvt_Encoding
+{
+ None,
+ UTF8,
+ UTF8_WITH_BOM,
+ ANSI,
+ ConsoleOutput,
+};
diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt
index b22d76d..fc3c23b 100644
--- a/Tests/CMakeLib/CMakeLists.txt
+++ b/Tests/CMakeLib/CMakeLists.txt
@@ -68,6 +68,10 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testUVProcessChainInput.txt" "HELLO WORL
create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS})
add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS})
target_link_libraries(CMakeLibTests CMakeLib CTestLib)
+if(CMake_BUILD_PCH)
+ target_precompile_headers(CMakeLibTests PRIVATE "<iostream>" "<cm3p/uv.h>")
+ target_compile_definitions(CMakeLibTests PRIVATE "NOMINMAX")
+endif()
set_property(TARGET CMakeLibTests PROPERTY C_CLANG_TIDY "")
set_property(TARGET CMakeLibTests PROPERTY CXX_CLANG_TIDY "")
diff --git a/Utilities/cmbzip2/CMakeLists.txt b/Utilities/cmbzip2/CMakeLists.txt
index 1d7b265..b52358e 100644
--- a/Utilities/cmbzip2/CMakeLists.txt
+++ b/Utilities/cmbzip2/CMakeLists.txt
@@ -19,3 +19,7 @@ endif()
add_definitions(-D_FILE_OFFSET_BITS=64)
add_library(cmbzip2
blocksort.c huffman.c crctable.c randtable.c compress.c decompress.c bzlib.c)
+
+if(WIN32 AND CMake_BUILD_PCH)
+ target_precompile_headers(cmbzip2 PRIVATE "bzlib.h")
+endif()
diff --git a/Utilities/cmcppdap/CMakeLists.txt b/Utilities/cmcppdap/CMakeLists.txt
index 39f72a2..2aca681 100644
--- a/Utilities/cmcppdap/CMakeLists.txt
+++ b/Utilities/cmcppdap/CMakeLists.txt
@@ -34,4 +34,8 @@ elseif(NOT APPLE)
target_link_libraries(cmcppdap PRIVATE Threads::Threads)
endif()
+if(CMake_BUILD_PCH)
+ target_precompile_headers(cmcppdap PRIVATE "include/dap/protocol.h")
+endif()
+
install(FILES NOTICE DESTINATION ${CMAKE_DOC_DIR}/cmcppdap)
diff --git a/Utilities/cmcurl/lib/CMakeLists.txt b/Utilities/cmcurl/lib/CMakeLists.txt
index f1d0f76..ba75420 100644
--- a/Utilities/cmcurl/lib/CMakeLists.txt
+++ b/Utilities/cmcurl/lib/CMakeLists.txt
@@ -110,6 +110,10 @@ set_target_properties(${LIB_NAME} PROPERTIES
OUTPUT_NAME ${LIBCURL_OUTPUT_NAME}
)
+if(WIN32 AND CMake_BUILD_PCH)
+ target_precompile_headers(${LIB_NAME} PRIVATE "curl_setup.h" "curl_sspi.h" "${CURL_SOURCE_DIR}/include/curl/curl.h")
+endif()
+
if(0) # This code not needed for building within CMake.
if(CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
diff --git a/Utilities/cmlibarchive/libarchive/CMakeLists.txt b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
index bee69c2..e820853 100644
--- a/Utilities/cmlibarchive/libarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
@@ -246,6 +246,10 @@ ENDIF()
ADD_LIBRARY(cmlibarchive STATIC ${libarchive_SOURCES} ${include_HEADERS})
TARGET_LINK_LIBRARIES(cmlibarchive ${ADDITIONAL_LIBS})
+if(WIN32 AND CMake_BUILD_PCH)
+ target_precompile_headers(cmlibarchive PRIVATE "archive_platform.h" "archive_entry.h" "<cm3p/bzlib.h>")
+endif()
+
IF(0) # CMake does not build libarchive's full package.
# Libarchive is a shared library
ADD_LIBRARY(archive SHARED ${libarchive_SOURCES} ${include_HEADERS})
diff --git a/Utilities/cmliblzma/CMakeLists.txt b/Utilities/cmliblzma/CMakeLists.txt
index 3121fbe..3ba3ce9 100644
--- a/Utilities/cmliblzma/CMakeLists.txt
+++ b/Utilities/cmliblzma/CMakeLists.txt
@@ -186,4 +186,8 @@ ELSEIF((CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "LCC"
SET_PROPERTY(TARGET cmliblzma PROPERTY COMPILE_FLAGS "-O0")
ENDIF()
+if(WIN32 AND CMake_BUILD_PCH)
+ target_precompile_headers(cmliblzma PRIVATE "common/mythread.h")
+endif()
+
INSTALL(FILES COPYING DESTINATION ${CMAKE_DOC_DIR}/cmliblzma)
diff --git a/Utilities/cmlibuv/CMakeLists.txt b/Utilities/cmlibuv/CMakeLists.txt
index ad3d433..9df0c7f 100644
--- a/Utilities/cmlibuv/CMakeLists.txt
+++ b/Utilities/cmlibuv/CMakeLists.txt
@@ -365,4 +365,8 @@ add_library(cmlibuv STATIC ${uv_sources})
target_link_libraries(cmlibuv ${uv_libraries})
set_property(TARGET cmlibuv PROPERTY COMPILE_DEFINITIONS ${uv_defines})
+if(WIN32 AND CMake_BUILD_PCH)
+ target_precompile_headers(cmlibuv PRIVATE "include/uv.h" "src/win/internal.h")
+endif()
+
install(FILES LICENSE DESTINATION ${CMAKE_DOC_DIR}/cmlibuv)