diff options
author | tamasmeszaros <meszaros.q@gmail.com> | 2020-05-14 11:10:47 +0300 |
---|---|---|
committer | tamasmeszaros <meszaros.q@gmail.com> | 2020-05-14 11:50:39 +0300 |
commit | 63c82ed8c60e0bd3694c48df2fdba4e2b3ef711e (patch) | |
tree | 732f27c74976ec200daffde963768f2025a2518b /cmake | |
parent | 2d3a218a07567c8378c8fa73424429d4e92b77ea (diff) |
Modify PCH script to use builtin cmake function if possible.
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/modules/PrecompiledHeader.cmake | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/cmake/modules/PrecompiledHeader.cmake b/cmake/modules/PrecompiledHeader.cmake index 2f62a7dbe..e5f01af21 100644 --- a/cmake/modules/PrecompiledHeader.cmake +++ b/cmake/modules/PrecompiledHeader.cmake @@ -101,7 +101,14 @@ function(export_all_flags _filename) file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}${_cxx_flags}\n") endfunction() +# Use the new builtin CMake function if possible or fall back to the old one. +if (CMAKE_VERSION VERSION_LESS 3.16) + function(add_precompiled_header _target _input) + + message(STATUS "Adding precompiled header ${_input} to target ${_target} with legacy method. " + "Update your cmake instance to use the native PCH functions.") + cmake_parse_arguments(_PCH "FORCEINCLUDE" "SOURCE_CXX;SOURCE_C" "" ${ARGN}) get_filename_component(_input_we ${_input} NAME_WE) @@ -241,3 +248,11 @@ function(add_precompiled_header _target _input) endforeach() endif(CMAKE_COMPILER_IS_GNUCXX) endfunction() + +else () + +function(add_precompiled_header _target _input) + target_precompile_headers(${_target} PRIVATE ${_input}) +endfunction() + +endif (CMAKE_VERSION VERSION_LESS 3.16) |