cmake_minimum_required(VERSION 3.13) project(ayatana-ido C CXX) set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}") if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) SET(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "..." FORCE) endif(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # 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_COVERAGE) set(ENABLE_TESTS ON) set(CMAKE_BUILD_TYPE "Coverage") else() set(CMAKE_BUILD_TYPE "Release") endif() if(ENABLE_WERROR) add_definitions("-Werror") endif() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") add_definitions("-Weverything") else() add_definitions("-Wall") endif() # Thread fix for old CMake set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread") # Check for prerequisites set(DEPS glib-2.0>=2.58 gtk+-3.0>=3.24) find_package (PkgConfig REQUIRED) pkg_check_modules(PROJECT_DEPS REQUIRED ${DEPS}) # Set global variables include(GNUInstallDirs) set(PROJECT_VERSION "0.10.1") # Make everything add_subdirectory(src) add_subdirectory(data) if (ENABLE_TESTS) include(CTest) enable_testing() add_subdirectory(example) add_subdirectory(tests) # coverage if (ENABLE_COVERAGE) find_package(CoverageReport) ENABLE_COVERAGE_REPORT( TARGETS "ayatana-ido3-0.4" TESTS "gtest-menuitems" 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}")