Move test data download into CMake script
Avoid using shell commands to check if the test directory exists by using a CMake script.
This commit is contained in:
parent
3c77b378e6
commit
875cc362e0
@ -12,7 +12,11 @@ else()
|
|||||||
find_package(Git REQUIRED)
|
find_package(Git REQUIRED)
|
||||||
# target to download test data
|
# target to download test data
|
||||||
add_custom_target(download_test_data
|
add_custom_target(download_test_data
|
||||||
COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL} --quiet --depth 1
|
COMMAND ${CMAKE_COMMAND}
|
||||||
|
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
|
||||||
|
-DJSON_TEST_DATA_VERSION=${JSON_TEST_DATA_VERSION}
|
||||||
|
-DJSON_TEST_DATA_URL=${JSON_TEST_DATA_URL}
|
||||||
|
-P ${PROJECT_SOURCE_DIR}/cmake/scripts/clone_test_data.cmake
|
||||||
COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
|
COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
|
||||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||||
)
|
)
|
||||||
|
|||||||
16
cmake/scripts/clone_test_data.cmake
Normal file
16
cmake/scripts/clone_test_data.cmake
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# clone test data
|
||||||
|
|
||||||
|
get_filename_component(test_data_dir json_test_data ABSOLUTE)
|
||||||
|
|
||||||
|
if(NOT EXISTS ${test_data_dir})
|
||||||
|
execute_process(COMMAND ${GIT_EXECUTABLE} clone
|
||||||
|
-q -c advice.detachedHead=false -b v${JSON_TEST_DATA_VERSION} --depth 1
|
||||||
|
-- ${JSON_TEST_DATA_URL} ${test_data_dir}
|
||||||
|
RESULT_VARIABLE git_result
|
||||||
|
OUTPUT_VARIABLE git_output
|
||||||
|
ERROR_VARIABLE git_output)
|
||||||
|
|
||||||
|
if(NOT git_result EQUAL 0)
|
||||||
|
message(FATAL_ERROR "git failed:\n${git_output}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
Loading…
Reference in New Issue
Block a user