download_test_data.cmake 684 B

1234567891011121314
  1. find_package(Git)
  2. set(JSON_TEST_DATA_URL https://github.com/nlohmann/json_test_data)
  3. set(JSON_TEST_DATA_VERSION 1.0.0)
  4. # target to download test data
  5. add_custom_target(download_test_data
  6. COMMAND test -d json_test_data || ${GIT_EXECUTABLE} clone -c advice.detachedHead=false --branch v${JSON_TEST_DATA_VERSION} ${JSON_TEST_DATA_URL}.git --quiet --depth 1
  7. COMMENT "Downloading test data from ${JSON_TEST_DATA_URL} (v${JSON_TEST_DATA_VERSION})"
  8. WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
  9. )
  10. # create a header with the path to the downloaded test data
  11. file(WRITE ${CMAKE_BINARY_DIR}/include/test_data.hpp "#define TEST_DATA_DIRECTORY \"${CMAKE_BINARY_DIR}/json_test_data\"")