From 334fc07146ec5b9703bc1bae8389bfca5a8b8500 Mon Sep 17 00:00:00 2001 From: shutsch Date: Thu, 22 Feb 2024 12:35:11 +0100 Subject: [PATCH] trying to find catch2 submodule part 2 --- CMakeLists.txt | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54126a0..5c3fc7e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,14 +22,16 @@ set(BUILD_PYTHON_PACKAGE OFF CACHE BOOL OFF) if (COMPILE_TESTS) message("-- Trying to find Catch2 to compile the test cases. Turn off via setting 'COMPILE_TESTS=OFF' in your environment before installation. ") - set(INTERNAL_findCatch2_DIR ${PROJECT_SOURCE_DIR}/extern/Catch2) - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${INTERNAL_findCatch2_DIR}") find_package(Catch2 3) if (Catch2_FOUND) - message("-- catch2 library found. Tests will be compiled.") + message("-- global installation of catch2 library found. Tests will be compiled.") else() - message("-- catch2 library not found. Testing disabled.") - set(COMPILE_TESTS OFF) + set(INTERNAL_findCatch2_DIR ${PROJECT_SOURCE_DIR}/extern/Catch2) + if(NOT EXISTS ${INTERNAL_findCatch2_DIR}) + message(FATAL_ERROR "The catch2 submodule was not initialized! Please run 'git submodule update --init'. Alternativly you can install catch2 globally on your system." ) + endif() + add_subdirectory(INTERNAL_findCatch2_DIR) + message("-- catch2 library found as a submodule. Tests will be compiled.") endif() else() set(Catch2_FOUND OFF)