From 656de2ab17bc21e7d15ad20c7e74c3f7e9b06988 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 5 Feb 2022 13:51:50 +0100 Subject: [PATCH] Only add doctest when tests are enabled --- CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e197432..edd874b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,12 +48,6 @@ CPMAddPackage( VERSION 1.6 DOWNLOAD_ONLY YES ) -CPMAddPackage( - NAME doctest - GITHUB_REPOSITORY doctest/doctest - GIT_TAG 2.4.0 - DOWNLOAD_ONLY YES -) CPMAddPackage( NAME pcg-cpp GITHUB_REPOSITORY imneme/pcg-cpp @@ -61,7 +55,6 @@ CPMAddPackage( DOWNLOAD_ONLY YES ) 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) # If we are building for Windows we need to set some specific variables. @@ -98,10 +91,18 @@ endif(STATICC) target_link_libraries(Arbutils ${LINKS}) 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 file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp") # And create an executable from it. Also include doctest.hpp. add_executable(ArbutilsTests ${TEST_FILES}) + target_include_directories(ArbutilsTests PUBLIC ${doctest_SOURCE_DIR}/doctest) # And finally link the library to the executable. target_link_libraries(ArbutilsTests Arbutils ${LINKS}) # Add a compilation definition to the code that we are building a test build.