| 1 |
cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR) |
| 2 |
|
| 3 |
# meta data |
| 4 |
set(META_PROJECT_NAME qtutilities) |
| 5 |
set(META_PROJECT_VARNAME QT_UTILITIES) |
| 6 |
set(META_APP_NAME "Qt Utilities") |
| 7 |
set(META_APP_AUTHOR "Martchus") |
| 8 |
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}") |
| 9 |
set(META_APP_DESCRIPTION |
| 10 |
"Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models") |
| 11 |
set(META_VERSION_MAJOR 6) |
| 12 |
set(META_VERSION_MINOR 21) |
| 13 |
set(META_VERSION_PATCH 0) |
| 14 |
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH}) |
| 15 |
set(META_GUI_OPTIONAL ON) |
| 16 |
|
| 17 |
# link explicitly against Qt Gui |
| 18 |
list(APPEND ADDITIONAL_QT_MODULES Gui) |
| 19 |
|
| 20 |
project(${META_PROJECT_NAME}) |
| 21 |
|
| 22 |
# add project files |
| 23 |
set(HEADER_FILES |
| 24 |
misc/xmlparsermacros.h |
| 25 |
misc/undefxmlparsermacros.h |
| 26 |
misc/trylocker.h |
| 27 |
misc/adoptlocker.h |
| 28 |
misc/dialogutils.h |
| 29 |
misc/disablewarningsmoc.h |
| 30 |
misc/desktoputils.h |
| 31 |
misc/conversion.h |
| 32 |
misc/compat.h |
| 33 |
settingsdialog/qtsettings.h |
| 34 |
setup/updater.h |
| 35 |
models/checklistmodel.h |
| 36 |
resources/qtconfigarguments.h |
| 37 |
resources/resources.h |
| 38 |
resources/importplugin.h) |
| 39 |
set(SRC_FILES |
| 40 |
misc/dialogutils.cpp |
| 41 |
misc/desktoputils.cpp |
| 42 |
settingsdialog/qtsettings.cpp |
| 43 |
setup/updater.cpp |
| 44 |
models/checklistmodel.cpp |
| 45 |
resources/qtconfigarguments.cpp |
| 46 |
resources/resources.cpp) |
| 47 |
set(RES_FILES resources/qtutilsicons.qrc) |
| 48 |
|
| 49 |
set(WIDGETS_HEADER_FILES |
| 50 |
aboutdialog/aboutdialog.h |
| 51 |
enterpassworddialog/enterpassworddialog.h |
| 52 |
settingsdialog/optioncategory.h |
| 53 |
settingsdialog/optioncategoryfiltermodel.h |
| 54 |
settingsdialog/optioncategorymodel.h |
| 55 |
settingsdialog/optionpage.h |
| 56 |
settingsdialog/settingsdialog.h |
| 57 |
widgets/buttonoverlay.h |
| 58 |
widgets/clearcombobox.h |
| 59 |
widgets/clearlineedit.h |
| 60 |
widgets/clearplaintextedit.h |
| 61 |
widgets/clearspinbox.h |
| 62 |
widgets/iconbutton.h |
| 63 |
widgets/pathselection.h |
| 64 |
paletteeditor/paletteeditor.h |
| 65 |
paletteeditor/colorbutton.h |
| 66 |
misc/recentmenumanager.h) |
| 67 |
set(WIDGETS_SRC_FILES |
| 68 |
aboutdialog/aboutdialog.cpp |
| 69 |
enterpassworddialog/enterpassworddialog.cpp |
| 70 |
settingsdialog/optioncategory.cpp |
| 71 |
settingsdialog/optioncategoryfiltermodel.cpp |
| 72 |
settingsdialog/optioncategorymodel.cpp |
| 73 |
settingsdialog/optionpage.cpp |
| 74 |
settingsdialog/settingsdialog.cpp |
| 75 |
widgets/buttonoverlay.cpp |
| 76 |
widgets/clearcombobox.cpp |
| 77 |
widgets/clearlineedit.cpp |
| 78 |
widgets/clearplaintextedit.cpp |
| 79 |
widgets/clearspinbox.cpp |
| 80 |
widgets/iconbutton.cpp |
| 81 |
widgets/pathselection.cpp |
| 82 |
paletteeditor/paletteeditor.cpp |
| 83 |
paletteeditor/colorbutton.cpp |
| 84 |
misc/recentmenumanager.cpp) |
| 85 |
set(WIDGETS_UI_FILES |
| 86 |
aboutdialog/aboutdialog.ui |
| 87 |
enterpassworddialog/enterpassworddialog.ui |
| 88 |
settingsdialog/settingsdialog.ui |
| 89 |
settingsdialog/qtappearanceoptionpage.ui |
| 90 |
settingsdialog/qtlanguageoptionpage.ui |
| 91 |
settingsdialog/qtenvoptionpage.ui |
| 92 |
paletteeditor/paletteeditor.ui) |
| 93 |
set(QT_TESTS) |
| 94 |
set(CMAKE_MODULE_FILES cmake/modules/QtConfig.cmake cmake/modules/QtGuiConfig.cmake cmake/modules/QtLinkage.cmake |
| 95 |
cmake/modules/QtWebViewProviderConfig.cmake cmake/modules/QtJsProviderConfig.cmake) |
| 96 |
set(CMAKE_TEMPLATE_FILES cmake/templates/qtconfig.h.in cmake/templates/webviewdefs.h.in cmake/templates/webviewincludes.h.in |
| 97 |
cmake/templates/jsdefs.h.in cmake/templates/jsincludes.h.in) |
| 98 |
|
| 99 |
set(TS_FILES |
| 100 |
translations/${META_PROJECT_NAME}_zh_CN.ts translations/${META_PROJECT_NAME}_de_DE.ts |
| 101 |
translations/${META_PROJECT_NAME}_ru_RU.ts translations/${META_PROJECT_NAME}_ja_JP.ts |
| 102 |
translations/${META_PROJECT_NAME}_en_US.ts) |
| 103 |
|
| 104 |
set(DOC_FILES README.md) |
| 105 |
|
| 106 |
set(REQUIRED_ICONS |
| 107 |
dialog-cancel |
| 108 |
dialog-ok |
| 109 |
dialog-ok-apply |
| 110 |
document-open |
| 111 |
document-open-recent |
| 112 |
edit-clear |
| 113 |
go-next |
| 114 |
preferences-desktop-icons |
| 115 |
preferences-desktop-locale |
| 116 |
qtcreator |
| 117 |
system-file-manager |
| 118 |
system-run |
| 119 |
system-search |
| 120 |
window-close) |
| 121 |
|
| 122 |
set(SCRIPT_FILES scripts/required_icons.sh) |
| 123 |
|
| 124 |
# required to include CMake modules from own project directory |
| 125 |
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_MODULE_PATH}") |
| 126 |
|
| 127 |
# configure whether setup tools are enabled |
| 128 |
option( |
| 129 |
SETUP_TOOLS |
| 130 |
"enables setup tools; needs c++utilities built with USE_LIBARCHIVE option; makes likely sense to disable when distributing via a package" |
| 131 |
OFF) |
| 132 |
|
| 133 |
# find c++utilities |
| 134 |
set(CPP_UTILITIES_REQUIRED_VERSION 5.5.0) |
| 135 |
if (SETUP_TOOLS) |
| 136 |
set(CPP_UTILITIES_REQUIRED_VERSION 5.26.0) |
| 137 |
endif () |
| 138 |
set(CONFIGURATION_PACKAGE_SUFFIX |
| 139 |
"" |
| 140 |
CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities") |
| 141 |
set(PACKAGE_NAMESPACE |
| 142 |
"" |
| 143 |
CACHE STRING "sets the namespace (prefix) for find_package() calls to packages configured via c++utilities") |
| 144 |
if (PACKAGE_NAMESPACE) |
| 145 |
set(PACKAGE_NAMESPACE_PREFIX "${PACKAGE_NAMESPACE}-") |
| 146 |
endif () |
| 147 |
find_package(${PACKAGE_NAMESPACE_PREFIX}c++utilities${CONFIGURATION_PACKAGE_SUFFIX} ${CPP_UTILITIES_REQUIRED_VERSION} |
| 148 |
REQUIRED) |
| 149 |
use_cpp_utilities() |
| 150 |
|
| 151 |
# configure platform specific capslock detection for enterpassworddialog.cpp |
| 152 |
if (WIN32) |
| 153 |
set(HAVE_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION ON) |
| 154 |
else () |
| 155 |
include(3rdParty) |
| 156 |
use_package(TARGET_NAME X11::X11 PACKAGE_NAME X11 OPTIONAL) |
| 157 |
if (TARGET X11::X11) |
| 158 |
set_property( |
| 159 |
SOURCE enterpassworddialog/enterpassworddialog.cpp |
| 160 |
APPEND |
| 161 |
PROPERTY COMPILE_DEFINITIONS X_AVAILABLE) |
| 162 |
set(HAVE_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION ON) |
| 163 |
endif () |
| 164 |
endif () |
| 165 |
option(CAPSLOCK_DETECTION "enables capslock detection" ${HAVE_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION}) |
| 166 |
if (CAPSLOCK_DETECTION) |
| 167 |
if (NOT HAVE_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) |
| 168 |
message(FATAL_ERROR "No backend for capslock detection found (WinAPI or X11 must be provided)") |
| 169 |
endif () |
| 170 |
set_property( |
| 171 |
SOURCE enterpassworddialog/enterpassworddialog.cpp |
| 172 |
APPEND |
| 173 |
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION) |
| 174 |
endif () |
| 175 |
|
| 176 |
# configure support for D-Bus notifications |
| 177 |
if (UNIX |
| 178 |
AND NOT APPLE |
| 179 |
AND NOT ANDROID) |
| 180 |
set(ENABLE_DBUS_NOTIFICATIONS_BY_DEFAULT ON) |
| 181 |
else () |
| 182 |
set(ENABLE_DBUS_NOTIFICATIONS_BY_DEFAULT OFF) |
| 183 |
endif () |
| 184 |
option(DBUS_NOTIFICATIONS "enables support for D-Bus notifications" ${ENABLE_DBUS_NOTIFICATIONS_BY_DEFAULT}) |
| 185 |
set(DBUS_NOTIFICATIONS_FILE_NAME misc/dbusnotification) |
| 186 |
if (DBUS_NOTIFICATIONS) |
| 187 |
list(APPEND HEADER_FILES ${DBUS_NOTIFICATIONS_FILE_NAME}.h) |
| 188 |
list(APPEND SRC_FILES ${DBUS_NOTIFICATIONS_FILE_NAME}.cpp) |
| 189 |
list(APPEND DBUS_FILES dbus/org.freedesktop.Notifications.xml) |
| 190 |
list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_SUPPORT_DBUS_NOTIFICATIONS) |
| 191 |
list(APPEND QT_TESTS dbusnotification) |
| 192 |
message(STATUS "D-Bus notifications enabled") |
| 193 |
else () |
| 194 |
list(APPEND EXCLUDED_FILES ${DBUS_NOTIFICATIONS_FILE_NAME}.h ${DBUS_NOTIFICATIONS_FILE_NAME}.cpp) |
| 195 |
message(STATUS "D-Bus notifications disabled") |
| 196 |
endif () |
| 197 |
|
| 198 |
# configure setup tools; if not enabled functions/classes under setup become no-ops |
| 199 |
if (SETUP_TOOLS) |
| 200 |
set_property( |
| 201 |
SOURCE setup/updater.cpp setup/signature.cpp tests/setup.cpp |
| 202 |
APPEND |
| 203 |
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_SETUP_TOOLS_ENABLED) |
| 204 |
list(APPEND REQUIRED_ICONS install info) |
| 205 |
list(APPEND WIDGETS_UI_FILES setup/updateoptionpage.ui) |
| 206 |
list(APPEND QT_TESTS setup) |
| 207 |
list(APPEND ADDITIONAL_QT_MODULES Network Concurrent) |
| 208 |
endif () |
| 209 |
|
| 210 |
# include modules to apply configuration |
| 211 |
include(BasicConfig) |
| 212 |
include(QtGuiConfig) |
| 213 |
|
| 214 |
# add further Qt modules (which are not automatically detected) |
| 215 |
set(META_PUBLIC_QT_MODULES Core ${ADDITIONAL_QT_MODULES}) |
| 216 |
|
| 217 |
# include further modules to apply configuration |
| 218 |
include(QtConfig) |
| 219 |
include(WindowsResources) |
| 220 |
include(LibraryTarget) |
| 221 |
include(Doxygen) |
| 222 |
include(ConfigHeader) |
| 223 |
|
| 224 |
# configure test target |
| 225 |
if (WIDGETS_GUI) |
| 226 |
list(APPEND QT_TESTS buttonoverlay dialogs) |
| 227 |
endif () |
| 228 |
include(TestUtilities) |
| 229 |
list(APPEND QT_TEST_LIBRARIES ${CPP_UTILITIES_LIB} ${META_TARGET_NAME}) |
| 230 |
use_qt_module(LIBRARIES_VARIABLE "QT_TEST_LIBRARIES" PREFIX "${QT_PACKAGE_PREFIX}" MODULE "Test") |
| 231 |
foreach (TEST ${QT_TESTS}) |
| 232 |
configure_test_target(TEST_NAME "${TEST}_tests" SRC_FILES "tests/${TEST}.cpp" LIBRARIES "${QT_TEST_LIBRARIES}") |
| 233 |
endforeach () |