From 440907e1cda7897e2dd029ab0d74ec36643e6095 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Sun, 14 Sep 2025 15:26:16 +0100 Subject: [PATCH] cmake: simplify tests handling Move the requirement checking and the dummy test where they are used. Use REQUIRED instead of the manual FOUND check and error handling. Signed-off-by: Emil Velikov --- CMakeLists.txt | 12 +----------- tests/CMakeLists.txt | 2 ++ tests/unit/CMakeLists.txt | 2 ++ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 133d7a63e..d351589ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -313,17 +313,7 @@ list(APPEND EXTRA_LIBS "m") add_subdirectory(src) add_subdirectory(doc) -if(ENABLE_TESTS) - find_package(CppUTest) - if(CPPUTEST_FOUND) - enable_testing() - else() - message(SEND_ERROR "CppUTest not found") - endif() -else() - enable_testing() - add_test(NAME notests COMMAND true) -endif() +enable_testing() add_subdirectory(tests) configure_file(config.h.cmake config.h @ONLY) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 06e9d780b..37b07c5ff 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -25,4 +25,6 @@ endif() if(ENABLE_TESTS) add_subdirectory(unit) +else() + add_test(NAME notests COMMAND true) endif() diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt index 2df393210..2966eda33 100644 --- a/tests/unit/CMakeLists.txt +++ b/tests/unit/CMakeLists.txt @@ -22,6 +22,8 @@ enable_language(CXX) remove_definitions(-DHAVE_CONFIG_H) + +find_package(CppUTest REQUIRED) include_directories( ${CPPUTEST_INCLUDE_DIRS} ${PROJECT_BINARY_DIR}