Changed: #880 Use PCH under Linux with CMake
This commit is contained in:
parent
7a99daae23
commit
fcb53cf7be
1 changed files with 107 additions and 114 deletions
|
@ -1,4 +1,4 @@
|
||||||
# - Try to find precompiled headers support for GCC 3.4 and 4.x
|
# - Try to find precompiled headers support for GCC 3.4 and 4.x (and MSVC)
|
||||||
# Once done this will define:
|
# Once done this will define:
|
||||||
#
|
#
|
||||||
# Variable:
|
# Variable:
|
||||||
|
@ -28,23 +28,22 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
SET(_PCH_include_prefix "-I")
|
SET(_PCH_include_prefix "-I")
|
||||||
|
|
||||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
IF(WIN32)
|
IF(WIN32)
|
||||||
SET(PCHSupport_FOUND TRUE) # for experimental msvc support
|
SET(PCHSupport_FOUND TRUE) # for experimental msvc support
|
||||||
SET(_PCH_include_prefix "/I")
|
SET(_PCH_include_prefix "/I")
|
||||||
ELSE(WIN32)
|
ELSE(WIN32)
|
||||||
SET(PCHSupport_FOUND FALSE)
|
SET(PCHSupport_FOUND FALSE)
|
||||||
ENDIF(WIN32)
|
ENDIF(WIN32)
|
||||||
|
|
||||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
|
|
||||||
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
||||||
|
|
||||||
|
|
||||||
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
|
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
|
||||||
SET(${_out_compile_flags} ${${_flags_var_name}} )
|
SET(${_out_compile_flags} ${${_flags_var_name}} )
|
||||||
|
|
||||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
|
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
|
||||||
IF(${_targetType} STREQUAL SHARED_LIBRARY)
|
IF(${_targetType} STREQUAL SHARED_LIBRARY)
|
||||||
LIST(APPEND ${_out_compile_flags} "${${_out_compile_flags}} -fPIC")
|
LIST(APPEND ${_out_compile_flags} "${${_out_compile_flags}} -fPIC")
|
||||||
|
@ -68,7 +67,6 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
||||||
|
|
||||||
ENDMACRO(_PCH_GET_COMPILE_FLAGS)
|
ENDMACRO(_PCH_GET_COMPILE_FLAGS)
|
||||||
|
|
||||||
|
|
||||||
MACRO(_PCH_WRITE_PCHDEP_CXX _targetName _include_file _dephelp)
|
MACRO(_PCH_WRITE_PCHDEP_CXX _targetName _include_file _dephelp)
|
||||||
|
|
||||||
SET(${_dephelp} ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch_dephelp.cxx)
|
SET(${_dephelp} ${CMAKE_CURRENT_BINARY_DIR}/${_targetName}_pch_dephelp.cxx)
|
||||||
|
@ -145,7 +143,7 @@ ENDMACRO(_PCH_GET_TARGET_COMPILE_FLAGS )
|
||||||
MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
|
MACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input _output)
|
||||||
GET_FILENAME_COMPONENT(_name ${_input} NAME)
|
GET_FILENAME_COMPONENT(_name ${_input} NAME)
|
||||||
GET_FILENAME_COMPONENT(_path ${_input} PATH)
|
GET_FILENAME_COMPONENT(_path ${_input} PATH)
|
||||||
SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch/${_targetName}_${CMAKE_BUILD_TYPE}.h++")
|
SET(_output "${CMAKE_CURRENT_BINARY_DIR}/${_name}.gch/${_targetName}_${CMAKE_BUILD_TYPE}.gch")
|
||||||
ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
|
ENDMACRO(GET_PRECOMPILED_HEADER_OUTPUT _targetName _input)
|
||||||
|
|
||||||
|
|
||||||
|
@ -194,7 +192,6 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
|
||||||
SET(_dowarn 1)
|
SET(_dowarn 1)
|
||||||
ENDIF("${ARGN}" STREQUAL "0")
|
ENDIF("${ARGN}" STREQUAL "0")
|
||||||
|
|
||||||
|
|
||||||
GET_FILENAME_COMPONENT(_name ${_input} NAME)
|
GET_FILENAME_COMPONENT(_name ${_input} NAME)
|
||||||
GET_FILENAME_COMPONENT(_path ${_input} PATH)
|
GET_FILENAME_COMPONENT(_path ${_input} PATH)
|
||||||
GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_input} _output)
|
GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_input} _output)
|
||||||
|
@ -212,7 +209,6 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
|
||||||
|
|
||||||
FILE(MAKE_DIRECTORY ${_outdir})
|
FILE(MAKE_DIRECTORY ${_outdir})
|
||||||
|
|
||||||
|
|
||||||
_PCH_GET_COMPILE_FLAGS(_compile_FLAGS)
|
_PCH_GET_COMPILE_FLAGS(_compile_FLAGS)
|
||||||
|
|
||||||
#MESSAGE("_compile_FLAGS: ${_compile_FLAGS}")
|
#MESSAGE("_compile_FLAGS: ${_compile_FLAGS}")
|
||||||
|
@ -236,11 +232,9 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
|
||||||
DEPENDS ${_input} ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_targetName}_pch_dephelp
|
DEPENDS ${_input} ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_targetName}_pch_dephelp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_input} ${_output} ${_dowarn})
|
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_input} ${_output} ${_dowarn})
|
||||||
ENDMACRO(ADD_PRECOMPILED_HEADER)
|
ENDMACRO(ADD_PRECOMPILED_HEADER)
|
||||||
|
|
||||||
|
|
||||||
# Generates the use of precompiled in a target,
|
# Generates the use of precompiled in a target,
|
||||||
# without using depency targets (2 extra for each target)
|
# without using depency targets (2 extra for each target)
|
||||||
# Using Visual, must also add ${_targetName}_pch to sources
|
# Using Visual, must also add ${_targetName}_pch to sources
|
||||||
|
@ -266,7 +260,6 @@ MACRO(GET_NATIVE_PRECOMPILED_HEADER _targetName _input)
|
||||||
|
|
||||||
ENDMACRO(GET_NATIVE_PRECOMPILED_HEADER)
|
ENDMACRO(GET_NATIVE_PRECOMPILED_HEADER)
|
||||||
|
|
||||||
|
|
||||||
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
|
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
|
||||||
|
|
||||||
IF( "${ARGN}" STREQUAL "0")
|
IF( "${ARGN}" STREQUAL "0")
|
||||||
|
|
Loading…
Reference in a new issue