diff options
author | Cristian Adam <cristian.adam@gmail.com> | 2019-07-13 10:07:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-08-28 15:47:40 (GMT) |
commit | b8626261e95e0f99c9227d619671822f9a60ef1a (patch) | |
tree | bb3b915854ac4ff9b01515642521b2940b02ec38 /Modules/Platform | |
parent | 375d01c6808713a0cfeef9ea092c8236ba063525 (diff) | |
download | CMake-b8626261e95e0f99c9227d619671822f9a60ef1a.zip CMake-b8626261e95e0f99c9227d619671822f9a60ef1a.tar.gz CMake-b8626261e95e0f99c9227d619671822f9a60ef1a.tar.bz2 |
Precompile headers: Add methods to generate PCH sources
Co-Author: Daniel Pfeifer <daniel@pfeifer-mail.de>
Diffstat (limited to 'Modules/Platform')
-rw-r--r-- | Modules/Platform/Windows-Clang.cmake | 7 | ||||
-rw-r--r-- | Modules/Platform/Windows-Embarcadero.cmake | 7 | ||||
-rw-r--r-- | Modules/Platform/Windows-MSVC.cmake | 9 |
3 files changed, 23 insertions, 0 deletions
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index 728e0b9..220649c 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -8,6 +8,9 @@ if(__WINDOWS_CLANG) endif() set(__WINDOWS_CLANG 1) +set(__pch_header_C "c-header") +set(__pch_header_CXX "c++-header") + macro(__windows_compiler_clang_gnu lang) set(CMAKE_LIBRARY_PATH_FLAG "-L") set(CMAKE_LINK_LIBRARY_FLAG "-l") @@ -73,6 +76,10 @@ macro(__windows_compiler_clang_gnu lang) string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}") set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ") + set(CMAKE_PCH_EXTENSION .gch) + set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Winvalid-pch -include <PCH_HEADER>) + set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Winvalid-pch -x ${__pch_header_${lang}} -include <PCH_HEADER>) + unset(__ADDED_FLAGS) unset(__ADDED_FLAGS_DEBUG) string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER) diff --git a/Modules/Platform/Windows-Embarcadero.cmake b/Modules/Platform/Windows-Embarcadero.cmake index 48b936e..370b56e 100644 --- a/Modules/Platform/Windows-Embarcadero.cmake +++ b/Modules/Platform/Windows-Embarcadero.cmake @@ -119,6 +119,13 @@ macro(__embarcadero_language lang) "tlib ${CMAKE_START_TEMP_FILE}/p512 <LINK_FLAGS> /a <TARGET_QUOTED> <OBJECTS>${CMAKE_END_TEMP_FILE}" ) + # Precompile Headers + if (EMBARCADERO) + set(CMAKE_PCH_EXTENSION .pch) + set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE>) + set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER>) + endif() + # Initial configuration flags. string(APPEND CMAKE_${lang}_FLAGS_INIT " ${_tM}") string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -Od -v") diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake index 7a83859..6ddcaa3 100644 --- a/Modules/Platform/Windows-MSVC.cmake +++ b/Modules/Platform/Windows-MSVC.cmake @@ -329,6 +329,15 @@ macro(__windows_compiler_msvc lang) set(CMAKE_${lang}_LINK_EXECUTABLE "${_CMAKE_VS_LINK_EXE}<CMAKE_LINKER> ${CMAKE_CL_NOLOGO} <OBJECTS> ${CMAKE_START_TEMP_FILE} /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES>${CMAKE_END_TEMP_FILE}") + set(CMAKE_PCH_EXTENSION .pch) + set(CMAKE_LINK_PCH ON) + if(MSVC_VERSION GREATER_EQUAL 1910) + # VS 2017 or greater + set(CMAKE_PCH_PROLOGUE "#pragma system_header") + endif() + set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH /Yu<PCH_HEADER> /FI<PCH_HEADER>) + set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH /Yc<PCH_HEADER> /FI<PCH_HEADER>) + if("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC") set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES) set(_CMAKE_${lang}_IPO_MAY_BE_SUPPORTED_BY_COMPILER YES) |