Line
Link Here
|
0 |
-- a/cmake/OpenCVPCHSupport.cmake |
0 |
++ b/cmake/OpenCVPCHSupport.cmake |
Lines 51-56
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
Link Here
|
51 |
ENDIF() |
51 |
ENDIF() |
52 |
endif() |
52 |
endif() |
53 |
|
53 |
|
|
|
54 |
IF(CMAKE_COMPILER_IS_GNUCXX) |
55 |
|
56 |
GET_PROPERTY(_definitions DIRECTORY PROPERTY COMPILE_DEFINITIONS) |
57 |
if(_definitions) |
58 |
foreach(_def ${_definitions}) |
59 |
LIST(APPEND ${_out_compile_flags} "\"-D${_def}\"") |
60 |
endforeach() |
61 |
endif() |
62 |
GET_TARGET_PROPERTY(_target_definitions ${_PCH_current_target} COMPILE_DEFINITIONS) |
63 |
if(_target_definitions) |
64 |
foreach(_def ${_target_definitions}) |
65 |
LIST(APPEND ${_out_compile_flags} "\"-D${_def}\"") |
66 |
endforeach() |
67 |
endif() |
68 |
|
69 |
ELSE() |
70 |
## TODO ... ? or does it work out of the box |
71 |
ENDIF() |
72 |
|
54 |
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES ) |
73 |
GET_DIRECTORY_PROPERTY(DIRINC INCLUDE_DIRECTORIES ) |
55 |
FOREACH(item ${DIRINC}) |
74 |
FOREACH(item ${DIRINC}) |
56 |
if(item MATCHES "^${OpenCV_SOURCE_DIR}/modules/") |
75 |
if(item MATCHES "^${OpenCV_SOURCE_DIR}/modules/") |
Lines 60-70
MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
Link Here
|
60 |
endif() |
79 |
endif() |
61 |
ENDFOREACH(item) |
80 |
ENDFOREACH(item) |
62 |
|
81 |
|
63 |
GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) |
82 |
get_target_property(DIRINC ${_PCH_current_target} INCLUDE_DIRECTORIES ) |
64 |
GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${OpenCV_SOURCE_DIR} DEFINITIONS) |
83 |
FOREACH(item ${DIRINC}) |
65 |
#MESSAGE("_directory_flags ${_directory_flags} ${_global_definitions}" ) |
84 |
if(item MATCHES "^${OpenCV_SOURCE_DIR}/modules/") |
66 |
LIST(APPEND ${_out_compile_flags} ${_directory_flags}) |
85 |
LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}\"${item}\"") |
67 |
LIST(APPEND ${_out_compile_flags} ${_global_definitions}) |
86 |
else() |
|
|
87 |
LIST(APPEND ${_out_compile_flags} "${_PCH_isystem_prefix}\"${item}\"") |
88 |
endif() |
89 |
ENDFOREACH(item) |
90 |
|
68 |
LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS}) |
91 |
LIST(APPEND ${_out_compile_flags} ${CMAKE_CXX_FLAGS}) |
69 |
|
92 |
|
70 |
SEPARATE_ARGUMENTS(${_out_compile_flags}) |
93 |
SEPARATE_ARGUMENTS(${_out_compile_flags}) |
Lines 146-154
MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags _header_name _pch_path _dowarn )
Link Here
|
146 |
# if you have different versions of the headers for different build types |
169 |
# if you have different versions of the headers for different build types |
147 |
# you may set _pch_dowarn |
170 |
# you may set _pch_dowarn |
148 |
IF (_dowarn) |
171 |
IF (_dowarn) |
149 |
set(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -Winvalid-pch") |
172 |
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include \"${CMAKE_CURRENT_BINARY_DIR}/${_header_name}\" -Winvalid-pch " ) |
150 |
ELSE (_dowarn) |
173 |
ELSE (_dowarn) |
151 |
set(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS}") |
174 |
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} -include \"${CMAKE_CURRENT_BINARY_DIR}/${_header_name}\" " ) |
152 |
ENDIF (_dowarn) |
175 |
ENDIF (_dowarn) |
153 |
|
176 |
|
154 |
ELSE(CMAKE_COMPILER_IS_GNUCXX) |
177 |
ELSE(CMAKE_COMPILER_IS_GNUCXX) |
Lines 246-257
MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
Link Here
|
246 |
endif() |
269 |
endif() |
247 |
endif() |
270 |
endif() |
248 |
|
271 |
|
|
|
272 |
get_target_property(DIRINC ${_targetName} INCLUDE_DIRECTORIES) |
273 |
set_target_properties(${_targetName}_pch_dephelp PROPERTIES INCLUDE_DIRECTORIES "${DIRINC}") |
274 |
|
249 |
#MESSAGE("_compile_FLAGS: ${_compile_FLAGS}") |
275 |
#MESSAGE("_compile_FLAGS: ${_compile_FLAGS}") |
250 |
#message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}") |
276 |
#message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}") |
251 |
|
277 |
|
252 |
ADD_CUSTOM_COMMAND( |
278 |
ADD_CUSTOM_COMMAND( |
253 |
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_name}" |
279 |
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_name}" |
254 |
COMMAND ${CMAKE_COMMAND} -E copy "${_input}" "${CMAKE_CURRENT_BINARY_DIR}/${_name}" # ensure same directory! Required by gcc |
280 |
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_input}" "${CMAKE_CURRENT_BINARY_DIR}/${_name}" # ensure same directory! Required by gcc |
255 |
DEPENDS "${_input}" |
281 |
DEPENDS "${_input}" |
256 |
) |
282 |
) |
257 |
|
283 |
|