11if (BUILD_TESTING AND Catch2_FOUND)
22 include (FetchContent)
33 include (Catch)
4+ set (SAMPLE_IMAGES_ARCHIVE "" CACHE FILEPATH "Path to sample images archive. If not set, it will be downloaded from the internet." )
45
56 # Get sample images
6- if (NOT EXISTS ${PROJECT_BINARY_DIR} /metadata_test_images.tar.gz)
7- file (DOWNLOAD https://nexus.library.illinois.edu/repository/sample-data/images/metadata_test_images.tar.gz ${PROJECT_BINARY_DIR} /metadata_test_images.tar.gz SHOW_PROGRESS )
8- endif ()
9- FetchContent_Declare(
10- test_images
11- URL ${PROJECT_BINARY_DIR} /metadata_test_images.tar.gz
12- )
13- FetchContent_MakeAvailable(test_images)
7+ if (SAMPLE_IMAGES_ARCHIVE)
8+ set (TEST_IMAGE_PATH "${CMAKE_CURRENT_BINARY_DIR} /metadata_test_images/" )
9+ file (ARCHIVE_EXTRACT
10+ INPUT "${SAMPLE_IMAGES_ARCHIVE} "
11+ DESTINATION "${CMAKE_CURRENT_BINARY_DIR} /"
12+ )
13+ else ()
14+ FetchContent_Declare(
15+ test_images
16+ URL ${PROJECT_BINARY_DIR} /metadata_test_images.tar.gz
17+ )
18+ FetchContent_MakeAvailable(test_images)
19+ set (TEST_IMAGE_PATH ${test_images_SOURCE_DIR} )
20+ endif ()
1421 add_executable (tester test -basic.cpp test_exceptions.cpp)
1522 target_include_directories (tester PRIVATE ${PROJECT_SOURCE_DIR} /uiucprescon/imagevalidate)
1623
17- target_compile_definitions (tester PRIVATE TEST_IMAGE_PATH="${test_images_SOURCE_DIR } " )
24+ target_compile_definitions (tester PRIVATE TEST_IMAGE_PATH="${TEST_IMAGE_PATH } " )
1825 target_link_libraries (tester PRIVATE Catch2::Catch2WithMain imagevalidate::glue)
1926 catch_discover_tests(tester
2027 TEST_PREFIX imagevalidate.
@@ -24,7 +31,7 @@ if (BUILD_TESTING AND Catch2_FOUND)
2431
2532 add_executable (tester-internal tester-internal .cpp)
2633 target_compile_definitions (tester-internal
27- PRIVATE TEST_IMAGE_PATH="${test_images_SOURCE_DIR } " )
34+ PRIVATE TEST_IMAGE_PATH="${TEST_IMAGE_PATH } " )
2835
2936
3037 target_link_libraries (tester-internal
0 commit comments