|
|
|
@ -159,107 +159,112 @@ ENDMACRO(ADD_PRECOMPILED_HEADER_TO_TARGET)
|
|
|
|
|
|
|
|
|
|
MACRO(ADD_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
|
|
|
|
|
|
|
|
|
|
SET(_PCH_current_target ${_targetName})
|
|
|
|
|
IF(WITH_PCH)
|
|
|
|
|
SET(_PCH_current_target ${_targetName})
|
|
|
|
|
|
|
|
|
|
IF(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
MESSAGE(FATAL_ERROR
|
|
|
|
|
"This is the ADD_PRECOMPILED_HEADER macro. "
|
|
|
|
|
"You must set CMAKE_BUILD_TYPE!"
|
|
|
|
|
)
|
|
|
|
|
ENDIF(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
IF(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
MESSAGE(FATAL_ERROR
|
|
|
|
|
"This is the ADD_PRECOMPILED_HEADER macro. "
|
|
|
|
|
"You must set CMAKE_BUILD_TYPE!"
|
|
|
|
|
)
|
|
|
|
|
ENDIF(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
|
|
|
|
|
IF( "${ARGN}" STREQUAL "0")
|
|
|
|
|
SET(_dowarn 0)
|
|
|
|
|
ELSE( "${ARGN}" STREQUAL "0")
|
|
|
|
|
SET(_dowarn 1)
|
|
|
|
|
ENDIF("${ARGN}" STREQUAL "0")
|
|
|
|
|
IF( "${ARGN}" STREQUAL "0")
|
|
|
|
|
SET(_dowarn 0)
|
|
|
|
|
ELSE( "${ARGN}" STREQUAL "0")
|
|
|
|
|
SET(_dowarn 1)
|
|
|
|
|
ENDIF("${ARGN}" STREQUAL "0")
|
|
|
|
|
|
|
|
|
|
GET_FILENAME_COMPONENT(_name ${_inputh} NAME)
|
|
|
|
|
GET_FILENAME_COMPONENT(_path ${_inputh} PATH)
|
|
|
|
|
GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_inputh} _output)
|
|
|
|
|
GET_FILENAME_COMPONENT(_name ${_inputh} NAME)
|
|
|
|
|
GET_FILENAME_COMPONENT(_path ${_inputh} PATH)
|
|
|
|
|
GET_PRECOMPILED_HEADER_OUTPUT( ${_targetName} ${_inputh} _output)
|
|
|
|
|
|
|
|
|
|
GET_FILENAME_COMPONENT(_outdir ${_output} PATH )
|
|
|
|
|
GET_FILENAME_COMPONENT(_outdir ${_output} PATH )
|
|
|
|
|
|
|
|
|
|
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
|
|
|
|
|
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
|
|
|
|
|
|
|
|
|
|
# always build static library because it doesn't need linking
|
|
|
|
|
ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_inputcpp})
|
|
|
|
|
# always build static library because it doesn't need linking
|
|
|
|
|
ADD_LIBRARY(${_targetName}_pch_dephelp STATIC ${_inputcpp})
|
|
|
|
|
|
|
|
|
|
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("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}")
|
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${_name} PROPERTIES GENERATED 1)
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${_inputh} ${CMAKE_CURRENT_BINARY_DIR}/${_name} # ensure same directory! Required by gcc
|
|
|
|
|
DEPENDS ${_inputh}
|
|
|
|
|
)
|
|
|
|
|
#MESSAGE("_compile_FLAGS: ${_compile_FLAGS}")
|
|
|
|
|
#message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}")
|
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_BINARY_DIR}/${_name} PROPERTIES GENERATED 1)
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_name}
|
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${_inputh} ${CMAKE_CURRENT_BINARY_DIR}/${_name} # ensure same directory! Required by gcc
|
|
|
|
|
DEPENDS ${_inputh}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
#message("_command ${_input} ${_output}")
|
|
|
|
|
_PCH_GET_COMPILE_COMMAND(_command ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_output})
|
|
|
|
|
|
|
|
|
|
#message("_command ${_input} ${_output}")
|
|
|
|
|
_PCH_GET_COMPILE_COMMAND(_command ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_output})
|
|
|
|
|
#message(${_input} )
|
|
|
|
|
#message("_output ${_output}")
|
|
|
|
|
|
|
|
|
|
#message(${_input} )
|
|
|
|
|
#message("_output ${_output}")
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
|
OUTPUT ${_output}
|
|
|
|
|
COMMAND ${_command}
|
|
|
|
|
DEPENDS ${_inputh} ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_targetName}_pch_dephelp
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
|
OUTPUT ${_output}
|
|
|
|
|
COMMAND ${_command}
|
|
|
|
|
DEPENDS ${_inputh} ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_targetName}_pch_dephelp
|
|
|
|
|
)
|
|
|
|
|
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_inputh} ${_output} ${_dowarn})
|
|
|
|
|
ENDIF(WITH_PCH)
|
|
|
|
|
|
|
|
|
|
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_inputh} ${_output} ${_dowarn})
|
|
|
|
|
ENDMACRO(ADD_PRECOMPILED_HEADER)
|
|
|
|
|
|
|
|
|
|
MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _inputh _inputcpp)
|
|
|
|
|
|
|
|
|
|
IF( "${ARGN}" STREQUAL "0")
|
|
|
|
|
SET(_dowarn 0)
|
|
|
|
|
ELSE( "${ARGN}" STREQUAL "0")
|
|
|
|
|
SET(_dowarn 1)
|
|
|
|
|
ENDIF("${ARGN}" STREQUAL "0")
|
|
|
|
|
IF(WITH_PCH)
|
|
|
|
|
IF( "${ARGN}" STREQUAL "0")
|
|
|
|
|
SET(_dowarn 0)
|
|
|
|
|
ELSE( "${ARGN}" STREQUAL "0")
|
|
|
|
|
SET(_dowarn 1)
|
|
|
|
|
ENDIF("${ARGN}" STREQUAL "0")
|
|
|
|
|
|
|
|
|
|
if(CMAKE_GENERATOR MATCHES Visual*)
|
|
|
|
|
# Auto include the precompile (useful for moc processing, since the use of
|
|
|
|
|
# precompiled is specified at the target level
|
|
|
|
|
# and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
|
|
|
|
|
if(CMAKE_GENERATOR MATCHES Visual*)
|
|
|
|
|
# Auto include the precompile (useful for moc processing, since the use of
|
|
|
|
|
# precompiled is specified at the target level
|
|
|
|
|
# and I don't want to specifiy /F- for each moc/res/ui generated files (using Qt)
|
|
|
|
|
|
|
|
|
|
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
|
|
|
|
|
if (${oldProps} MATCHES NOTFOUND)
|
|
|
|
|
SET(oldProps "")
|
|
|
|
|
endif(${oldProps} MATCHES NOTFOUND)
|
|
|
|
|
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
|
|
|
|
|
if (${oldProps} MATCHES NOTFOUND)
|
|
|
|
|
SET(oldProps "")
|
|
|
|
|
endif(${oldProps} MATCHES NOTFOUND)
|
|
|
|
|
|
|
|
|
|
SET(newProperties "${oldProps} /Yu\"${_inputh}\" /FI\"${_inputh}\"")
|
|
|
|
|
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
|
|
|
|
|
SET(newProperties "${oldProps} /Yu\"${_inputh}\" /FI\"${_inputh}\"")
|
|
|
|
|
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES COMPILE_FLAGS "${newProperties}")
|
|
|
|
|
|
|
|
|
|
#also inlude ${oldProps} to have the same compile options
|
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_inputh}\"")
|
|
|
|
|
#also inlude ${oldProps} to have the same compile options
|
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(${_inputcpp} PROPERTIES COMPILE_FLAGS "${oldProps} /Yc\"${_inputh}\"")
|
|
|
|
|
|
|
|
|
|
else(CMAKE_GENERATOR MATCHES Visual*)
|
|
|
|
|
else(CMAKE_GENERATOR MATCHES Visual*)
|
|
|
|
|
|
|
|
|
|
if (CMAKE_GENERATOR MATCHES Xcode)
|
|
|
|
|
# For Xcode, cmake needs my patch to process
|
|
|
|
|
# GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
|
|
|
|
|
if (CMAKE_GENERATOR MATCHES Xcode)
|
|
|
|
|
# For Xcode, cmake needs my patch to process
|
|
|
|
|
# GCC_PREFIX_HEADER and GCC_PRECOMPILE_PREFIX_HEADER as target properties
|
|
|
|
|
|
|
|
|
|
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
|
|
|
|
|
if (${oldProps} MATCHES NOTFOUND)
|
|
|
|
|
SET(oldProps "")
|
|
|
|
|
endif(${oldProps} MATCHES NOTFOUND)
|
|
|
|
|
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
|
|
|
|
|
if (${oldProps} MATCHES NOTFOUND)
|
|
|
|
|
SET(oldProps "")
|
|
|
|
|
endif(${oldProps} MATCHES NOTFOUND)
|
|
|
|
|
|
|
|
|
|
# When buiding out of the tree, precompiled may not be located
|
|
|
|
|
# Use full path instead.
|
|
|
|
|
GET_FILENAME_COMPONENT(fullPath ${_inputh} ABSOLUTE)
|
|
|
|
|
# When buiding out of the tree, precompiled may not be located
|
|
|
|
|
# Use full path instead.
|
|
|
|
|
GET_FILENAME_COMPONENT(fullPath ${_inputh} ABSOLUTE)
|
|
|
|
|
|
|
|
|
|
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
|
|
|
|
|
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
|
|
|
|
|
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PREFIX_HEADER "${fullPath}")
|
|
|
|
|
SET_TARGET_PROPERTIES(${_targetName} PROPERTIES XCODE_ATTRIBUTE_GCC_PRECOMPILE_PREFIX_HEADER "YES")
|
|
|
|
|
|
|
|
|
|
else (CMAKE_GENERATOR MATCHES Xcode)
|
|
|
|
|
else (CMAKE_GENERATOR MATCHES Xcode)
|
|
|
|
|
|
|
|
|
|
#Fallback to the "old" precompiled suppport
|
|
|
|
|
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp} ${_dowarn})
|
|
|
|
|
endif(CMAKE_GENERATOR MATCHES Xcode)
|
|
|
|
|
endif(CMAKE_GENERATOR MATCHES Visual*)
|
|
|
|
|
#Fallback to the "old" precompiled suppport
|
|
|
|
|
ADD_PRECOMPILED_HEADER(${_targetName} ${_inputh} ${_inputcpp} ${_dowarn})
|
|
|
|
|
endif(CMAKE_GENERATOR MATCHES Xcode)
|
|
|
|
|
endif(CMAKE_GENERATOR MATCHES Visual*)
|
|
|
|
|
ENDIF(WITH_PCH)
|
|
|
|
|
|
|
|
|
|
ENDMACRO(ADD_NATIVE_PRECOMPILED_HEADER)
|
|
|
|
|