@@ -165,17 +165,23 @@ if (WIN32 OR APPLE)
165165endif ()
166166
167167macro (register_test_as_custom_target _test_name _binary_name)
168+ set (multiValueArgs CMD_ARGS)
169+ cmake_parse_arguments (ARGS "" "" "${multiValueArgs} " ${ARGN} )
170+
168171 if (NOT CMAKE_CROSSCOMPILING OR CMAKE_CROSSCOMPILING_EMULATOR)
169172 add_custom_target (
170173 ${_test_name}
171- COMMAND ${CMAKE_COMMAND} -E env ${TEST_ENV} $<TARGET_FILE:${_binary_name} > ${ARGN }
174+ COMMAND ${CMAKE_COMMAND} -E env ${TEST_ENV} $<TARGET_FILE:${_binary_name} > ${ARGS_CMD_ARGS }
172175 DEPENDS ${_binary_name} )
173176 endif ()
174177endmacro ()
175178
176179macro (register_test _test_name _binary_name)
177- register_test_as_custom_target(${_test_name} ${_binary_name} ${ARGN} )
178- add_test (NAME ${_test_name} COMMAND ${_binary_name} ${ARGN} )
180+ set (multiValueArgs CMD_ARGS)
181+ cmake_parse_arguments (ARGS "" "" "${multiValueArgs} " ${ARGN} )
182+
183+ register_test_as_custom_target(${_test_name} ${_binary_name} CMD_ARGS ${ARGS_CMD_ARGS} )
184+ add_test (NAME ${_test_name} COMMAND ${_binary_name} ${ARGS_CMD_ARGS} )
179185 set_property (TEST ${_test_name} PROPERTY ENVIRONMENT "${TEST_ENV} " )
180186endmacro ()
181187
@@ -190,88 +196,100 @@ add_library(main_gtest STATIC main_gtest.cpp)
190196target_link_libraries (main_gtest PRIVATE gtest_for_gdal $<TARGET_NAME:${GDAL_LIB_TARGET_NAME} >)
191197gdal_standard_includes(main_gtest)
192198
193- gdal_test_target(testblockcache testblockcache.cpp)
194- target_link_libraries (testblockcache PRIVATE gtest_for_gdal main_gtest)
199+ gdal_test_target(testblockcache
200+ FILES
201+ testblockcache.cpp)
202+ target_link_libraries (testblockcache
203+ PRIVATE
204+ gtest_for_gdal main_gtest)
195205
196206register_test(
197207 test -block-cache -1
198208 testblockcache
199- -check
200- -co
201- TILED=YES
202- --debug
203- TEST ,LOCK
204- -loops
205- 3
206- --config
207- GDAL_RB_LOCK_DEBUG_CONTENTION
208- YES )
209+ CMD_ARGS
210+ -check
211+ -co
212+ TILED=YES
213+ --debug
214+ TEST ,LOCK
215+ -loops
216+ 3
217+ --config
218+ GDAL_RB_LOCK_DEBUG_CONTENTION
219+ YES )
209220register_test(
210221 test -block-cache -2
211222 testblockcache
212- -check
213- -co
214- TILED=YES
215- --debug
216- TEST ,LOCK
217- -loops
218- 3
219- --config
220- GDAL_RB_LOCK_DEBUG_CONTENTION
221- YES
222- --config
223- GDAL_RB_LOCK_TYPE
224- SPIN)
225- register_test(test -block-cache -3 testblockcache -check -co TILED=YES -migrate)
226- register_test(test -block-cache -4 testblockcache -check -memdriver)
223+ CMD_ARGS
224+ -check
225+ -co
226+ TILED=YES
227+ --debug
228+ TEST ,LOCK
229+ -loops
230+ 3
231+ --config
232+ GDAL_RB_LOCK_DEBUG_CONTENTION
233+ YES
234+ --config
235+ GDAL_RB_LOCK_TYPE
236+ SPIN)
237+ register_test(test -block-cache -3 testblockcache
238+ CMD_ARGS
239+ -check -co TILED=YES -migrate)
240+ register_test(test -block-cache -4 testblockcache
241+ CMD_ARGS
242+ -check -memdriver)
227243register_test(
228244 test -block-cache -5
229245 testblockcache
230- --config
231- GDAL_BAND_BLOCK_CACHE
232- HASHSET
233- -check
234- -co
235- TILED=YES
236- --debug
237- TEST ,LOCK
238- -loops
239- 3
240- --config
241- GDAL_RB_LOCK_DEBUG_CONTENTION
242- YES )
246+ CMD_ARGS
247+ --config
248+ GDAL_BAND_BLOCK_CACHE
249+ HASHSET
250+ -check
251+ -co
252+ TILED=YES
253+ --debug
254+ TEST ,LOCK
255+ -loops
256+ 3
257+ --config
258+ GDAL_RB_LOCK_DEBUG_CONTENTION
259+ YES )
243260register_test(
244261 test -block-cache -6
245262 testblockcache
246- --config
247- GDAL_BAND_BLOCK_CACHE
248- HASHSET
249- -check
250- -co
251- TILED=YES
252- --debug
253- TEST ,LOCK
254- -loops
255- 3
256- --config
257- GDAL_RB_LOCK_DEBUG_CONTENTION
258- YES
259- --config
260- GDAL_RB_LOCK_TYPE
261- SPIN)
263+ CMD_ARGS
264+ --config
265+ GDAL_BAND_BLOCK_CACHE
266+ HASHSET
267+ -check
268+ -co
269+ TILED=YES
270+ --debug
271+ TEST ,LOCK
272+ -loops
273+ 3
274+ --config
275+ GDAL_RB_LOCK_DEBUG_CONTENTION
276+ YES
277+ --config
278+ GDAL_RB_LOCK_TYPE
279+ SPIN)
262280
263281if ("${CMAKE_SYSTEM_PROCESSOR} " MATCHES "(x86_64|AMD64)" AND CMAKE_SIZEOF_VOID_P EQUAL 8 AND HAVE_SSE_AT_COMPILE_TIME)
264- gdal_test_target(testsse2 testsse.cpp)
265- gdal_test_target(testsse2_emulation testsse.cpp)
282+ gdal_test_target(testsse2 FILES testsse.cpp)
283+ gdal_test_target(testsse2_emulation FILES testsse.cpp)
266284 target_compile_definitions (testsse2_emulation PRIVATE -DUSE_SSE2_EMULATION -DNO_WARN_USE_SSE2_EMULATION)
267285 register_test(test -sse2 testsse2)
268286 register_test(test -sse2-emulation testsse2_emulation)
269287
270288 if (HAVE_AVX_AT_COMPILE_TIME)
271289 # Do not include in ctest as we aren't sure the target machine support this
272- gdal_test_target(testssse3 testsse.cpp)
273- gdal_test_target(testsse4_1 testsse.cpp)
274- gdal_test_target(testavx2 testsse.cpp)
290+ gdal_test_target(testssse3 FILES testsse.cpp)
291+ gdal_test_target(testsse4_1 FILES testsse.cpp)
292+ gdal_test_target(testavx2 FILES testsse.cpp)
275293 target_compile_options (testssse3 PRIVATE ${GDAL_SSSE3_FLAG} )
276294 target_compile_options (testsse4_1 PRIVATE ${GDAL_SSSE3_FLAG} ${GDAL_SSE41_FLAG} )
277295 target_compile_options (testavx2 PRIVATE ${GDAL_AVX2_FLAG} )
@@ -281,13 +299,19 @@ if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "(x86_64|AMD64)" AND CMAKE_SIZEOF_VOID_P
281299 endif ()
282300endif ()
283301
284- macro (gdal_autotest_target _target testlabel _source)
285- gdal_test_target(${_target} ${_source} )
286- register_test(${testlabel} ${_target} ${ARGN} )
302+ macro (gdal_autotest_target _target testlabel)
303+ set (multiValueArgs CMD_ARGS FILES )
304+ cmake_parse_arguments (ARGS "" "" "${multiValueArgs} " ${ARGN} )
305+
306+ gdal_test_target(${_target} FILES ${ARGS_FILES} )
307+ register_test(${testlabel} ${_target} CMD_ARGS ${ARGS_CMD_ARGS} )
287308endmacro ()
288309
289- function (gdal_gtest_target _target testlabel _source)
290- gdal_autotest_target(${_target} ${testlabel} ${_source} ${ARGN} )
310+ function (gdal_gtest_target _target testlabel)
311+ set (multiValueArgs CMD_ARGS FILES )
312+ cmake_parse_arguments (ARGS "" "" "${multiValueArgs} " ${ARGN} )
313+
314+ gdal_autotest_target(${_target} ${testlabel} ARGS ${ARGS_CMD_ARGS} FILES ${ARGS_FILES} )
291315 target_link_libraries (${_target} PRIVATE gtest_for_gdal main_gtest)
292316endfunction ()
293317
@@ -313,32 +337,74 @@ set(QUICKTEST_LIST
313337 test -deferred-plugin
314338)
315339
316- gdal_gtest_target(testfloat16 test -float16 testfloat16.cpp)
317- gdal_gtest_target(testcopywords test -copy-words testcopywords.cpp)
318- gdal_gtest_target(testclosedondestroydm test -closed-on -destroy-DM testclosedondestroydm.cpp)
319- gdal_gtest_target(testthreadcond test -threaded-condition testthreadcond.cpp)
320- gdal_gtest_target(testvirtualmem test -virtual-memory testvirtualmem.cpp)
321- gdal_gtest_target(testblockcachewrite test -block-cache -write testblockcachewrite.cpp --debug ON )
322- gdal_gtest_target(testblockcachelimits test -block-cache -limit testblockcachelimits.cpp --debug ON )
323- gdal_gtest_target(testmultithreadedwriting test -multi-threaded-writing testmultithreadedwriting.cpp)
324- gdal_gtest_target(testdestroy test -destroy testdestroy.cpp)
325- gdal_autotest_target(test_include_from_c_file test -include -from-C-file test_include_from_c_file.c "" )
326- gdal_autotest_target(test_c_include_from_cpp_file test -C-include -from-CPP-file test_c_include_from_cpp_file.cpp "" )
327- gdal_gtest_target(bug1488 test -bug1488 bug1488.cpp)
328- gdal_gtest_target(testlog test -log testlog.cpp)
329- gdal_gtest_target(test_deferred_plugin test -deferred-plugin test_deferred_plugin.cpp)
340+ gdal_gtest_target(testfloat16 test -float16
341+ FILES
342+ testfloat16.cpp)
343+ gdal_gtest_target(testcopywords test -copy-words
344+ FILES
345+ testcopywords.cpp)
346+ gdal_gtest_target(testclosedondestroydm test -closed-on -destroy-DM
347+ FILES
348+ testclosedondestroydm.cpp)
349+ gdal_gtest_target(testthreadcond test -threaded-condition
350+ FILES
351+ testthreadcond.cpp)
352+ gdal_gtest_target(testvirtualmem test -virtual-memory
353+ FILES
354+ testvirtualmem.cpp)
355+ gdal_gtest_target(testblockcachewrite test -block-cache -write
356+ FILES
357+ testblockcachewrite.cpp
358+ CMD_ARGS
359+ --debug ON )
360+ gdal_gtest_target(testblockcachelimits test -block-cache -limit
361+ FILES
362+ testblockcachelimits.cpp
363+ CMD_ARGS
364+ --debug ON )
365+ gdal_gtest_target(testmultithreadedwriting test -multi-threaded-writing
366+ FILES
367+ testmultithreadedwriting.cpp)
368+ gdal_gtest_target(testdestroy test -destroy
369+ FILES
370+ testdestroy.cpp
371+ CMD_ARGS
372+ "" )
373+ gdal_autotest_target(test_include_from_c_file test -include -from-C-file
374+ FILES
375+ test_include_from_c_file.c)
376+ gdal_autotest_target(test_c_include_from_cpp_file test -C-include -from-CPP-file
377+ FILES
378+ test_c_include_from_cpp_file.cpp
379+ CMD_ARGS
380+ "" )
381+
382+
383+ gdal_gtest_target(bug1488 test -bug1488
384+ FILES
385+ bug1488.cpp)
386+ gdal_gtest_target(testlog test -log
387+ FILES
388+ testlog.cpp)
389+ gdal_gtest_target(test_deferred_plugin test -deferred-plugin
390+ FILES
391+ test_deferred_plugin.cpp)
330392
331393if (GDAL_ENABLE_DRIVER_JPEG_PLUGIN)
332394 target_compile_definitions (test_deferred_plugin PRIVATE -DJPEG_PLUGIN)
333395endif ()
334396
335397if (UNIX )
336398 list (APPEND QUICKTEST_LIST test -osr-set-proj-search-paths )
337- gdal_gtest_target(test_osr_set_proj_search_paths test -osr-set-proj-search-paths test_osr_set_proj_search_paths.cpp)
399+ gdal_gtest_target(test_osr_set_proj_search_paths test -osr-set-proj-search-paths
400+ FILES
401+ test_osr_set_proj_search_paths.cpp)
338402endif ()
339403
340404if (UNIX )
341- gdal_gtest_target(proj_with_fork test -proj-with-fork proj_with_fork.cpp)
405+ gdal_gtest_target(proj_with_fork test -proj-with-fork
406+ FILES
407+ proj_with_fork.cpp)
342408 list (APPEND QUICKTEST_LIST test -proj-with-fork)
343409endif ()
344410
@@ -349,3 +415,4 @@ endif ()
349415foreach (_test IN LISTS QUICKTEST_LIST)
350416 set_tests_properties (${_test} PROPERTIES LABELS "quicktest" )
351417endforeach ()
418+
0 commit comments