From 09bd2b8722dcbdddba32c10940c02b6f6229e6d2 Mon Sep 17 00:00:00 2001 From: Mikko Johannes Koivunalho Date: Mon, 2 Sep 2019 22:34:49 +0200 Subject: [PATCH] Remove non-CMake style option CHECK_ENABLE_TESTS It is a CMake best practice to include file 'CTest' in the project main file and then use option 'BUILD_TESTING' (defined in 'CTest') to enable or disable building the tests. BUILD_TESTING is ON by default. https://cmake.org/cmake/help/v3.9/module/CTest.html?highlight=build_testing https://cmake.org/cmake/help/v3.9/command/add_test.html?highlight=build_testing Option CHECK_ENABLE_TESTS is deprecated. Because it is on by default, deprecation warning is only shown to user when user explicitly turns CHECK_ENABLE_TESTS off. Suggesting to remove the option by release 0.15.0. Signed-off-by: Mikko Johannes Koivunalho --- CMakeLists.txt | 15 +++++++++++---- tests/CMakeLists.txt | 2 -- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ccb402f..8b93c18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,10 @@ project(check DESCRIPTION "Unit Testing Framework for C" LANGUAGES C) +############################################################################### +# Configure a project for testing with CTest/CDash +include(CTest) + set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") macro(extract_version file setting_name) @@ -60,7 +64,11 @@ set(CMAKE_C_EXTENSIONS ON) # Use GNU extensions and POSIX standard ############################################################################### # Option option(CHECK_ENABLE_TESTS - "Enable the compilation and running of Check's unit tests" ON) + "Deprecated: Enable the compilation and running of Check's unit tests" ON) +if(NOT CHECK_ENABLE_TESTS) + message(DEPRECATION "The option CHECK_ENABLE_TESTS is deprecated. Use option BUILD_TESTING.") + # TODO Remove this option by Check 0.15.0! +endif(NOT CHECK_ENABLE_TESTS) option(CHECK_ENABLE_GCOV "Turn on test coverage" OFF) if (CHECK_ENABLE_GCOV AND NOT ${CMAKE_C_COMPILER_ID} MATCHES "GNU") @@ -415,9 +423,8 @@ add_subdirectory(checkmk) ############################################################################### # Unit tests -if (CHECK_ENABLE_TESTS) +if (BUILD_TESTING) add_subdirectory(tests) - enable_testing() add_test(NAME check_check COMMAND check_check) add_test(NAME check_check_export COMMAND check_check_export) @@ -445,7 +452,7 @@ if (CHECK_ENABLE_TESTS) WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tests COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/tests/test_set_max_msg_size.sh) endif(UNIX OR MINGW OR MSYS) -endif() +endif (BUILD_TESTING) ############################################################################### # Export project, prepare a config and config-version files diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b3d7ab7..7ce8389 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -40,8 +40,6 @@ endif(WIN32) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test_vars.in ${CMAKE_CURRENT_BINARY_DIR}/test_vars) -include(CTest) - set(CHECK_CHECK_SOURCES check_check_exit.c check_check_fixture.c -- 2.50.1