diff --git a/cmake/CPM.cmake b/cmake/CPM.cmake index f4d0eea4..d43f4436 100644 --- a/cmake/CPM.cmake +++ b/cmake/CPM.cmake @@ -756,6 +756,10 @@ function(CPMAddPackage) "${CPM_ARGS_SYSTEM}" "${CPM_ARGS_OPTIONS}" ) + set(CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} + PARENT_SCOPE + ) set(PACKAGE_INFO "${PACKAGE_INFO} at ${download_directory}") # As the source dir is already cached/populated, we override the call to FetchContent. @@ -815,6 +819,10 @@ function(CPMAddPackage) "${CPM_ARGS_SYSTEM}" "${CPM_ARGS_OPTIONS}" ) + set(CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} + PARENT_SCOPE + ) endif() cpm_get_fetch_properties("${CPM_ARGS_NAME}") endif() @@ -986,6 +994,10 @@ function( set(CPM_OLD_INDENT "${CPM_INDENT}") set(CPM_INDENT "${CPM_INDENT} ${PACKAGE}:") add_subdirectory(${SOURCE_DIR} ${BINARY_DIR} ${addSubdirectoryExtraArgs}) + set(CMAKE_MODULE_PATH + ${CMAKE_MODULE_PATH} + PARENT_SCOPE + ) set(CPM_INDENT "${CPM_OLD_INDENT}") endif() endfunction() diff --git a/examples/catch2/CMakeLists.txt b/examples/catch2/CMakeLists.txt index f4d3e226..2e171ae2 100644 --- a/examples/catch2/CMakeLists.txt +++ b/examples/catch2/CMakeLists.txt @@ -17,5 +17,7 @@ target_compile_features(CPMExampleCatch2 PRIVATE cxx_std_17) # ---- Enable testing ---- +include(Catch) + enable_testing() -add_test(CPMExampleCatch2 CPMExampleCatch2) +catch_discover_tests(CPMExampleCatch2)