From 82d873933f3aef190b139c4f3ff903c41808c0f5 Mon Sep 17 00:00:00 2001 From: Mike Gabriel Date: Thu, 29 Apr 2021 08:43:28 +0200 Subject: CMakeLists.txt: Adjust test build option (DISABLE_TESTS -> ENABLE_TESTS, defaulting to OFF). Add ENABLE_COVERAGE build option. --- CMakeLists.txt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index c1bffc3..ce7ab46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,7 +8,16 @@ set(API_VERSION 0) set(ABI_VERSION 0) # Options -option(DISABLE_TESTS "Disable tests" off) +option (ENABLE_TESTS "Build the package's automatic tests." OFF) +option (ENABLE_COVERAGE "Generate lcov code coverage reports." OFF) + +if(ENABLE_COVERAGE) + set(ENABLE_TESTS ON) + set(CMAKE_BUILD_TYPE "Coverage") +else() + set(CMAKE_BUILD_TYPE "Release") +endif() + # GNU standard installation directories include (GNUInstallDirs) @@ -34,10 +43,10 @@ set(CC_WARNING_ARGS " -Wall -pedantic -Wextra -Wno-missing-field-initializers") add_subdirectory(src) -if (DISABLE_TESTS) - message(STATUS "Tests disabled") -else() +if (ENABLE_TESTS) include(CTest) enable_testing() add_subdirectory(tests) +else() + message(STATUS "Tests disabled") endif() -- cgit v1.2.3