diff options
author | Robert Adam <dev@robert-adam.de> | 2020-09-12 10:00:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-12 10:00:37 +0300 |
commit | 0a53864d2084a9cd47fe6216914cccb7841b187c (patch) | |
tree | fc345e94d85876c1f1922eae60780462abf067c3 /CMakeLists.txt | |
parent | 557bf8d3f003ee678f481e98cc99daca259a2995 (diff) | |
parent | 42d9f2dab84587a8fbda0cffc273f71c6afe1ef6 (diff) |
Merge pull request #4480: BUILD(cmake): Don't re-use BUILD_TESTING
We used the BUILD_TESTING variable in order to indicate whether or not
tests shall be built. However this variable is used by e.g. CTest
already and there it had a different default value. Therefore we now
deprecate BUILD_TESTING and use the tests option instead.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bba988b3..0580d4955 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,13 +32,13 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/FindModules" ) + include(pkg-utils) -include(CTest) include(project-utils) include(GNUInstallDirs) -option(BUILD_TESTING "Build tests." OFF) +option(tests "Build tests" OFF) option(optimize "Build a heavily optimized version, specific to the machine it's being compiled on." OFF) option(static "Build static binaries." OFF) @@ -112,6 +112,21 @@ message(STATUS "Architecture: ${ARCH}") message(STATUS "Build type: ${BUILD_STR}") message(STATUS "##################################################") +# We have to check for BUILD_TESTING before including CTest as CTest defines this variable +if(DEFINED BUILD_TESTING) + message(WARNING "Use of option \"BUILD_TESTING\" is deprecated. Use \"tests\" instead.") + + if(NOT tests) + # Allow deprecated option to enable tests if they had been disabled otherwise + set(tests "${BUILD_TESTING}") + endif() +endif() + +if(tests) + include(CTest) +endif() + + add_subdirectory(src) if(g15 AND WIN32) |