Warning, /maui/mauikit/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 # SPDX-FileCopyrightText: 2020 Camilo Higuita <milo.h@aol.com> 0002 # 0003 # SPDX-License-Identifier: GPL-3.0-or-later 0004 0005 cmake_minimum_required(VERSION 3.16) 0006 0007 option(BUILD_WITH_QT5 "Use Qt 5" OFF) 0008 option(BUILD_WITH_QT6 "Use Qt 6" OFF) 0009 0010 if(BUILD_WITH_QT5) 0011 set(QT_MAJOR_VERSION 5) 0012 elseif(BUILD_WITH_QT6) 0013 set(QT_MAJOR_VERSION 6) 0014 else() 0015 set(QT_MAJOR_VERSION 5) 0016 endif() 0017 0018 if (QT_MAJOR_VERSION STREQUAL "6") 0019 option(BUILD_SHARED_LIBS "Build a shared module" ON) 0020 set(REQUIRED_QT_VERSION 6.4) 0021 set(REQUIRED_KF_VERSION 5.240.0) 0022 set(KF_MAJOR_VERSION 6) 0023 set(MAUI_MAJOR_VERSION 4) 0024 set(MAUIKIT_VERSION 4.0.0) 0025 else() 0026 set(REQUIRED_QT_VERSION 5.15.2) 0027 set(REQUIRED_KF_VERSION 5.95.0) 0028 set(KF_MAJOR_VERSION 5) 0029 set(MAUI_MAJOR_VERSION 3) 0030 set(MAUIKIT_VERSION 3.1.0) 0031 endif() 0032 0033 set(CMAKE_CXX_STANDARD 17) 0034 set(CMAKE_CXX_STANDARD_REQUIRED ON) 0035 0036 set(CMAKE_INCLUDE_CURRENT_DIR ON) 0037 set(CMAKE_AUTOMOC ON) 0038 set(CMAKE_AUTORCC ON) 0039 0040 set(MAUIKIT_URI org.mauikit.controls) 0041 0042 set(AUTOMOC_MOC_OPTIONS -Muri=${MAUIKIT_URI}) 0043 0044 project(mauikit VERSION ${MAUIKIT_VERSION}) 0045 0046 ################# Disallow in-source build ################# 0047 0048 # if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}") 0049 # message(FATAL_ERROR "MauiKit requires an out of source build. Please create a separate build directory and run 'cmake path_to_mauikit [options]' there.") 0050 # endif() 0051 0052 if(ANDROID) 0053 set(ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/platforms/android) 0054 set(ANDROID_ABIS "armeabi-v7a") 0055 endif() 0056 0057 find_package(ECM ${REQUIRED_KF_VERSION} NO_MODULE) 0058 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${ECM_MODULE_PATH}) 0059 0060 #DEFAULT COMPONENTS DEFINITIONS 0061 include(GenerateExportHeader) 0062 include(CMakePackageConfigHelpers) 0063 0064 include(ECMSetupVersion) 0065 include(ECMGenerateHeaders) 0066 include(ECMFindQmlModule) 0067 include(ECMQmlModule) 0068 include(ECMGenerateQmlTypes) 0069 include(ECMSourceVersionControl) 0070 0071 include(KDEClangFormat) 0072 include(KDEInstallDirs) 0073 include(KDECMakeSettings) 0074 0075 option(QUICK_COMPILER "Use QtQuick compiler to improve performance. QML sources won't be installed in the file system." ON) 0076 0077 ##option to be removed in qt6 migration 0078 if (QT_MAJOR_VERSION STREQUAL "5") 0079 option(QUICK_COMPILER ON) 0080 if(ANDROID OR WIN32 OR APPLE) 0081 set(QUICK_COMPILER ON) 0082 set(BUNDLE_LUV_ICONS ON) 0083 endif() 0084 else() 0085 option(QUICK_COMPILER OFF) 0086 endif() 0087 0088 option(BUILD_DEMO "Build the MauiKit Demo application." OFF) 0089 option(BUNDLE_LUV_ICONS "Ship Luv icon bundled." OFF) 0090 0091 find_package(Qt${QT_MAJOR_VERSION} ${REQUIRED_QT_VERSION} REQUIRED COMPONENTS 0092 Core 0093 Concurrent 0094 Qml 0095 Quick 0096 QuickControls2 0097 Svg 0098 Widgets) 0099 0100 find_package(KF${KF_MAJOR_VERSION} ${REQUIRED_KF_VERSION} REQUIRED COMPONENTS 0101 I18n 0102 CoreAddons 0103 Notifications) 0104 0105 find_package(MauiMan${MAUI_MAJOR_VERSION} ${MAUIKIT_VERSION} REQUIRED) 0106 set_package_properties(MauiMan${MAUI_MAJOR_VERSION} PROPERTIES 0107 TYPE REQUIRED 0108 DESCRIPTION "MauiMan is a server and API for syncing global system setting preferences." 0109 URL "https://invent.kde.org/maui/mauiman" 0110 PURPOSE "Sync to system setting preferences.") 0111 0112 # find_package(OpenMP) 0113 #set_package_properties(OpenMP 0114 # PROPERTIES DESCRIPTION "Multi-platform shared-memory parallel programming in C/C++ and Fortran" 0115 # TYPE OPTIONAL 0116 # PURPOSE "Accelerates palette generation in Kirigami.ImageColors" 0117 #) 0118 #if(OpenMP_CXX_FOUND) 0119 # set(HAVE_OpenMP TRUE) 0120 # set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") 0121 #endif() 0122 0123 #include_directories("${CMAKE_CURRENT_BINARY_DIR}") 0124 #configure_file(config-OpenMP.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-OpenMP.h) 0125 0126 if (QT_MAJOR_VERSION STREQUAL "5") 0127 ecm_find_qmlmodule(QtQuick.Shapes 1.0) 0128 else() 0129 ecm_find_qmlmodule(QtQuick.Shapes 1.0) 0130 ecm_find_qmlmodule(Qt5Compat.GraphicalEffects 6.0) 0131 endif() 0132 0133 #if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 0134 # # link time optimization has been observed to break colors. Force-disable it. 0135 # # Before undoing this make double sure the lockscreen 0136 # # and logout screen are correctly colored in light/dark mode! 0137 # add_compile_options("-fno-lto") 0138 #endif() 0139 0140 if(ANDROID) 0141 find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS AndroidExtras) 0142 find_package(Gradle REQUIRED) 0143 elseif(UNIX AND NOT ANDROID) 0144 if(NOT APPLE) 0145 # Do not find X11 on macOS 0146 if (QT_MAJOR_VERSION STREQUAL "5") 0147 find_package(Qt5 REQUIRED COMPONENTS X11Extras) 0148 endif() 0149 find_package(KF${KF_MAJOR_VERSION} REQUIRED COMPONENTS WindowSystem) 0150 0151 find_package(XCB 1.10 REQUIRED COMPONENTS 0152 ICCCM 0153 SHAPE 0154 XCB) 0155 set_package_properties(XCB PROPERTIES TYPE REQUIRED) 0156 endif() 0157 endif() 0158 0159 if (QT_MAJOR_VERSION STREQUAL "5") 0160 if(QUICK_COMPILER) 0161 find_package(Qt5QuickCompiler) 0162 set_package_properties(Qt5QuickCompiler PROPERTIES 0163 DESCRIPTION "Compile QML at build time" 0164 TYPE OPTIONAL) 0165 endif() 0166 endif() 0167 0168 if(${ECM_SOURCE_UNDER_VERSION_CONTROL}) 0169 execute_process( 0170 COMMAND git rev-parse --abbrev-ref HEAD 0171 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 0172 OUTPUT_VARIABLE GIT_BRANCH 0173 OUTPUT_STRIP_TRAILING_WHITESPACE) 0174 0175 # Get the latest abbreviated commit hash of the working branch 0176 execute_process( 0177 COMMAND git log -1 --format=%h 0178 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} 0179 OUTPUT_VARIABLE GIT_COMMIT_HASH 0180 OUTPUT_STRIP_TRAILING_WHITESPACE) 0181 0182 add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}") 0183 add_definitions(-DGIT_BRANCH="${GIT_BRANCH}") 0184 else() 0185 add_definitions(-DGIT_COMMIT_HASH="${PROJECT_VERSION}") 0186 add_definitions(-DGIT_BRANCH="Stable") 0187 endif() 0188 0189 ##CMAKE PARTS 0190 set(CMAKECONFIG_INSTALL_DIR "${KDE_INSTALL_CMAKEPACKAGEDIR}/MauiKit${MAUI_MAJOR_VERSION}") 0191 0192 ecm_setup_version(${MAUIKIT_VERSION} 0193 VARIABLE_PREFIX MAUIKIT 0194 VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/mauikit_version.h" 0195 PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/MauiKit${MAUI_MAJOR_VERSION}ConfigVersion.cmake" 0196 SOVERSION ${PROJECT_VERSION_MAJOR}) 0197 0198 configure_package_config_file( 0199 "${CMAKE_CURRENT_SOURCE_DIR}/MauiKitConfig.cmake.in.${QT_MAJOR_VERSION}" 0200 "${CMAKE_CURRENT_BINARY_DIR}/MauiKit${MAUI_MAJOR_VERSION}Config.cmake" 0201 INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR} 0202 PATH_VARS CMAKE_INSTALL_PREFIX) 0203 0204 install(FILES 0205 "${CMAKE_CURRENT_BINARY_DIR}/MauiKit${MAUI_MAJOR_VERSION}Config.cmake" 0206 "${CMAKE_CURRENT_BINARY_DIR}/MauiKit${MAUI_MAJOR_VERSION}ConfigVersion.cmake" 0207 DESTINATION "${CMAKECONFIG_INSTALL_DIR}" 0208 COMPONENT Devel) 0209 0210 install(EXPORT MauiKit${MAUI_MAJOR_VERSION}Targets 0211 DESTINATION "${CMAKECONFIG_INSTALL_DIR}" 0212 FILE MauiKit${MAUI_MAJOR_VERSION}Targets.cmake) 0213 0214 ##Translations stuff with KI18n 0215 add_definitions(-DTRANSLATION_DOMAIN="mauikit") 0216 if(${QT_MAJOR_VERSION} STREQUAL 5) ##for now skip installing translations for mauikit4 to avoid packaging conflicts with translation files 0217 ki18n_install(po) 0218 endif() 0219 0220 add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) 0221 0222 add_subdirectory(src) 0223 0224 if(${QT_MAJOR_VERSION} STREQUAL 6) 0225 if(BUILD_DEMO) 0226 add_subdirectory(demo.6) ##Fails to build while trying to link to MauiKit4 - maybe is it better to move it out to its own project? 0227 endif() 0228 endif() 0229 0230 ##Clang formatting 0231 file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h) 0232 kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES}) 0233 0234 feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)