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

3
set(KF5_VERSION "5.70.0") # handled by release scripts
4
set(KF5_DEP_VERSION "5.69.0") # handled by release scripts
5

6 7
project(qqc2-desktop-style VERSION ${KF5_VERSION})

8
set(REQUIRED_QT_VERSION 5.12.0)
Marco Martin's avatar
Marco Martin committed
9 10 11 12

################# Disallow in-source build #################

if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
Marco Martin's avatar
Marco Martin committed
13
   message(FATAL_ERROR "qqc2-desktop-style requires an out of source build. Please create a separate build directory and run 'cmake path_to_qqc2-desktop-style [options]' there.")
Marco Martin's avatar
Marco Martin committed
14 15 16 17 18 19 20 21 22 23
endif()



# Make CPack available to easy generate binary packages
include(CPack)
include(FeatureSummary)

################# set KDE specific information #################

24
find_package(ECM 5.69.0 REQUIRED NO_MODULE)
Marco Martin's avatar
Marco Martin committed
25 26

# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
27
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
Marco Martin's avatar
Marco Martin committed
28 29 30 31 32

include(ECMSetupVersion)
include(ECMGenerateHeaders)
include(KDEInstallDirs)
include(KDECMakeSettings)
33
include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
Marco Martin's avatar
Marco Martin committed
34

35
find_package(Qt5 ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Core Quick Gui Widgets QuickControls2)
Marco Martin's avatar
Marco Martin committed
36

Alexey Min's avatar
Alexey Min committed
37
find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS Config Kirigami2)
Marco Martin's avatar
Marco Martin committed
38

Alexey Min's avatar
Alexey Min committed
39 40 41
# IconThemes and ConfigWidgets are optional
find_package(KF5IconThemes ${KF5_DEP_VERSION})
find_package(KF5ConfigWidgets ${KF5_DEP_VERSION})
42 43 44 45 46 47 48 49 50 51 52 53

if (NOT APPLE AND NOT WIN32)
    find_package(X11)
endif()

# When building as a static plugin, dependencies may add a -lQt5X11Extras
# to the linker, in that case, it requires to have the proper variables
# to exists.
if(X11_FOUND)
    find_package(Qt5X11Extras ${REQUIRED_QT_VERSION} NO_MODULE QUIET)
endif()

Marco Martin's avatar
Marco Martin committed
54 55 56 57 58 59 60 61 62
set_package_properties(IconThemes PROPERTIES DESCRIPTION "KF5 IconThemes framework"
                       TYPE OPTIONAL
                       PURPOSE "Optional integration of Kirigami with KIconLoader icons handling for a better integration with Plasma Desktop"
                      )
set_package_properties(ConfigWidgets PROPERTIES DESCRIPTION "KF5 WidgetAddons framework"
                       TYPE OPTIONAL
                       PURPOSE "Optional integration of Kirigami with KColorScheme for color palettes integration with Plasma Desktop"
                      )

Marco Martin's avatar
Marco Martin committed
63
find_package(PkgConfig)
64

65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5QQC2DesktopStyle")

configure_package_config_file(
  "${CMAKE_CURRENT_SOURCE_DIR}/KF5QQC2DesktopStyleConfig.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/KF5QQC2DesktopStyleConfig.cmake"
  INSTALL_DESTINATION  ${CMAKECONFIG_INSTALL_DIR}
  PATH_VARS  KF5_INCLUDE_INSTALL_DIR CMAKE_INSTALL_PREFIX
)

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


ecm_setup_version(PROJECT
    VARIABLE_PREFIX QQC2DESKTOPSTYLE
    PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5QQC2DesktopStyleConfigVersion.cmake"
    SOVERSION 5)

# legacy support for CMake Config files with typo KF5QQC2Desk_opStyle TODO: KF6 remove
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5QQC2DeskopStyle")

configure_package_config_file(
  "${CMAKE_CURRENT_SOURCE_DIR}/KF5QQC2DeskopStyleConfig.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/KF5QQC2DeskopStyleConfig.cmake"
  INSTALL_DESTINATION  ${CMAKECONFIG_INSTALL_DIR}
  PATH_VARS  KF5_INCLUDE_INSTALL_DIR CMAKE_INSTALL_PREFIX
)

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


105
ecm_setup_version(PROJECT
106 107 108 109
    VARIABLE_PREFIX QQC2DESKTOPSTYLE
    PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5QQC2DeskopStyleConfigVersion.cmake"
    SOVERSION 5)

Marco Martin's avatar
Marco Martin committed
110
#########################################################################
111
add_definitions(-DQT_NO_FOREACH)
112
add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00)
113
add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054400)
Marco Martin's avatar
Marco Martin committed
114 115
add_subdirectory(plugin)

Marco Martin's avatar
Marco Martin committed
116 117 118 119
if (KF5IconThemes_FOUND AND KF5WidgetsAddons_FOUND)
add_subdirectory(kirigami-plasmadesktop-integration)
endif(KF5IconThemes_FOUND AND KF5WidgetsAddons_FOUND)

120 121 122 123 124 125 126 127 128
# FIXME: this assumes there will always be a QQC2 release for each Qt release, needs
# something to discover what's the latest qqc2 version available
# Since 5.12, QQC2 version is sync with Qt's minor version:
# https://github.com/qt/qtquickcontrols2/commit/3c7bfc156797b2f3ef08a8cf620b79da80e4b061
if (Qt5QuickControls2_VERSION_MINOR LESS 12)
    math(EXPR QQC2_VERSION_MINOR "${Qt5QuickControls2_VERSION_MINOR} - 7")
else()
    set(QQC2_VERSION_MINOR "${Qt5QuickControls2_VERSION_MINOR}")
endif()
Marco Martin's avatar
Marco Martin committed
129 130 131 132 133 134 135
set(QQC2_VERSION "2.${QQC2_VERSION_MINOR}")

if (QQC2_VERSION_MINOR LESS 3)
    set(DISABLE_UNDER_QQC2_2_3 "//Needs QtQuick.Controls 2.3 ")
else()
    set(DISABLE_UNDER_QQC2_2_3 "")
endif()
136

137 138 139 140 141 142
if (QQC2_VERSION_MINOR LESS 4)
    set(DISABLE_UNDER_QQC2_2_4 "//Needs QtQuick.Controls 2.4 ")
else()
    set(DISABLE_UNDER_QQC2_2_4 "")
endif()

143 144 145 146 147 148 149 150 151 152
# Find all the source qml files
FILE(GLOB_RECURSE inFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}"
    "${CMAKE_CURRENT_SOURCE_DIR}/org.kde.desktop/*")

    #for each file, replace @QQC2_VERSION@ with the version we found
FOREACH(infileName ${inFiles})
    configure_package_config_file(
        "${CMAKE_CURRENT_SOURCE_DIR}/${infileName}"
        "${CMAKE_CURRENT_BINARY_DIR}/${infileName}"
        INSTALL_DESTINATION  ${CMAKECONFIG_INSTALL_DIR}
Marco Martin's avatar
Marco Martin committed
153
        PATH_VARS  QQC2_VERSION DISABLE_UNDER_QQC2_2_3
154
        DISABLE_UNDER_QQC2_2_4
155 156 157 158
    )
ENDFOREACH(infileName)

install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/org.kde.desktop DESTINATION ${KDE_INSTALL_QMLDIR}/QtQuick/Controls.2)
Marco Martin's avatar
Marco Martin committed
159 160 161

feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)