project(settings-components) cmake_minimum_required(VERSION 2.8.9) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) # Install paths include(GNUInstallDirs) include(FindPkgConfig) find_package(Qt5Quick REQUIRED) set(OUR_QT_QUICK_LIB ${Qt5Quick_LIBRARIES}) get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION) exec_program(${QMAKE_EXECUTABLE} ARGS "-query QT_INSTALL_QML" OUTPUT_VARIABLE QT_IMPORTS_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) file(TO_CMAKE_PATH "${QT_IMPORTS_DIR}" QT_IMPORTS_DIR) set(OUR_QT_QUICK_INCLUDE ${Qt5Quick_INCLUDE_DIRS}) LIST(APPEND QT_PKGCONFIG_DEPENDENCIES "Qt5Quick") find_package(Qt5Core REQUIRED) find_package(Qt5Quick REQUIRED) find_package(Qt5Widgets REQUIRED) add_definitions(-DQT_NO_KEYWORDS) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) # enable QML debugging string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) # Build types should always be lowercase but sometimes they are not. if(cmake_build_type_lower MATCHES "debug") add_definitions(-DQT_QML_DEBUG) endif() include(EnableCoverageReport) ##################################################################### # Enable code coverage calculation with gcov/gcovr/lcov # Usage: # * Switch build type to coverage (use ccmake or cmake-gui) # * Invoke make, make test, make coverage (or ninja if you use that backend) # * Find html report in subdir coveragereport # * Find xml report feasible for jenkins in coverage.xml ##################################################################### if(cmake_build_type_lower MATCHES coverage) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage" ) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage" ) set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} --coverage" ) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage" ) ENABLE_COVERAGE_REPORT(TARGETS ${SHELL_APP} FILTER /usr/include ${CMAKE_SOURCE_DIR}/tests/* ${CMAKE_BINARY_DIR}/*) endif() configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake") # Doc OPTION(GENERATE_DOC "Enable qdoc generation" OFF) if(GENERATE_DOC) message(STATUS "QDoc enabled.") find_program(QDOC_BIN qdoc) if(NOT QDOC_BIN) message(FATAL_ERROR "qdoc command not found") else() add_subdirectory(doc) endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-permissive -pedantic -Wall -Wextra") if ("${CMAKE_BUILD_TYPE}" STREQUAL "release" OR "${CMAKE_BUILD_TYPE}" STREQUAL "relwithdebinfo") option(Werror "Treat warnings as errors" ON) else() option(Werror "Treat warnings as errors" OFF) endif() if (Werror) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") endif() file(GLOB_RECURSE QML_EXTRA_FILES ${CMAKE_SOURCE_DIR}/tests/*.qml ${CMAKE_SOURCE_DIR}/tests/*.js ${CMAKE_SOURCE_DIR}/tests/*.jpg ${CMAKE_SOURCE_DIR}/tests/*.png ${CMAKE_SOURCE_DIR}/tests/*.sci ${CMAKE_SOURCE_DIR}/tests/*.svg ) add_custom_target(qml_fake_target SOURCES ${QML_EXTRA_FILES}) # Tests enable_testing() add_subdirectory(plugins) add_subdirectory(examples) add_subdirectory(tests) add_subdirectory(po)