Warning, /plasma/qqc2-breeze-style/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 cmake_minimum_required(VERSION 3.16)
0002 
0003 #set(KF5_VERSION "5.75.0") # handled by release scripts
0004 set(KF5_DEP_VERSION "5.91.0") # handled by release scripts
0005 
0006 project(qqc2-breeze-style VERSION 1.0)
0007 
0008 # QT_VERSION >= 5.15.2 is required for Layout margins with working support for LayoutMirroring
0009 set(REQUIRED_QT_VERSION 5.15.0)
0010 
0011 ################# Disallow in-source build #################
0012 
0013 if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
0014    message(FATAL_ERROR "qqc2-breeze-style requires an out of source build. Please create a separate build directory and run 'cmake -S /path/to/qqc2-breeze-style' there.")
0015 endif()
0016 
0017 
0018 
0019 # Make CPack available to easy generate binary packages
0020 include(CPack)
0021 include(FeatureSummary)
0022 
0023 ################# set KDE specific information #################
0024 
0025 set(CMAKE_CXX_STANDARD 17)
0026 set(CMAKE_CXX_STANDARD_REQUIRED ON)
0027 
0028 find_package(ECM ${KF5_DEP_VERSION} REQUIRED NO_MODULE)
0029 
0030 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
0031 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH})
0032 
0033 include(ECMSetupVersion)
0034 include(ECMGenerateHeaders)
0035 include(KDEInstallDirs)
0036 include(KDECMakeSettings)
0037 set(KDE_COMPILERSETTINGS_LEVEL 5.84.0)
0038 include(KDECompilerSettings NO_POLICY_SCOPE)
0039 include(KDEClangFormat)
0040 include(KDEGitCommitHooks)
0041 include(ECMQmlModule)
0042 
0043 #TODO: Clean up dependencies. I was experimenting.
0044 find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE COMPONENTS Core Gui Qml Quick QuickControls2 QuickTemplates2)
0045 
0046 if (NOT ANDROID)
0047     find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS DBus)
0048     find_package(KF5IconThemes ${KF5_DEP_VERSION} REQUIRED)
0049 endif()
0050 
0051 find_package(KF5 ${KF5_DEP_VERSION} REQUIRED COMPONENTS GuiAddons Config Kirigami2 CoreAddons ConfigWidgets)
0052 
0053 if (NOT APPLE AND NOT WIN32)
0054     find_package(X11)
0055 endif()
0056 
0057 # When building as a static plugin, dependencies may add a -lQt5X11Extras
0058 # to the linker, in that case, it requires to have the proper variables
0059 # to exists.
0060 if(X11_FOUND AND NOT QT_MAJOR_VERSION EQUAL "5")
0061     find_package(Qt5X11Extras ${REQUIRED_QT_VERSION} NO_MODULE QUIET)
0062 endif()
0063 
0064 set_package_properties(IconThemes PROPERTIES DESCRIPTION "KF5 IconThemes framework"
0065                        TYPE OPTIONAL
0066                        PURPOSE "Optional integration of Kirigami with KIconLoader icons handling for a better integration with Plasma Desktop"
0067                       )
0068 set_package_properties(ConfigWidgets PROPERTIES DESCRIPTION "KF5 WidgetAddons framework"
0069                        TYPE OPTIONAL
0070                        PURPOSE "Optional integration of Kirigami with KColorScheme for color palettes integration with Plasma Desktop"
0071                       )
0072 
0073 find_package(PkgConfig)
0074 
0075 set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/KF5QQC2BreezeStyle")
0076 
0077 configure_package_config_file(
0078   "${CMAKE_CURRENT_SOURCE_DIR}/KF5QQC2BreezeStyleConfig.cmake.in"
0079   "${CMAKE_CURRENT_BINARY_DIR}/KF5QQC2BreezeStyleConfig.cmake"
0080   INSTALL_DESTINATION  ${CMAKECONFIG_INSTALL_DIR}
0081   PATH_VARS  KDE_INSTALL_INCLUDEDIR_KF CMAKE_INSTALL_PREFIX
0082 )
0083 
0084 install(FILES
0085   "${CMAKE_CURRENT_BINARY_DIR}/KF5QQC2BreezeStyleConfig.cmake"
0086   "${CMAKE_CURRENT_BINARY_DIR}/KF5QQC2BreezeStyleConfigVersion.cmake"
0087   DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
0088   COMPONENT Devel
0089 )
0090 
0091 
0092 ecm_setup_version(PROJECT
0093     VARIABLE_PREFIX QQC2BREEZESTYLE
0094     PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/KF5QQC2BreezeStyleConfigVersion.cmake"
0095     SOVERSION 5)
0096 
0097 #########################################################################
0098 add_definitions(-DQT_NO_FOREACH)
0099 add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x050d00)
0100 add_definitions(-DKF_DISABLE_DEPRECATED_BEFORE_AND_AT=0x054900)
0101 
0102 add_subdirectory(style)
0103 
0104 add_subdirectory(kirigami-plasmadesktop-integration)
0105 
0106 # FIXME: this assumes there will always be a QQC2 release for each Qt release, needs
0107 # something to discover what's the latest qqc2 version available
0108 # Since 5.12, QQC2 version is sync with Qt's minor version:
0109 # https://github.com/qt/qtquickcontrols2/commit/3c7bfc156797b2f3ef08a8cf620b79da80e4b061
0110 if (Qt5QuickControls2_VERSION_MINOR LESS 12)
0111     math(EXPR QQC2_VERSION_MINOR "${Qt5QuickControls2_VERSION_MINOR} - 7")
0112 else()
0113     set(QQC2_VERSION_MINOR "${Qt5QuickControls2_VERSION_MINOR}")
0114 endif()
0115 set(QQC2_VERSION "2.${QQC2_VERSION_MINOR}")
0116 
0117 if (QQC2_VERSION_MINOR LESS 3)
0118     set(DISABLE_UNDER_QQC2_2_3 "//Needs QtQuick.Controls 2.3 ")
0119 else()
0120     set(DISABLE_UNDER_QQC2_2_3 "")
0121 endif()
0122 
0123 if (QQC2_VERSION_MINOR LESS 4)
0124     set(DISABLE_UNDER_QQC2_2_4 "//Needs QtQuick.Controls 2.4 ")
0125 else()
0126     set(DISABLE_UNDER_QQC2_2_4 "")
0127 endif()
0128 
0129 if (Qt5Qml_VERSION_STRING VERSION_GREATER_EQUAL 5.14)
0130     set(DISABLE_UNDER_QT_5_14 "")
0131     set(DISABLE_AT_QT_5_14 "//Disabled since Qt 5.14 ")
0132 else()
0133     set(DISABLE_UNDER_QT_5_14 "//Needs Qt 5.14 ")
0134     set(DISABLE_AT_QT_5_14 "")
0135 endif()
0136 
0137 # TODO: Automate Kirigami version
0138 # This code doesn't work yet
0139 # set(KIRIGAMI_VERSION "2.${KF5_DEP_VERSION_MINOR}")
0140 
0141 # Find all the source qml files
0142 
0143 FILE(GLOB_RECURSE inFiles RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" "*.qml")
0144 
0145 #for each file, replace @QQC2_VERSION@ with the version we found
0146 FOREACH(infileName ${inFiles})
0147     configure_package_config_file(
0148         "${CMAKE_CURRENT_SOURCE_DIR}/${infileName}"
0149         "${CMAKE_CURRENT_BINARY_DIR}/${infileName}"
0150         INSTALL_DESTINATION  ${CMAKECONFIG_INSTALL_DIR}
0151         PATH_VARS  QQC2_VERSION DISABLE_UNDER_QQC2_2_3
0152         DISABLE_UNDER_QQC2_2_4
0153     )
0154 ENDFOREACH(infileName)
0155 
0156 # TODO: Automate Kirigami version
0157 # This code doesn't work yet
0158 #for each file, replace @KIRIGAMI_VERSION@ with the version we found
0159 #[[
0160 FOREACH(infileName ${inFiles})
0161     configure_package_config_file(
0162         "${CMAKE_CURRENT_SOURCE_DIR}/${infileName}"
0163         "${CMAKE_CURRENT_BINARY_DIR}/${infileName}"
0164         INSTALL_DESTINATION  ${CMAKECONFIG_INSTALL_DIR}
0165         PATH_VARS KIRIGAMI_VERSION
0166     )
0167 ENDFOREACH(infileName)
0168 ]]
0169 
0170 feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
0171 
0172 # add clang-format target for all our real source files
0173 file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
0174 kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
0175 kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)