|
|
|
@ -51,6 +51,25 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags) |
|
|
|
|
ENDIF() |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
IF(CMAKE_COMPILER_IS_GNUCXX) |
|
|
|
|
|
|
|
|
|
GET_PROPERTY(_definitions DIRECTORY PROPERTY COMPILE_DEFINITIONS) |
|
|
|
|
if(_definitions) |
|
|
|
|
foreach(_def ${_definitions}) |
|
|
|
|
LIST(APPEND ${_out_compile_flags} "\"-D${_def}\"") |
|
|
|
|
endforeach() |
|
|
|
|
endif() |
|
|
|
|
GET_TARGET_PROPERTY(_target_definitions ${_PCH_current_target} COMPILE_DEFINITIONS) |
|
|
|
|
if(_target_definitions) |
|
|
|
|
foreach(_def ${_target_definitions}) |
|
|
|
|
LIST(APPEND ${_out_compile_flags} "\"-D${_def}\"") |
|
|
|
|
endforeach() |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
ELSE() |
|
|
|
|
## TODO ... ? or does it work out of the box |
|
|
|
|
ENDIF() |
|
|
|
|
|
|
|
|
|
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES ) |
|
|
|
|
FOREACH(item ${DIRINC}) |
|
|
|
|
if(item MATCHES "^${OpenCV_SOURCE_DIR}/modules/") |
|
|
|
@ -60,11 +79,15 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags) |
|
|
|
|
endif() |
|
|
|
|
ENDFOREACH(item) |
|
|
|
|
|
|
|
|
|
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) |
|
|
|
|
GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${OpenCV_SOURCE_DIR} DEFINITIONS) |
|
|
|
|
#MESSAGE("_directory_flags ${_directory_flags} ${_global_definitions}" ) |
|
|
|
|
LIST(APPEND ${_out_compile_flags} ${_directory_flags}) |
|
|
|
|
LIST(APPEND ${_out_compile_flags} ${_global_definitions}) |
|
|
|
|
get_target_property(DIRINC ${_PCH_current_target} INCLUDE_DIRECTORIES ) |
|
|
|
|
FOREACH(item ${DIRINC}) |
|
|
|
|
if(item MATCHES "^${OpenCV_SOURCE_DIR}/modules/") |
|
|
|
|
LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}\"${item}\"") |
|
|
|
|
else() |
|
|
|
|
LIST(APPEND ${_out_compile_flags} "${_PCH_isystem_prefix}\"${item}\"") |
|
|
|
|
endif() |
|
|
|
|
ENDFOREACH(item) |
|
|
|
|
|
|
|
|
|
LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS}) |
|
|
|
|
|
|
|
|
|
SEPARATE_ARGUMENTS(${_out_compile_flags}) |
|
|
|
@ -146,9 +169,9 @@ MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags _header_name _pch_path _dowarn ) |
|
|
|
|
# if you have different versions of the headers for different build types |
|
|
|
|
# you may set _pch_dowarn |
|
|
|
|
IF (_dowarn) |
|
|
|
|
set(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -Winvalid-pch") |
|
|
|
|
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include \"${CMAKE_CURRENT_BINARY_DIR}/${_header_name}\" -Winvalid-pch " ) |
|
|
|
|
ELSE (_dowarn) |
|
|
|
|
set(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS}") |
|
|
|
|
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include \"${CMAKE_CURRENT_BINARY_DIR}/${_header_name}\" " ) |
|
|
|
|
ENDIF (_dowarn) |
|
|
|
|
|
|
|
|
|
ELSE(CMAKE_COMPILER_IS_GNUCXX) |
|
|
|
@ -246,12 +269,15 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input) |
|
|
|
|
endif() |
|
|
|
|
endif() |
|
|
|
|
|
|
|
|
|
get_target_property(DIRINC ${_targetName} INCLUDE_DIRECTORIES) |
|
|
|
|
set_target_properties(${_targetName}_pch_dephelp PROPERTIES INCLUDE_DIRECTORIES "${DIRINC}") |
|
|
|
|
|
|
|
|
|
#MESSAGE("_compile_FLAGS: ${_compile_FLAGS}") |
|
|
|
|
#message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}") |
|
|
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND( |
|
|
|
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_name}" |
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy "${_input}" "${CMAKE_CURRENT_BINARY_DIR}/${_name}" # ensure same directory! Required by gcc |
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_input}" "${CMAKE_CURRENT_BINARY_DIR}/${_name}" # ensure same directory! Required by gcc |
|
|
|
|
DEPENDS "${_input}" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|