@@ -4,9 +4,13 @@ cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
4
4
5
5
include (FetchContent )
6
6
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 ()
10
14
FetchContent_Declare (supplemental_test_files
11
15
GIT_REPOSITORY https://github.com/fastfloat/supplemental_test_files.git
12
16
GIT_TAG origin/main )
@@ -16,10 +20,12 @@ FetchContent_Declare(supplemental_test_files
16
20
# FetchContent_MakeAvailable() was only introduced in 3.14
17
21
# https://cmake.org/cmake/help/v3.14/release/3.14.html#modules
18
22
# 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 ()
23
29
endif ()
24
30
FetchContent_GetProperties (supplemental_test_files )
25
31
if (NOT supplemental_test_files_POPULATED )
@@ -40,7 +46,10 @@ function(fast_float_add_cpp_test TEST_NAME)
40
46
target_compile_options (${TEST_NAME} PUBLIC -Werror -Wall -Wextra -Weffc++ )
41
47
target_compile_options (${TEST_NAME} PUBLIC -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wsign-conversion )
42
48
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 ()
44
53
endfunction (fast_float_add_cpp_test )
45
54
46
55
@@ -65,4 +74,4 @@ if (FASTFLOAT_EXHAUSTIVE)
65
74
fast_float_add_cpp_test (random64 )
66
75
endif (FASTFLOAT_EXHAUSTIVE )
67
76
68
- add_subdirectory (build_tests )
77
+ add_subdirectory (build_tests )
0 commit comments