mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-07 01:06:48 +08:00
Merge pull request #84 from musicinmybrain/system-doctest-option
Add a SYSTEM_DOCTEST CMake option
This commit is contained in:
commit
8159e8bcf6
@ -4,9 +4,13 @@ cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
|
|||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
|
option(SYSTEM_DOCTEST "Use system copy of doctest" OFF)
|
||||||
|
|
||||||
|
if (NOT SYSTEM_DOCTEST)
|
||||||
FetchContent_Declare(doctest
|
FetchContent_Declare(doctest
|
||||||
GIT_REPOSITORY https://github.com/onqtam/doctest.git
|
GIT_REPOSITORY https://github.com/onqtam/doctest.git
|
||||||
GIT_TAG 2.4.6)
|
GIT_TAG 2.4.6)
|
||||||
|
endif()
|
||||||
FetchContent_Declare(supplemental_test_files
|
FetchContent_Declare(supplemental_test_files
|
||||||
GIT_REPOSITORY https://github.com/fastfloat/supplemental_test_files.git
|
GIT_REPOSITORY https://github.com/fastfloat/supplemental_test_files.git
|
||||||
GIT_TAG origin/main)
|
GIT_TAG origin/main)
|
||||||
@ -16,11 +20,13 @@ FetchContent_Declare(supplemental_test_files
|
|||||||
# FetchContent_MakeAvailable() was only introduced in 3.14
|
# FetchContent_MakeAvailable() was only introduced in 3.14
|
||||||
# https://cmake.org/cmake/help/v3.14/release/3.14.html#modules
|
# https://cmake.org/cmake/help/v3.14/release/3.14.html#modules
|
||||||
# FetchContent_MakeAvailable(doctest)
|
# FetchContent_MakeAvailable(doctest)
|
||||||
|
if (NOT SYSTEM_DOCTEST)
|
||||||
FetchContent_GetProperties(doctest)
|
FetchContent_GetProperties(doctest)
|
||||||
if(NOT doctest_POPULATED)
|
if(NOT doctest_POPULATED)
|
||||||
FetchContent_Populate(doctest)
|
FetchContent_Populate(doctest)
|
||||||
add_subdirectory(${doctest_SOURCE_DIR} ${doctest_BINARY_DIR})
|
add_subdirectory(${doctest_SOURCE_DIR} ${doctest_BINARY_DIR})
|
||||||
endif()
|
endif()
|
||||||
|
endif()
|
||||||
FetchContent_GetProperties(supplemental_test_files)
|
FetchContent_GetProperties(supplemental_test_files)
|
||||||
if(NOT supplemental_test_files_POPULATED)
|
if(NOT supplemental_test_files_POPULATED)
|
||||||
message(STATUS "Tests enabled. Retrieving test files.")
|
message(STATUS "Tests enabled. Retrieving test files.")
|
||||||
@ -40,7 +46,10 @@ function(fast_float_add_cpp_test TEST_NAME)
|
|||||||
target_compile_options(${TEST_NAME} PUBLIC -Werror -Wall -Wextra -Weffc++)
|
target_compile_options(${TEST_NAME} PUBLIC -Werror -Wall -Wextra -Weffc++)
|
||||||
target_compile_options(${TEST_NAME} PUBLIC -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wsign-conversion)
|
target_compile_options(${TEST_NAME} PUBLIC -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wsign-conversion)
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(${TEST_NAME} PUBLIC fast_float doctest supplemental-data)
|
target_link_libraries(${TEST_NAME} PUBLIC fast_float supplemental-data)
|
||||||
|
if (NOT SYSTEM_DOCTEST)
|
||||||
|
target_link_libraries(${TEST_NAME} PUBLIC doctest)
|
||||||
|
endif()
|
||||||
endfunction(fast_float_add_cpp_test)
|
endfunction(fast_float_add_cpp_test)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user