aboutsummaryrefslogtreecommitdiff
path: root/cmake/macros/FindPCHSupport.cmake
diff options
context:
space:
mode:
authorPeter Keresztes Schmidt <carbenium@outlook.com>2020-06-16 13:38:37 +0200
committerGitHub <noreply@github.com>2020-06-16 13:38:37 +0200
commitcb5694607d8640b1ad54f7bdaf5f17482a97bc85 (patch)
tree734948b566397cb939273eda6cf5781e24399220 /cmake/macros/FindPCHSupport.cmake
parent3e7b0d6c05b27e012b8e407aaeef43b956565fe9 (diff)
CP of CMake: Prepare for target_precompile_headers (#24810) for 3.3.5 (#24816)
* CMake: Remove guards around CMP0043 and CMP0054 We require CMake >= 3.8 which includes the policies. CMP0043 OLD behaviour is still required by cotire. (cherry picked from commit 18ad76722663c6e8cd462645b995080c67b5bff2) * CMake: Use target_precompile_headers instead of cotire with CMake >= 3.16.0 (cherry picked from commit f387673aa328f3ff5941437149ba369d3c9a2806)
Diffstat (limited to 'cmake/macros/FindPCHSupport.cmake')
-rw-r--r--cmake/macros/FindPCHSupport.cmake52
1 files changed, 30 insertions, 22 deletions
diff --git a/cmake/macros/FindPCHSupport.cmake b/cmake/macros/FindPCHSupport.cmake
index eda21a71967..11388d6fed9 100644
--- a/cmake/macros/FindPCHSupport.cmake
+++ b/cmake/macros/FindPCHSupport.cmake
@@ -1,27 +1,35 @@
-if (MSVC)
- # Specify the maximum PreCompiled Header memory allocation limit
- # Fixes a compiler-problem when using PCH - the /Ym flag is adjusted by the compiler in MSVC2012,
- # hence we need to set an upper limit with /Zm to avoid discrepancies)
- # (And yes, this is a verified, unresolved bug with MSVC... *sigh*)
- #
- # Note: This workaround was verified to be required on MSVC 2017 as well
- set(COTIRE_PCH_MEMORY_SCALING_FACTOR 500)
-endif()
+if (CMAKE_VERSION VERSION_LESS "3.16.0")
+ if (MSVC)
+ # Specify the maximum PreCompiled Header memory allocation limit
+ # Fixes a compiler-problem when using PCH - the /Ym flag is adjusted by the compiler in MSVC2012,
+ # hence we need to set an upper limit with /Zm to avoid discrepancies)
+ # (And yes, this is a verified, unresolved bug with MSVC... *sigh*)
+ #
+ # Note: This workaround was verified to be required on MSVC 2017 as well
+ set(COTIRE_PCH_MEMORY_SCALING_FACTOR 500)
+ endif ()
-include(cotire)
+ include(cotire)
-function(ADD_CXX_PCH TARGET_NAME_LIST PCH_HEADER)
- # Use the header for every target
- foreach(TARGET_NAME ${TARGET_NAME_LIST})
- # Disable unity builds
- set_target_properties(${TARGET_NAME} PROPERTIES COTIRE_ADD_UNITY_BUILD OFF)
+ function(ADD_CXX_PCH TARGET_NAME_LIST PCH_HEADER)
+ # Use the header for every target
+ foreach (TARGET_NAME ${TARGET_NAME_LIST})
+ # Disable unity builds
+ set_target_properties(${TARGET_NAME} PROPERTIES COTIRE_ADD_UNITY_BUILD OFF)
- # Set the prefix header
- set_target_properties(${TARGET_NAME} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT ${PCH_HEADER})
+ # Set the prefix header
+ set_target_properties(${TARGET_NAME} PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT ${PCH_HEADER})
- # Workaround for cotire bug: https://github.com/sakra/cotire/issues/138
- set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 17)
- endforeach()
+ # Workaround for cotire bug: https://github.com/sakra/cotire/issues/138
+ set_property(TARGET ${TARGET_NAME} PROPERTY CXX_STANDARD 17)
+ endforeach ()
- cotire(${TARGET_NAME_LIST})
-endfunction(ADD_CXX_PCH)
+ cotire(${TARGET_NAME_LIST})
+ endfunction(ADD_CXX_PCH)
+else()
+ function(ADD_CXX_PCH TARGET_NAME_LIST PCH_HEADER)
+ foreach(TARGET_NAME ${TARGET_NAME_LIST})
+ target_precompile_headers(${TARGET_NAME} PRIVATE ${PCH_HEADER})
+ endforeach()
+ endfunction(ADD_CXX_PCH)
+endif() \ No newline at end of file