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/Compiler | |
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/Compiler')
-rw-r--r-- | Modules/Compiler/Clang.cmake | 2 | ||||
-rw-r--r-- | Modules/Compiler/GNU.cmake | 8 | ||||
-rw-r--r-- | Modules/Compiler/Intel.cmake | 7 |
3 files changed, 17 insertions, 0 deletions
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index c3f13f3..45c33fb 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -96,5 +96,7 @@ else() set(CMAKE_${lang}_ARCHIVE_FINISH_IPO "\"${__ranlib}\" <TARGET>" ) + + set(CMAKE_PCH_PROLOGUE "#pragma clang system_header") endmacro() endif() diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 6b1bd3a..e0ff174 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -11,6 +11,9 @@ set(__COMPILER_GNU 1) include(Compiler/CMakeCommonCompilerMacros) include(Internal/CMakeCheckCompilerFlag) +set(__pch_header_C "c-header") +set(__pch_header_CXX "c++-header") + macro(__compiler_gnu lang) # Feature flags. set(CMAKE_${lang}_VERBOSE_FLAG "-v") @@ -104,4 +107,9 @@ macro(__compiler_gnu lang) unset(_COMPILER_ARGS) endif() list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") + + set(CMAKE_PCH_EXTENSION .gch) + set(CMAKE_PCH_PROLOGUE "#pragma GCC system_header") + 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>) endmacro() diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake index f2f16e0..d895ed0 100644 --- a/Modules/Compiler/Intel.cmake +++ b/Modules/Compiler/Intel.cmake @@ -32,5 +32,12 @@ else() unset(_COMPILER_ARGS) endif() list(APPEND CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp") + + # Precompile Headers + set(CMAKE_PCH_EXTENSION .pchi) + set(CMAKE_LINK_PCH ON) + set(CMAKE_PCH_EPILOGUE "#pragma hdrstop") + set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Winvalid-pch -Wno-pch-messages -pch-use <PCH_FILE> -include <PCH_HEADER>) + set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Winvalid-pch -Wno-pch-messages -pch-create <PCH_FILE> -include <PCH_HEADER>) endmacro() endif() |