@@ -4,9 +4,13 @@ cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
44
55include (FetchContent)
66
7- FetchContent_Declare(doctest
8- GIT_REPOSITORY https://github.com/onqtam/doctest.git
9- GIT_TAG 2.4.6)
7+ option (SYSTEM_DOCTEST "Use system copy of doctest" OFF )
8+
9+ if (NOT SYSTEM_DOCTEST)
10+ FetchContent_Declare(doctest
11+ GIT_REPOSITORY https://github.com/onqtam/doctest.git
12+ GIT_TAG 2.4.6)
13+ endif ()
1014FetchContent_Declare(supplemental_test_files
1115 GIT_REPOSITORY https://github.com/fastfloat/supplemental_test_files.git
1216 GIT_TAG origin/main)
@@ -16,10 +20,12 @@ FetchContent_Declare(supplemental_test_files
1620# FetchContent_MakeAvailable() was only introduced in 3.14
1721# https://cmake.org/cmake/help/v3.14/release/3.14.html#modules
1822# FetchContent_MakeAvailable(doctest)
19- FetchContent_GetProperties(doctest)
20- if (NOT doctest_POPULATED)
21- FetchContent_Populate(doctest)
22- add_subdirectory (${doctest_SOURCE_DIR} ${doctest_BINARY_DIR} )
23+ if (NOT SYSTEM_DOCTEST)
24+ FetchContent_GetProperties(doctest)
25+ if (NOT doctest_POPULATED)
26+ FetchContent_Populate(doctest)
27+ add_subdirectory (${doctest_SOURCE_DIR} ${doctest_BINARY_DIR} )
28+ endif ()
2329endif ()
2430FetchContent_GetProperties(supplemental_test_files)
2531if (NOT supplemental_test_files_POPULATED)
@@ -40,7 +46,10 @@ function(fast_float_add_cpp_test TEST_NAME)
4046 target_compile_options (${TEST_NAME} PUBLIC -Werror -Wall -Wextra -Weffc++)
4147 target_compile_options (${TEST_NAME} PUBLIC -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wsign-conversion)
4248 endif ()
43- target_link_libraries (${TEST_NAME} PUBLIC fast_float doctest supplemental-data)
49+ target_link_libraries (${TEST_NAME} PUBLIC fast_float supplemental-data)
50+ if (NOT SYSTEM_DOCTEST)
51+ target_link_libraries (${TEST_NAME} PUBLIC doctest)
52+ endif ()
4453endfunction (fast_float_add_cpp_test)
4554
4655
@@ -65,4 +74,4 @@ if (FASTFLOAT_EXHAUSTIVE)
6574 fast_float_add_cpp_test(random64)
6675endif (FASTFLOAT_EXHAUSTIVE)
6776
68- add_subdirectory (build_tests)
77+ add_subdirectory (build_tests)
0 commit comments