[044716]: config / cmake / config / vxl_config_macros.cmake  Maximize  Restore  History

Download this file

343 lines (313 with data), 12.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
#
# Perform the VXL specific test with status output
#
# Sets the TEST to 1 if the corresponding program could be compiled
# and linked
#
MACRO(PERFORM_CMAKE_TEST FILE TEST)
IF( VXL_UPDATE_CONFIGURATION )
SET( ${TEST} "${TEST}" )
ENDIF( VXL_UPDATE_CONFIGURATION )
IF("${TEST}" MATCHES "^${TEST}$")
# Perform test
SET(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${TEST} ${CMAKE_REQUIRED_FLAGS}")
IF(CMAKE_REQUIRED_LIBRARIES)
SET(TEST_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ENDIF(CMAKE_REQUIRED_LIBRARIES)
MESSAGE(STATUS "Performing Test ${TEST}")
TRY_COMPILE(${TEST}
${CMAKE_BINARY_DIR}
${vxl_config_SOURCE_DIR}/${FILE}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${TEST_ADD_LIBRARIES}"
OUTPUT_VARIABLE OUTPUT)
IF(${TEST})
SET(${TEST} 1 CACHE INTERNAL "VXL test ${FUNCTION}")
MESSAGE(STATUS "Performing Test ${TEST} - Success")
ELSE(${TEST})
MESSAGE(STATUS "Performing Test ${TEST} - Failed")
SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION}")
WRITE_FILE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing Test ${TEST} failed with the following output:\n"
"${OUTPUT}\n" APPEND)
ENDIF(${TEST})
ELSE("${TEST}" MATCHES "^${TEST}$")
# Have result
#FOREACH(tst ${TEST})
# MESSAGE("Test ${TEST} resulted in ${${tst}}")
#ENDFOREACH(tst ${TEST})
ENDIF("${TEST}" MATCHES "^${TEST}$")
ENDMACRO(PERFORM_CMAKE_TEST FILE TEST)
#
# Perform a custom VXL try compile test with status output
#
# DIR is the directory containing the test project
#
# Sets the TEST to 1 if the corresponding program could be compiled
# and linked
#
MACRO(PERFORM_CMAKE_TEST_CUSTOM DIR TEST)
IF( VXL_UPDATE_CONFIGURATION )
SET( ${TEST} "${TEST}" )
ENDIF( VXL_UPDATE_CONFIGURATION )
IF("${TEST}" MATCHES "^${TEST}$")
# Perform test
SET(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${TEST} ${CMAKE_REQUIRED_FLAGS}")
IF(CMAKE_REQUIRED_LIBRARIES)
SET(TEST_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ENDIF(CMAKE_REQUIRED_LIBRARIES)
MESSAGE(STATUS "Performing Test ${TEST}")
TRY_COMPILE(${TEST}
${CMAKE_BINARY_DIR}/config/${DIR}
${vxl_config_SOURCE_DIR}/${DIR}
${TEST}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
"${TEST_ADD_LIBRARIES}"
OUTPUT_VARIABLE OUTPUT)
IF(${TEST})
SET(${TEST} 1 CACHE INTERNAL "VXL test ${FUNCTION}")
MESSAGE(STATUS "Performing Test ${TEST} - Success")
ELSE(${TEST})
MESSAGE(STATUS "Performing Test ${TEST} - Failed")
SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION}")
WRITE_FILE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing Test ${TEST} failed with the following output:\n"
"${OUTPUT}\n" APPEND)
ENDIF(${TEST})
ENDIF("${TEST}" MATCHES "^${TEST}$")
FILE(REMOVE_RECURSE ${CMAKE_BINARY_DIR}/config/${DIR})
ENDMACRO(PERFORM_CMAKE_TEST_CUSTOM DIR TEST)
#
# Perform the VXL specific try-run test with status output
#
# Sets TEST to 1 if the corresponding program compiles, links, run,
# and returns 0 (indicating success).
#
MACRO(PERFORM_CMAKE_TEST_RUN FILE TEST)
IF( VXL_UPDATE_CONFIGURATION )
SET( ${TEST} "${TEST}" )
ENDIF( VXL_UPDATE_CONFIGURATION )
IF("${TEST}" MATCHES "^${TEST}$")
# Perform test
SET(MACRO_CHECK_FUNCTION_DEFINITIONS
"-D${TEST} ${CMAKE_REQUIRED_FLAGS}")
IF(CMAKE_REQUIRED_LIBRARIES)
SET(TEST_ADD_LIBRARIES
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ENDIF(CMAKE_REQUIRED_LIBRARIES)
MESSAGE(STATUS "Performing Test ${TEST}")
TRY_RUN(${TEST} ${TEST}_COMPILED
${CMAKE_BINARY_DIR}
${vxl_config_SOURCE_DIR}/${FILE}
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
"${TEST_ADD_LIBRARIES}"
OUTPUT_VARIABLE OUTPUT)
IF(${TEST}_COMPILED)
IF(${TEST})
MESSAGE(STATUS "Performing Test ${TEST} - Failed")
SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION} (failed to run)")
WRITE_FILE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing Test ${TEST} failed with the following output:\n"
"${OUTPUT}\n" APPEND)
ELSE(${TEST})
SET(${TEST} 1 CACHE INTERNAL "VXL test ${FUNCTION} (successful run)")
MESSAGE(STATUS "Performing Test ${TEST} - Success")
WRITE_FILE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing Test ${TEST} succeeded with the following output:\n"
"${OUTPUT}\n" APPEND)
ENDIF(${TEST})
ELSE(${TEST}_COMPILED)
MESSAGE(STATUS "Performing Try-Run Test ${TEST} - Test Compilation Failed")
SET(${TEST} 0 CACHE INTERNAL "Test ${FUNCTION} (failed to compile)")
WRITE_FILE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing Try-Run Test ${TEST} failed to compile with the following output:\n"
"${OUTPUT}\n" APPEND)
ENDIF(${TEST}_COMPILED)
ELSE("${TEST}" MATCHES "^${TEST}$")
# Have result
#FOREACH(tst ${TEST})
# MESSAGE("Test ${TEST} resulted in ${${tst}}")
#ENDFOREACH(tst ${TEST})
ENDIF("${TEST}" MATCHES "^${TEST}$")
ENDMACRO(PERFORM_CMAKE_TEST_RUN FILE TEST)
#
# Check for include file and if not found, set variable to 0
#
MACRO(PERFORM_CHECK_HEADER FILE VARIABLE)
IF( VXL_UPDATE_CONFIGURATION )
SET( ${VARIABLE} ${VARIABLE} )
ENDIF( VXL_UPDATE_CONFIGURATION )
CHECK_INCLUDE_FILE_CXX(${FILE} ${VARIABLE})
IF("${VARIABLE}" MATCHES "^$")
SET(${VARIABLE} 0)
ENDIF("${VARIABLE}" MATCHES "^$")
ENDMACRO(PERFORM_CHECK_HEADER FILE VARIABLE)
#
# Check value of variable and if true, set to VALUE_TRUE, otherwise to
# VALUE_FALSE
#
MACRO(SET_BOOL VAR VALUE_TRUE VALUE_FALSE)
SET(SET_BOOL_VAR "${VAR}")
IF(${SET_BOOL_VAR})
SET(${VAR} ${VALUE_TRUE})
ELSE(${SET_BOOL_VAR})
SET(${VAR} ${VALUE_FALSE})
ENDIF(${SET_BOOL_VAR})
ENDMACRO(SET_BOOL VAR VALUE_TRUE VALUE_FALSE)
#
# Set the variable to inverse of the given value
#
MACRO(SET_INVERT VAR VALUE)
SET(SET_INVERT_VAR "${VALUE}")
IF(SET_INVERT_VAR)
SET(${VAR} "0")
ELSE(SET_INVERT_VAR)
SET(${VAR} "1")
ENDIF(SET_INVERT_VAR)
ENDMACRO(SET_INVERT VAR VALUE)
#
# Check if the type exists (should really go to CMake/Modules)
#
MACRO(CHECK_TYPE_EXISTS TYPE FILES VARIABLE)
IF( VXL_UPDATE_CONFIGURATION )
SET( ${VARIABLE} "${VARIABLE}" )
ENDIF( VXL_UPDATE_CONFIGURATION )
IF("${VARIABLE}" MATCHES "^${VARIABLE}$")
SET(CHECK_TYPE_EXISTS_CONTENT "/* */\n")
SET(MACRO_CHECK_TYPE_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS})
IF(CMAKE_REQUIRED_LIBRARIES)
SET(CHECK_TYPE_EXISTS_LIBS
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
ENDIF(CMAKE_REQUIRED_LIBRARIES)
FOREACH(FILE ${FILES})
SET(CHECK_TYPE_EXISTS_CONTENT
"${CHECK_TYPE_EXISTS_CONTENT}#include <${FILE}>\n")
ENDFOREACH(FILE)
SET(CHECK_TYPE_EXISTS_CONTENT
"${CHECK_TYPE_EXISTS_CONTENT}\nvoid cmakeRequireSymbol(${TYPE} dummy){(void)dummy;}\nint main()\n{return 0;\n}\n")
FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeExists.cxx
"${CHECK_TYPE_EXISTS_CONTENT}")
MESSAGE(STATUS "Looking for ${TYPE}")
TRY_COMPILE(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeExists.cxx
CMAKE_FLAGS
-DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_EXISTS_FLAGS}
"${CHECK_TYPE_EXISTS_LIBS}"
OUTPUT_VARIABLE OUTPUT)
IF(${VARIABLE})
MESSAGE(STATUS "Looking for ${TYPE} - found")
SET(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${TYPE}")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the ${TYPE} "
"exist passed with the following output:\n"
"${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeExists.cxx:\n"
"${CHECK_TYPE_EXISTS_CONTENT}\n")
ELSE(${VARIABLE})
MESSAGE(STATUS "Looking for ${TYPE} - not found.")
SET(${VARIABLE} "" CACHE INTERNAL "Have symbol ${TYPE}")
FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the ${TYPE} "
"exist failed with the following output:\n"
"${OUTPUT}\nFile ${CMAKE_BINARY_DIR}/CMakeTmp/CheckTypeExists.c:\n"
"${CHECK_TYPE_EXISTS_CONTENT}\n")
ENDIF(${VARIABLE})
ENDIF("${VARIABLE}" MATCHES "^${VARIABLE}$")
ENDMACRO(CHECK_TYPE_EXISTS TYPE FILES VARIABLE)
#
# Check if the type exists and if not make result 0
#
MACRO(CHECK_TYPE_EXISTS_ZERO SYMBOL FILES VARIABLE)
IF( VXL_UPDATE_CONFIGURATION )
SET( ${VARIABLE} )
ENDIF( VXL_UPDATE_CONFIGURATION )
CHECK_TYPE_EXISTS("${SYMBOL}" "${FILES}" "${VARIABLE}")
IF(NOT ${VARIABLE})
SET(${VARIABLE} 0)
ENDIF(NOT ${VARIABLE})
ENDMACRO(CHECK_TYPE_EXISTS_ZERO SYMBOL FILES VARIABLE)
#
# Check if the function exists and if not make result 0
#
MACRO(CHECK_FUNCTION_EXISTS_ZERO FUNCTION VARIABLE)
IF( VXL_UPDATE_CONFIGURATION )
SET( ${VARIABLE} ${VARIABLE} )
ENDIF( VXL_UPDATE_CONFIGURATION )
CHECK_FUNCTION_EXISTS("${FUNCTION}" "${VARIABLE}")
IF(NOT ${VARIABLE})
SET(${VARIABLE} 0)
ENDIF(NOT ${VARIABLE})
ENDMACRO(CHECK_FUNCTION_EXISTS_ZERO FUNCTION VARIABLE)
#
# Determine which C++ type matches the given size
#
MACRO( DETERMINE_TYPE VAR INTEGRAL_TYPE SIZE TYPE_LIST )
IF( VXL_UPDATE_CONFIGURATION )
SET( VXL_${VAR} "" )
ENDIF( VXL_UPDATE_CONFIGURATION )
# If we've tested this before, use the cached result and don't re-run
IF( NOT VXL_${VAR} )
# We can't have IF commands on a macro parameter. For example,
# IF( INTEGRAL_TYPE ) doesn't seem to work. I think the
# expansion is done at the wrong time. A macro is not a procedure
# call. This is a workaround.
SET( MSG1 "Looking for ${SIZE}-bit int." )
SET( MSG0 "Looking for ${SIZE}-bit float." )
SET( MSG ${MSG${INTEGRAL_TYPE}} )
SET( VXL_${VAR} "void" )
SET( VXL_HAS_${VAR} 0 )
FOREACH( TYPE ${TYPE_LIST} )
# Write the config to a file instead of passing on the command
# line to avoid issues with spaces. (In "long double", for
# example)
WRITE_FILE( ${CMAKE_BINARY_DIR}/CMakeTmp/config.h "#define THE_TYPE ${TYPE}\n#define THE_SIZE ${SIZE}\n#define INTEGRAL_TYPE ${INTEGRAL_TYPE}" )
SET( MACRO_DETERMINE_TYPE_FLAGS "-DVXL_HAS_TYPE_OF_SIZE" )
MESSAGE( STATUS "${MSG} [Checking ${TYPE}...]" )
TRY_COMPILE(COMPILE_RESULT
${CMAKE_BINARY_DIR}
${vxl_config_SOURCE_DIR}/vxl_platform_tests.cxx
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_DETERMINE_TYPE_FLAGS}
-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR}/CMakeTmp
-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}
OUTPUT_VARIABLE OUTPUT )
IF( COMPILE_RESULT )
SET( VXL_${VAR} ${TYPE} )
SET( VXL_HAS_${VAR} 1 )
ELSE( COMPILE_RESULT )
WRITE_FILE( ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${MSG} Failed to compile with the following output:\n(FLAGS=${MACRO_DETERMINE_TYPE_FLAGS})\n${OUTPUT}\n"
APPEND )
ENDIF( COMPILE_RESULT )
ENDFOREACH( TYPE )
IF( VXL_HAS_${VAR} )
MESSAGE( STATUS "${MSG} Found ${VXL_${VAR}}." )
ELSE( VXL_HAS_${VAR} )
MESSAGE( STATUS "${MSG} Not found." )
ENDIF( VXL_HAS_${VAR} )
# Cache the value to prevent a second run of the test
SET( VXL_${VAR} ${VXL_${VAR}} CACHE INTERNAL "VXL test result" )
SET( VXL_HAS_${VAR} ${VXL_HAS_${VAR}} CACHE INTERNAL "VXL test result" )
ENDIF( NOT VXL_${VAR} )
ENDMACRO( DETERMINE_TYPE VAR SIZE TYPE_LIST )
#
# Determine if a particular function is declared in the given header.
#
MACRO(PERFORM_C_CHECK_FUNCTION SYMBOL FILE VARIABLE)
IF( VXL_UPDATE_CONFIGURATION )
SET( ${VARIABLE} ${VARIABLE} )
ENDIF( VXL_UPDATE_CONFIGURATION )
CHECK_SYMBOL_EXISTS(${SYMBOL} ${FILE} ${VARIABLE})
IF(${VARIABLE})
SET(${VARIABLE} "1")
ELSE(${VARIABLE})
SET(${VARIABLE} "0")
ENDIF(${VARIABLE})
ENDMACRO(PERFORM_C_CHECK_FUNCTION SYMBOL FILE VARIABLE)

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks