]> granicus.if.org Git - check/commitdiff
Remove non-CMake style option CHECK_ENABLE_TESTS
authorMikko Johannes Koivunalho <mikko.koivunalho@iki.fi>
Mon, 2 Sep 2019 20:34:49 +0000 (22:34 +0200)
committerMikko Johannes Koivunalho <mikko.koivunalho@iki.fi>
Sun, 8 Sep 2019 07:31:04 +0000 (09:31 +0200)
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 <mikko.koivunalho@iki.fi>
CMakeLists.txt
tests/CMakeLists.txt

index ccb402faeac644178ea3f3992099b9fc814944c2..8b93c187296883ec7fa1c95dd9dc57599d4987cf 100644 (file)
@@ -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
index b3d7ab7e73d6df6499dd52e973a5982dc74e1972..7ce83890a5c224f4c3094ac6ab5703fab07ea964 100644 (file)
@@ -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