CMakeLists.txt 3.76 KB
Newer Older
1
cmake_minimum_required(VERSION 3.0)
2

3
project(libkscreen)
4
set(PROJECT_VERSION "5.21.80")
5

6
set(QT_MIN_VERSION "5.15.0")
7
set(KF5_MIN_VERSION "5.78")
8

Nicolas Fella's avatar
Nicolas Fella committed
9
10
11
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

12
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
13
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
14
include(KDEInstallDirs)
15
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
16
17
include(KDECMakeSettings)
include(ECMSetupVersion)
Àlex Fiestas's avatar
Àlex Fiestas committed
18
include(ECMMarkAsTest)
19
include(ECMGenerateHeaders)
20
include(ECMQtDeclareLoggingCategory)
21
include(ECMAddQch)
22
include(FeatureSummary)
23
include(CheckCXXCompilerFlag)
24
include(CMakePackageConfigHelpers)
25
include(GenerateExportHeader)
26
include(KDEClangFormat)
27
28
29
if(ECM_VERSION VERSION_GREATER_EQUAL 5.79)
    include(KDEGitCommitHooks)
endif()
30

31
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core DBus Gui Test X11Extras)
32

Sebastian Kügler's avatar
Sebastian Kügler committed
33
# Wayland backend
34
find_package(KF5Wayland ${KF5_MIN_VERSION} CONFIG REQUIRED)
35
add_feature_info("KF5Wayland" KF5Wayland_FOUND "Required for building libkscreen's KWayland backend")
36

Sebastian Kügler's avatar
Sebastian Kügler committed
37
38
# xrandr backend

39
40
find_package(XCB COMPONENTS XCB RANDR)
set_package_properties(XCB PROPERTIES
41
                       TYPE OPTIONAL
42
                       PURPOSE "Required for building XRandR backends"
43
44
)

45
46
47
option(BUILD_QCH "Build API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)" OFF)
add_feature_info(QCH ${BUILD_QCH} "API documentation in QCH format (for e.g. Qt Assistant, Qt Creator & KDevelop)")

Frederik Gladhorn's avatar
Frederik Gladhorn committed
48

49
ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX KSCREEN
50
                        VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kscreen_version.h"
51
                        PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5ScreenConfigVersion.cmake"
Sebastian Kügler's avatar
Sebastian Kügler committed
52
                        SOVERSION 7)
Daniel Vrátil's avatar
Daniel Vrátil committed
53

54
55
56
57
58
59
60
61
62
63
64
check_cxx_compiler_flag(-fvisibility=hidden _HAVE_VISIBILITY)
if (_HAVE_VISIBILITY AND NOT WIN32)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden")

  check_cxx_compiler_flag(-fvisibility-inlines-hidden _HAVE_VISIBILITY_INLINES)
  if (_HAVE_VISIBILITY_INLINES)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility-inlines-hidden")
  endif (_HAVE_VISIBILITY_INLINES)
endif (_HAVE_VISIBILITY AND NOT WIN32)

add_subdirectory(src)
Àlex Fiestas's avatar
Àlex Fiestas committed
65
add_subdirectory(backends)
66
67
68
69
if(BUILD_TESTING)
   add_subdirectory(autotests)
   add_subdirectory(tests)
endif()
70

71
set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KF5Screen")
72

73
74
75
# add clang-format target for all our real source files
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
76
77
78
79
if(ECM_VERSION VERSION_GREATER_EQUAL 5.79)
    kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
endif()

80

81
82
83
84
85
86
87
88
89
90
if (BUILD_QCH)
    ecm_install_qch_export(
        TARGETS KF5Screen_QCH
        FILE KF5ScreenQchTargets.cmake
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
        COMPONENT Devel
    )
    set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5ScreenQchTargets.cmake\")")
endif()

91
configure_package_config_file("${CMAKE_CURRENT_SOURCE_DIR}/KF5ScreenConfig.cmake.in"
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
                              "${CMAKE_CURRENT_BINARY_DIR}/KF5ScreenConfig.cmake"
                              INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR}
)

install(FILES
  "${CMAKE_CURRENT_BINARY_DIR}/KF5ScreenConfig.cmake"
  "${CMAKE_CURRENT_BINARY_DIR}/KF5ScreenConfigVersion.cmake"
  DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
  COMPONENT Devel
)

install(EXPORT
  KF5ScreenTargets
  DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
  FILE KF5ScreenTargets.cmake
  NAMESPACE KF5::
  COMPONENT Devel
)

install(FILES
  "${CMAKE_CURRENT_BINARY_DIR}/kscreen_version.h"
  DESTINATION "${KF5_INCLUDE_INSTALL_DIR}"
  COMPONENT Devel
115
)
Laurent Montel's avatar
Laurent Montel committed
116
install(FILES libkscreen.categories  DESTINATION  ${KDE_INSTALL_LOGGINGCATEGORIESDIR})
117

118

119
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)