Merge topic 'build-pch'
aba5bab62e
ci: Add nightly job to build CMake with PCH on macOS44f08e94ff
ci: Add nightly job to build CMake with PCH on Windowse0eb97e923
libuv: Precompile common expensive headerse2efa89c7f
cmcppdap: Precompile common expensive headers9d7921d388
liblzma: Precompile common expensive headers6aaefdb3be
libarchive: Precompile common expensive headersa8d91e2719
curl: Precompile common expensive headers59277bccd3
bzip: Precompile common expensive headers ... Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: buildbot <buildbot@kitware.com> Merge-request: !8571
This commit is contained in:
commit
994e88ec38
@ -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
|
||||
|
7
.gitlab/ci/configure_macos_arm64_pch.cmake
Normal file
7
.gitlab/ci/configure_macos_arm64_pch.cmake
Normal file
@ -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")
|
2
.gitlab/ci/configure_windows_vs2022_x64_pch.cmake
Normal file
2
.gitlab/ci/configure_windows_vs2022_x64_pch.cmake
Normal file
@ -0,0 +1,2 @@
|
||||
set(CMake_BUILD_PCH "ON" CACHE BOOL "")
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_common.cmake")
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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!")
|
||||
|
@ -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
|
||||
#
|
||||
|
@ -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";
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -5,6 +5,10 @@
|
||||
#include <cerrno>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <Windows.h>
|
||||
#endif
|
||||
|
||||
cmFileLockResult cmFileLockResult::MakeOk()
|
||||
{
|
||||
return { OK, 0 };
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
@ -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) };
|
||||
|
@ -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);
|
||||
};
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -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. */
|
||||
|
@ -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. */
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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*>
|
||||
|
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
12
Source/cm_codecvt_Encoding.hxx
Normal file
12
Source/cm_codecvt_Encoding.hxx
Normal file
@ -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,
|
||||
};
|
@ -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 "")
|
||||
|
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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})
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user