Modify PCH script to use builtin cmake function if possible.

This commit is contained in:
tamasmeszaros 2020-05-14 10:10:47 +02:00
parent 2d3a218a07
commit 63c82ed8c6
3 changed files with 17 additions and 4 deletions

View File

@ -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") file(GENERATE OUTPUT "${_filename}" CONTENT "${_compile_definitions}${_include_directories}${_compile_flags}${_compile_options}${_cxx_flags}\n")
endfunction() 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) 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}) cmake_parse_arguments(_PCH "FORCEINCLUDE" "SOURCE_CXX;SOURCE_C" "" ${ARGN})
get_filename_component(_input_we ${_input} NAME_WE) get_filename_component(_input_we ${_input} NAME_WE)
@ -241,3 +248,11 @@ function(add_precompiled_header _target _input)
endforeach() endforeach()
endif(CMAKE_COMPILER_IS_GNUCXX) endif(CMAKE_COMPILER_IS_GNUCXX)
endfunction() endfunction()
else ()
function(add_precompiled_header _target _input)
target_precompile_headers(${_target} PRIVATE ${_input})
endfunction()
endif (CMAKE_VERSION VERSION_LESS 3.16)

View File

@ -308,6 +308,5 @@ if(SLIC3R_PROFILE)
endif() endif()
if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY) if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
#add_precompiled_header(libslic3r pchheader.hpp FORCEINCLUDE) add_precompiled_header(libslic3r pchheader.hpp FORCEINCLUDE)
target_precompile_headers(libslic3r PRIVATE pchheader.hpp)
endif () endif ()

View File

@ -231,6 +231,5 @@ if (SLIC3R_STATIC AND UNIX AND NOT APPLE)
endif () endif ()
if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY) if (SLIC3R_PCH AND NOT SLIC3R_SYNTAXONLY)
#add_precompiled_header(libslic3r_gui pchheader.hpp FORCEINCLUDE) add_precompiled_header(libslic3r_gui pchheader.hpp FORCEINCLUDE)
target_precompile_headers(libslic3r_gui PRIVATE pchheader.hpp)
endif () endif ()