aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-05-04 14:25:47 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-05-04 14:30:07 +0200
commitedd6cdd68fe0410d86d36455b200ddd8455a5842 (patch)
tree93670bf2c991955ef1a3cc09e6b9431ad7ca50ad
parenta3db57030481923c3624822f3e439468d969c500 (diff)
downloadayatana-indicator-power-edd6cdd68fe0410d86d36455b200ddd8455a5842.tar.gz
ayatana-indicator-power-edd6cdd68fe0410d86d36455b200ddd8455a5842.tar.bz2
ayatana-indicator-power-edd6cdd68fe0410d86d36455b200ddd8455a5842.zip
CMakeLists.txt: Switch to 'our' new style of enabling tests and coverage reports.
This also fixes the generation of coverage reports. By some reason, the variables SERVICE_LIB and SERVICE_EXEC did not produce any raw trace data for coverage analysis. Hard-coding the target names, though, seems to work.
-rw-r--r--CMakeLists.txt27
1 files changed, 19 insertions, 8 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0ca8dbe..4be6ca1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,16 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
set(PROJECT_VERSION "2.1.2")
set(PACKAGE ${CMAKE_PROJECT_NAME})
-option (enable_tests "Build the package's automatic tests." ON)
+# Options
+option(ENABLE_TESTS "Enable all tests and checks" OFF)
+option(ENABLE_COVERAGE "Enable coverage reports (includes enabling all tests and checks)" OFF)
+
+if(ENABLE_COVERAGE)
+ set(ENABLE_TESTS ON)
+ set(CMAKE_BUILD_TYPE "Coverage")
+else()
+ set(CMAKE_BUILD_TYPE "Release")
+endif()
##
## GNU standard installation directories
@@ -85,13 +94,15 @@ add_subdirectory(po)
# testing & coverage
-if (${enable_tests})
+if (ENABLE_TESTS)
enable_testing ()
add_subdirectory(tests)
- find_package(CoverageReport)
- ENABLE_COVERAGE_REPORT(
- TARGETS ${SERVICE_LIB} ${SERVICE_EXEC}
- TESTS ${COVERAGE_TEST_TARGETS}
- FILTER /usr/include ${CMAKE_BINARY_DIR}/*
- )
+ if (ENABLE_COVERAGE)
+ find_package(CoverageReport)
+ ENABLE_COVERAGE_REPORT(
+ TARGETS ayatanaindicatorpowerservice ayatana-indicator-power-service
+ TESTS ${COVERAGE_TEST_TARGETS}
+ FILTER /usr/include ${CMAKE_BINARY_DIR}/*
+ )
+ endif ()
endif ()