Only add doctest when tests are enabled
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-02-05 13:51:50 +01:00
parent ea2fa7b547
commit 656de2ab17
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 8 additions and 7 deletions

View File

@ -48,12 +48,6 @@ CPMAddPackage(
VERSION 1.6 VERSION 1.6
DOWNLOAD_ONLY YES DOWNLOAD_ONLY YES
) )
CPMAddPackage(
NAME doctest
GITHUB_REPOSITORY doctest/doctest
GIT_TAG 2.4.0
DOWNLOAD_ONLY YES
)
CPMAddPackage( CPMAddPackage(
NAME pcg-cpp NAME pcg-cpp
GITHUB_REPOSITORY imneme/pcg-cpp GITHUB_REPOSITORY imneme/pcg-cpp
@ -61,7 +55,6 @@ CPMAddPackage(
DOWNLOAD_ONLY YES DOWNLOAD_ONLY YES
) )
target_include_directories(Arbutils PUBLIC ${backward_SOURCE_DIR}) target_include_directories(Arbutils PUBLIC ${backward_SOURCE_DIR})
target_include_directories(Arbutils PUBLIC ${doctest_SOURCE_DIR}/doctest)
target_include_directories(Arbutils PUBLIC ${pcg-cpp_SOURCE_DIR}/include) target_include_directories(Arbutils PUBLIC ${pcg-cpp_SOURCE_DIR}/include)
# If we are building for Windows we need to set some specific variables. # If we are building for Windows we need to set some specific variables.
@ -98,10 +91,18 @@ endif(STATICC)
target_link_libraries(Arbutils ${LINKS}) target_link_libraries(Arbutils ${LINKS})
if (TESTS) if (TESTS)
CPMAddPackage(
NAME doctest
GITHUB_REPOSITORY doctest/doctest
GIT_TAG 2.4.0
DOWNLOAD_ONLY YES
)
# If we want a tests executable, grab all tests source files # If we want a tests executable, grab all tests source files
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
# And create an executable from it. Also include doctest.hpp. # And create an executable from it. Also include doctest.hpp.
add_executable(ArbutilsTests ${TEST_FILES}) add_executable(ArbutilsTests ${TEST_FILES})
target_include_directories(ArbutilsTests PUBLIC ${doctest_SOURCE_DIR}/doctest)
# And finally link the library to the executable. # And finally link the library to the executable.
target_link_libraries(ArbutilsTests Arbutils ${LINKS}) target_link_libraries(ArbutilsTests Arbutils ${LINKS})
# Add a compilation definition to the code that we are building a test build. # Add a compilation definition to the code that we are building a test build.