aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-10 22:10:28 +0200
committerMike Gabriel <mike.gabriel@das-netzwerkteam.de>2021-08-10 22:10:28 +0200
commit5f7bc0fd29982f49cb64e2da578ed3ccea423111 (patch)
treedd7c7a1fe1dded849e94b835b5c855627ea79d6e
parentc98d777ae4445938549e98caa443a51febba94a3 (diff)
parent76fd52d2211e91cd8c88a4d21845530a77489f4c (diff)
downloadayatana-indicator-display-5f7bc0fd29982f49cb64e2da578ed3ccea423111.tar.gz
ayatana-indicator-display-5f7bc0fd29982f49cb64e2da578ed3ccea423111.tar.bz2
ayatana-indicator-display-5f7bc0fd29982f49cb64e2da578ed3ccea423111.zip
Merge branch 'tari01-pr/add-standard-ayatana-cmake-bits'
Attributes GH PR #17: https://github.com/AyatanaIndicators/ayatana-indicator-display/pull/17
-rw-r--r--CMakeLists.txt55
1 files changed, 43 insertions, 12 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 94615b6..1e2eca2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,9 @@
project(ayatana-indicator-display LANGUAGES C CXX)
-cmake_minimum_required(VERSION 2.8.9)
+cmake_minimum_required(VERSION 3.13)
-list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
+if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE)
+endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
##
## GNU standard paths
@@ -13,7 +15,23 @@ set(PACKAGE ${CMAKE_PROJECT_NAME})
set(SERVICE_LIB ${PACKAGE})
set(SERVICE_EXEC "${PACKAGE}-service")
-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)
+option(ENABLE_WERROR "Treat all build warnings as errors" OFF)
+
+if(ENABLE_COVERAGE)
+ set(ENABLE_TESTS ON)
+ set(CMAKE_BUILD_TYPE "Coverage")
+else()
+ set(CMAKE_BUILD_TYPE "Release")
+endif()
+
+if(ENABLE_WERROR)
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
+endif()
set(CMAKE_INSTALL_PKGLIBEXECDIR "${CMAKE_INSTALL_LIBEXECDIR}/${CMAKE_PROJECT_NAME}")
set(CMAKE_INSTALL_FULL_PKGLIBEXECDIR "${CMAKE_INSTALL_FULL_LIBEXECDIR}/${CMAKE_PROJECT_NAME}")
@@ -77,13 +95,26 @@ add_subdirectory(po)
## Testing & Coverage
##
-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_TESTS)
+
+ include(CTest)
+ enable_testing()
+ add_subdirectory(tests)
+
+ if (ENABLE_COVERAGE)
+ find_package(CoverageReport)
+ ENABLE_COVERAGE_REPORT(
+ TARGETS ${SERVICE_LIB} ${SERVICE_EXEC}
+ TESTS ${COVERAGE_TEST_TARGETS}
+ FILTER /usr/include ${CMAKE_BINARY_DIR}/*
+ )
+
+ endif()
+
endif()
+
+# Display config info
+
+message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
+message(STATUS "Unit tests: ${ENABLE_TESTS}")
+message(STATUS "Build with -Werror: ${ENABLE_WERROR}")