From dbce1b739209f73f562748022d77e8302a17ebc3 Mon Sep 17 00:00:00 2001 From: ClausKlein Date: Wed, 26 Jul 2023 22:06:11 +0200 Subject: [PATCH] Fix problems while using local packages update CPM.cmake version too Set FORCE option for SOURCE_DIR usage --- cmake/CPM.cmake | 3 ++- standalone/CMakeLists.txt | 6 +++++- test/CMakeLists.txt | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index e9674a7..f49d743 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -1,4 +1,4 @@ -set(CPM_DOWNLOAD_VERSION 0.37.0) +set(CPM_DOWNLOAD_VERSION 0.38.2) if(CPM_SOURCE_CACHE) set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake") @@ -27,6 +27,7 @@ else() if("${check}" STREQUAL "") download_cpm() endif() + unset(check) endif() include(${CPM_DOWNLOAD_LOCATION}) diff --git a/standalone/CMakeLists.txt b/standalone/CMakeLists.txt index a932149..d558c0e 100644 --- a/standalone/CMakeLists.txt +++ b/standalone/CMakeLists.txt @@ -16,7 +16,11 @@ CPMAddPackage( OPTIONS "CXXOPTS_BUILD_EXAMPLES NO" "CXXOPTS_BUILD_TESTS NO" "CXXOPTS_ENABLE_INSTALL YES" ) -CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..) +CPMAddPackage( + NAME Greeter + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/.. + FORCE ON +) # ---- Create standalone executable ---- diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 74cd08d..0991d16 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,7 +21,11 @@ CPMAddPackage("gh:TheLartians/Format.cmake@1.7.3") if(TEST_INSTALLED_VERSION) find_package(Greeter REQUIRED) else() - CPMAddPackage(NAME Greeter SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/..) + CPMAddPackage( + NAME Greeter + SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/.. + FORCE ON + ) endif() # ---- Create binary ---- @@ -46,11 +50,13 @@ endif() enable_testing() # Note: doctest and similar testing frameworks can automatically configure CMake tests. For other -# testing frameworks add the tests target instead: add_test(NAME ${PROJECT_NAME} COMMAND -# ${PROJECT_NAME}) - -include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake) -doctest_discover_tests(${PROJECT_NAME}) +# testing frameworks add the tests target instead: +if(NOT doctest_SOURCE_DIR) + add_test(NAME ${PROJECT_NAME} COMMAND ${PROJECT_NAME}) +else() + include(${doctest_SOURCE_DIR}/scripts/cmake/doctest.cmake) + doctest_discover_tests(${PROJECT_NAME}) +endif() # ---- code coverage ----