CMakeLists.txt 4.57 KB
Newer Older
1
cmake_minimum_required(VERSION 3.5)
2

3
set(KF5_VERSION "5.75.0") # handled by release scripts
4
set(KF5_DEP_VERSION "5.75.0") # handled by release scripts
5
project(KXmlGui VERSION ${KF5_VERSION})
6 7

# ECM setup
8
include(FeatureSummary)
9
find_package(ECM 5.75.0  NO_MODULE)
10
set_package_properties(ECM PROPERTIES TYPE REQUIRED DESCRIPTION "Extra CMake Modules." URL "https://commits.kde.org/extra-cmake-modules")
11 12
feature_summary(WHAT REQUIRED_PACKAGES_NOT_FOUND FATAL_ON_MISSING_REQUIRED_PACKAGES)

13

14
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH})
15 16 17

include(ECMMarkNonGuiExecutable)
include(ECMSetupVersion)
David Faure's avatar
David Faure committed
18
include(ECMGenerateHeaders)
19
include(ECMAddQch)
20
include(ECMGenerateExportHeader)
21

22
include(KDEInstallDirs)
23
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
24
include(KDECMakeSettings)
25
include(ECMQtDeclareLoggingCategory)
26

27
ecm_setup_version(PROJECT
28 29
                  VARIABLE_PREFIX KXMLGUI
                  VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/kxmlgui_version.h"
Jonathan Riddell's avatar
Jonathan Riddell committed
30 31
                  PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5XmlGuiConfigVersion.cmake"
                  SOVERSION 5)
32

33 34
set(EXCLUDE_DEPRECATED_BEFORE_AND_AT 0 CACHE STRING "Control the range of deprecated API excluded from the build [default=0].")

35
option(FORCE_DISABLE_KGLOBALACCEL "Force building KXmlGui without KGlobalAccel. Doing this will break global shortcut support. [default=OFF]" OFF)
36 37
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)")
38

39 40 41
option(BUILD_DESIGNERPLUGIN "Build plugin for Qt Designer" ON)
add_feature_info(DESIGNERPLUGIN ${BUILD_DESIGNERPLUGIN} "Build plugin for Qt Designer")

42
# Dependencies
43
set(REQUIRED_QT_VERSION 5.12.0)
Volker Krause's avatar
Volker Krause committed
44 45 46 47
find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED Widgets Xml Network PrintSupport)
if (NOT ANDROID)
  find_package(Qt5 ${REQUIRED_QT_VERSION} CONFIG REQUIRED DBus)
endif()
48

49
find_package(KF5CoreAddons ${KF5_DEP_VERSION} REQUIRED)
50 51 52 53 54 55 56 57
find_package(KF5ItemViews ${KF5_DEP_VERSION} REQUIRED)
find_package(KF5Config ${KF5_DEP_VERSION} REQUIRED)
find_package(KF5ConfigWidgets ${KF5_DEP_VERSION} REQUIRED)
find_package(KF5I18n ${KF5_DEP_VERSION} REQUIRED)
find_package(KF5IconThemes ${KF5_DEP_VERSION} REQUIRED)
find_package(KF5WidgetsAddons ${KF5_DEP_VERSION} REQUIRED)
find_package(KF5WindowSystem ${KF5_DEP_VERSION} REQUIRED)
find_package(KF5Attica ${KF5_DEP_VERSION})
Hrvoje Senjan's avatar
Hrvoje Senjan committed
58
set_package_properties(KF5Attica PROPERTIES DESCRIPTION "A Qt library that implements the Open Collaboration Services API"
59
                       PURPOSE "Support for Get Hot New Stuff in KXMLGUI"
60
                       URL "https://commits.kde.org/attica"
61 62
                       TYPE OPTIONAL
                      )
Hrvoje Senjan's avatar
Hrvoje Senjan committed
63
set (HAVE_ATTICA ${KF5Attica_FOUND})
64

65 66 67 68
if (NOT FORCE_DISABLE_KGLOBALACCEL)
    find_package(KF5GlobalAccel ${KF5_DEP_VERSION} REQUIRED)
endif()
set (HAVE_GLOBALACCEL ${KF5GlobalAccel_FOUND})
69
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00)
70
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054900)
Aurélien Gâteau's avatar
Aurélien Gâteau committed
71
add_definitions(-DTRANSLATION_DOMAIN=\"kxmlgui5\")
Nicolas Fella's avatar
Nicolas Fella committed
72
add_definitions(-DQT_NO_FOREACH)
73 74 75
if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po")
    ki18n_install(po)
endif()
76

77
# Subdirectories
78
add_subdirectory(src)
Antonio Rojas's avatar
Antonio Rojas committed
79 80 81 82
if (BUILD_TESTING)
    add_subdirectory(tests)
    add_subdirectory(autotests)
endif()
83 84

# create a Config.cmake and a ConfigVersion.cmake file and install them
Alex Merry's avatar
Alex Merry committed
85
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5XmlGui")
86

87 88 89 90 91 92 93 94 95 96
if (BUILD_QCH)
    ecm_install_qch_export(
        TARGETS KF5XmlGui_QCH
        FILE KF5XmlGuiQchTargets.cmake
        DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
        COMPONENT Devel
    )
    set(PACKAGE_INCLUDE_QCHTARGETS "include(\"\${CMAKE_CURRENT_LIST_DIR}/KF5XmlGuiQchTargets.cmake\")")
endif()

97
include(CMakePackageConfigHelpers)
98

Volker Krause's avatar
Volker Krause committed
99 100 101 102
set(HAVE_DBUS FALSE)
if (TARGET Qt5::DBus)
  set(HAVE_DBUS TRUE)
endif()
103
configure_package_config_file(
104 105
  "${CMAKE_CURRENT_SOURCE_DIR}/KF5XmlGuiConfig.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/KF5XmlGuiConfig.cmake"
106
  PATH_VARS KDE_INSTALL_DBUSINTERFACEDIR
107 108 109 110 111 112 113 114 115 116 117 118 119 120
  INSTALL_DESTINATION  ${CMAKECONFIG_INSTALL_DIR}
)

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

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

install(FILES
   ${CMAKE_CURRENT_BINARY_DIR}/kxmlgui_version.h
Alex Merry's avatar
Alex Merry committed
121
  DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5} COMPONENT Devel
122 123
)

124
feature_summary(WHAT ALL   FATAL_ON_MISSING_REQUIRED_PACKAGES)