From 2461c2364f524b5462a4747de3304b0efe197aa8 Mon Sep 17 00:00:00 2001 From: Johannes Schmidt Date: Thu, 31 Jul 2025 15:42:40 +0200 Subject: [PATCH] Drop ICINGA2_WITH_TESTS option in favor of CTest's BUILD_TESTING There is no need to use our own option for this when an official one exists. Even worse, on the current master, if we set ours to on and the official one to OFF, the tests directory is included, but the add_boost_test() command skips building/adding them, which forces us to wrap additional calls to set_tests_properties() in a check on the official option. --- CMakeLists.txt | 7 ++----- doc/21-development.md | 7 +++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f392e51a2..ef59d95de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,6 @@ option(ICINGA2_WITH_COMPAT "Build the compat module" ${ICINGA2_MASTER}) option(ICINGA2_WITH_LIVESTATUS "Build the Livestatus module" ${ICINGA2_MASTER}) option(ICINGA2_WITH_NOTIFICATION "Build the notification module" ON) option(ICINGA2_WITH_PERFDATA "Build the perfdata module" ${ICINGA2_MASTER}) -option(ICINGA2_WITH_TESTS "Run unit tests" ON) option(ICINGA2_WITH_ICINGADB "Build the IcingaDB module" ${ICINGA2_MASTER}) option (USE_SYSTEMD @@ -471,9 +470,6 @@ install( DESTINATION ${CMAKE_INSTALL_DOCDIR} ) -include(CTest) -enable_testing() - set_property(GLOBAL PROPERTY USE_FOLDERS ON) add_subdirectory(third-party) @@ -494,7 +490,8 @@ if(MSVC) add_subdirectory(icinga-installer) endif() -if(ICINGA2_WITH_TESTS) +include(CTest) +if(BUILD_TESTING) add_subdirectory(test) endif() diff --git a/doc/21-development.md b/doc/21-development.md index c3f46fb92..143319b34 100644 --- a/doc/21-development.md +++ b/doc/21-development.md @@ -1453,7 +1453,7 @@ Second, define the two build types with their specific CMake variables. ```bash export I2_DEBUG="-DCMAKE_BUILD_TYPE=Debug -DICINGA2_UNITY_BUILD=OFF $I2_GENERIC" -export I2_RELEASE="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DICINGA2_WITH_TESTS=ON -DICINGA2_UNITY_BUILD=ON $I2_GENERIC" +export I2_RELEASE="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DICINGA2_UNITY_BUILD=ON $I2_GENERIC" ``` Third, depending on your likings, you may use a bash alias for building, @@ -1655,7 +1655,7 @@ export I2_USER=$(id -u -n) export I2_GROUP=$(id -g -n) export I2_GENERIC="-DCMAKE_INSTALL_PREFIX=/usr/local/icinga/icinga2 -DICINGA2_USER=$I2_USER -DICINGA2_GROUP=$I2_GROUP -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@1.1/include -DOPENSSL_SSL_LIBRARY=/usr/local/opt/openssl@1.1/lib/libssl.dylib -DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/openssl@1.1/lib/libcrypto.dylib -DICINGA2_PLUGINDIR=/usr/local/sbin -DICINGA2_WITH_PGSQL=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" export I2_DEBUG="-DCMAKE_BUILD_TYPE=Debug -DICINGA2_UNITY_BUILD=OFF $I2_GENERIC" -export I2_RELEASE="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DICINGA2_WITH_TESTS=ON -DICINGA2_UNITY_BUILD=ON $I2_GENERIC" +export I2_RELEASE="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DICINGA2_UNITY_BUILD=ON $I2_GENERIC" cd debug cmake $I2_DEBUG .. @@ -1686,7 +1686,7 @@ export I2_GROUP=$(id -g -n) export I2_GENERIC="-DCMAKE_INSTALL_PREFIX=/usr/local/icinga/icinga2 -DICINGA2_USER=$I2_USER -DICINGA2_GROUP=$I2_GROUP -DOPENSSL_INCLUDE_DIR=/usr/local/opt/openssl@1.1/include -DOPENSSL_SSL_LIBRARY=/usr/local/opt/openssl@1.1/lib/libssl.dylib -DOPENSSL_CRYPTO_LIBRARY=/usr/local/opt/openssl@1.1/lib/libcrypto.dylib -DICINGA2_PLUGINDIR=/usr/local/sbin -DICINGA2_WITH_PGSQL=OFF -DCMAKE_EXPORT_COMPILE_COMMANDS=ON" export I2_DEBUG="-DCMAKE_BUILD_TYPE=Debug -DICINGA2_UNITY_BUILD=OFF $I2_GENERIC" -export I2_RELEASE="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DICINGA2_WITH_TESTS=ON -DICINGA2_UNITY_BUILD=ON $I2_GENERIC" +export I2_RELEASE="-DCMAKE_BUILD_TYPE=RelWithDebInfo -DICINGA2_UNITY_BUILD=ON $I2_GENERIC" alias i2_debug="mkdir -p debug; cd debug; cmake $I2_DEBUG ..; make -j4; make -j4 install; cd .." alias i2_release="mkdir -p release; cd release; cmake $I2_RELEASE ..; make -j4; make -j4 install; cd .." @@ -2365,7 +2365,6 @@ Also see `CMakeLists.txt` for details. * `ICINGA2_WITH_LIVESTATUS`: Determines whether the Livestatus module is built; defaults to `ON` * `ICINGA2_WITH_NOTIFICATION`: Determines whether the notification module is built; defaults to `ON` * `ICINGA2_WITH_PERFDATA`: Determines whether the perfdata module is built; defaults to `ON` -* `ICINGA2_WITH_TESTS`: Determines whether the unit tests are built; defaults to `ON` #### MySQL or MariaDB