qtutilities/CMakeLists.txt

200 lines
7.1 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.17.0 FATAL_ERROR)
2015-12-05 22:50:38 +01:00
2017-01-07 16:46:53 +01:00
# meta data
set(META_PROJECT_NAME qtutilities)
set(META_PROJECT_VARNAME QT_UTILITIES)
set(META_APP_NAME "Qt Utilities")
set(META_APP_AUTHOR "Martchus")
set(META_APP_URL "https://github.com/${META_APP_AUTHOR}/${META_PROJECT_NAME}")
2019-02-06 17:32:10 +01:00
set(META_APP_DESCRIPTION
"Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models")
set(META_VERSION_MAJOR 6)
2024-03-31 13:28:49 +02:00
set(META_VERSION_MINOR 14)
2024-04-08 12:36:51 +02:00
set(META_VERSION_PATCH 1)
2017-01-07 16:46:53 +01:00
set(META_APP_VERSION ${META_VERSION_MAJOR}.${META_VERSION_MINOR}.${META_VERSION_PATCH})
project(${META_PROJECT_NAME})
2015-12-08 08:36:36 +01:00
# add project files
set(HEADER_FILES
2016-03-03 01:43:48 +01:00
misc/xmlparsermacros.h
misc/undefxmlparsermacros.h
misc/trylocker.h
misc/adoptlocker.h
misc/dialogutils.h
misc/desktoputils.h
misc/conversion.h
2020-09-02 19:49:40 +02:00
misc/compat.h
2015-12-08 08:36:36 +01:00
models/checklistmodel.h
resources/qtconfigarguments.h
resources/resources.h
2019-02-06 17:32:10 +01:00
resources/importplugin.h)
2019-11-30 17:58:56 +01:00
set(SRC_FILES misc/dialogutils.cpp misc/desktoputils.cpp models/checklistmodel.cpp resources/qtconfigarguments.cpp
resources/resources.cpp)
2019-02-06 17:32:10 +01:00
set(RES_FILES resources/qtutilsicons.qrc)
set(WIDGETS_HEADER_FILES
aboutdialog/aboutdialog.h
enterpassworddialog/enterpassworddialog.h
2015-12-08 08:36:36 +01:00
settingsdialog/optioncategory.h
settingsdialog/optioncategoryfiltermodel.h
settingsdialog/optioncategorymodel.h
settingsdialog/optionpage.h
settingsdialog/settingsdialog.h
2016-04-04 14:49:40 +02:00
settingsdialog/qtsettings.h
2015-12-08 08:36:36 +01:00
widgets/buttonoverlay.h
widgets/clearcombobox.h
widgets/clearlineedit.h
widgets/clearplaintextedit.h
widgets/clearspinbox.h
widgets/iconbutton.h
widgets/pathselection.h
2016-04-04 14:49:40 +02:00
paletteeditor/paletteeditor.h
paletteeditor/colorbutton.h
2019-02-06 17:32:10 +01:00
misc/recentmenumanager.h)
set(WIDGETS_SRC_FILES
2015-12-08 08:36:36 +01:00
aboutdialog/aboutdialog.cpp
enterpassworddialog/enterpassworddialog.cpp
settingsdialog/optioncategory.cpp
settingsdialog/optioncategoryfiltermodel.cpp
settingsdialog/optioncategorymodel.cpp
settingsdialog/optionpage.cpp
settingsdialog/settingsdialog.cpp
2016-04-04 14:49:40 +02:00
settingsdialog/qtsettings.cpp
2015-12-08 08:36:36 +01:00
widgets/buttonoverlay.cpp
widgets/clearcombobox.cpp
widgets/clearlineedit.cpp
widgets/clearplaintextedit.cpp
widgets/clearspinbox.cpp
widgets/iconbutton.cpp
widgets/pathselection.cpp
2016-04-04 14:49:40 +02:00
paletteeditor/paletteeditor.cpp
paletteeditor/colorbutton.cpp
2019-02-06 17:32:10 +01:00
misc/recentmenumanager.cpp)
2016-01-25 18:59:44 +01:00
set(WIDGETS_UI_FILES
aboutdialog/aboutdialog.ui
enterpassworddialog/enterpassworddialog.ui
settingsdialog/settingsdialog.ui
2016-04-04 14:49:40 +02:00
settingsdialog/qtappearanceoptionpage.ui
settingsdialog/qtlanguageoptionpage.ui
settingsdialog/qtenvoptionpage.ui
2019-02-06 17:32:10 +01:00
paletteeditor/paletteeditor.ui)
2020-06-23 02:00:00 +02:00
set(QT_TESTS buttonoverlay dialogs)
set(CMAKE_MODULE_FILES
2019-11-30 17:58:56 +01:00
cmake/modules/AndroidApk.cmake cmake/modules/QtConfig.cmake cmake/modules/QtGuiConfig.cmake
cmake/modules/QtLinkage.cmake cmake/modules/QtWebViewProviderConfig.cmake cmake/modules/QtJsProviderConfig.cmake)
set(CMAKE_TEMPLATE_FILES cmake/templates/qtconfig.h.in cmake/templates/webviewdefs.h.in cmake/templates/webviewincludes.h.in
cmake/templates/jsdefs.h.in cmake/templates/jsincludes.h.in)
2019-02-06 17:32:10 +01:00
if (ANDROID)
list(APPEND CMAKE_MODULE_FILES)
list(APPEND CMAKE_TEMPLATE_FILES cmake/templates/android-deployment.json.in)
endif ()
set(TS_FILES translations/${META_PROJECT_NAME}_zh_CN.ts translations/${META_PROJECT_NAME}_de_DE.ts
translations/${META_PROJECT_NAME}_en_US.ts)
2017-01-07 16:46:53 +01:00
2019-02-06 17:32:10 +01:00
set(DOC_FILES README.md)
2016-06-10 23:05:43 +02:00
set(REQUIRED_ICONS
dialog-cancel
dialog-ok
dialog-ok-apply
document-open
document-open-recent
edit-clear
go-next
2016-08-31 23:38:35 +02:00
preferences-desktop-icons
preferences-desktop-locale
qtcreator
system-file-manager
system-run
system-search
2019-02-06 17:32:10 +01:00
window-close)
2019-02-06 17:32:10 +01:00
set(SCRIPT_FILES scripts/required_icons.sh)
# required to include CMake modules from own project directory
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_MODULE_PATH}")
2015-12-05 22:50:38 +01:00
# find c++utilities
set(CONFIGURATION_PACKAGE_SUFFIX
""
CACHE STRING "sets the suffix for find_package() calls to packages configured via c++utilities")
set(PACKAGE_NAMESPACE
""
CACHE STRING "sets the namespace (prefix) for find_package() calls to packages configured via c++utilities")
if (PACKAGE_NAMESPACE)
set(PACKAGE_NAMESPACE_PREFIX "${PACKAGE_NAMESPACE}-")
endif ()
find_package(${PACKAGE_NAMESPACE_PREFIX}c++utilities${CONFIGURATION_PACKAGE_SUFFIX} 5.5.0 REQUIRED)
use_cpp_utilities()
# configure platform specific capslock detection for enterpassworddialog.cpp
if (WIN32)
set(HAVE_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION ON)
2019-02-06 17:32:10 +01:00
else ()
include(3rdParty)
2023-10-11 18:11:07 +02:00
use_package(TARGET_NAME X11::X11 PACKAGE_NAME X11 OPTIONAL)
if (TARGET X11::X11)
set_property(
SOURCE enterpassworddialog/enterpassworddialog.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS X_AVAILABLE)
set(HAVE_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION ON)
2019-02-06 17:32:10 +01:00
endif ()
endif ()
option(CAPSLOCK_DETECTION "enables capslock detection" ${HAVE_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION})
if (CAPSLOCK_DETECTION)
2019-02-06 17:32:10 +01:00
if (NOT HAVE_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION)
message(FATAL_ERROR "No backend for capslock detection found (WinAPI or X11 must be provided)")
2019-02-06 17:32:10 +01:00
endif ()
2019-11-30 17:58:56 +01:00
set_property(
SOURCE enterpassworddialog/enterpassworddialog.cpp
APPEND
PROPERTY COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_PLATFORM_SPECIFIC_CAPSLOCK_DETECTION)
2019-02-06 17:32:10 +01:00
endif ()
2015-12-05 22:50:38 +01:00
# configure support for D-Bus notifications
2019-11-30 17:58:56 +01:00
if (UNIX
AND NOT APPLE
AND NOT ANDROID)
set(ENABLE_DBUS_NOTIFICATIONS_BY_DEFAULT ON)
2019-02-06 17:32:10 +01:00
else ()
set(ENABLE_DBUS_NOTIFICATIONS_BY_DEFAULT OFF)
2019-02-06 17:32:10 +01:00
endif ()
option(DBUS_NOTIFICATIONS "enables support for D-Bus notifications" ${ENABLE_DBUS_NOTIFICATIONS_BY_DEFAULT})
set(DBUS_NOTIFICATIONS_FILE_NAME misc/dbusnotification)
2019-02-06 17:32:10 +01:00
if (DBUS_NOTIFICATIONS)
list(APPEND HEADER_FILES ${DBUS_NOTIFICATIONS_FILE_NAME}.h)
list(APPEND SRC_FILES ${DBUS_NOTIFICATIONS_FILE_NAME}.cpp)
list(APPEND DBUS_FILES dbus/org.freedesktop.Notifications.xml)
list(APPEND META_PUBLIC_COMPILE_DEFINITIONS ${META_PROJECT_VARNAME}_SUPPORT_DBUS_NOTIFICATIONS)
2020-06-23 02:00:00 +02:00
list(APPEND QT_TESTS dbusnotification)
message(STATUS "D-Bus notifications enabled")
2019-02-06 17:32:10 +01:00
else ()
list(APPEND EXCLUDED_FILES ${DBUS_NOTIFICATIONS_FILE_NAME}.h ${DBUS_NOTIFICATIONS_FILE_NAME}.cpp)
message(STATUS "D-Bus notifications disabled")
2019-02-06 17:32:10 +01:00
endif ()
# include modules to apply configuration
include(BasicConfig)
include(QtGuiConfig)
2018-07-11 13:16:57 +02:00
# add further Qt modules (which are not automatically detected)
set(META_PUBLIC_QT_MODULES Core ${ADDITIONAL_QT_MODULES})
2018-07-11 13:16:57 +02:00
# include further modules to apply configuration
include(QtConfig)
include(WindowsResources)
include(LibraryTarget)
2016-06-10 23:05:43 +02:00
include(Doxygen)
2016-07-27 21:38:57 +02:00
include(ConfigHeader)
2020-06-16 00:17:24 +02:00
# configure test target
include(TestUtilities)
list(APPEND QT_TEST_LIBRARIES ${CPP_UTILITIES_LIB} ${META_TARGET_NAME})
2020-06-16 00:17:24 +02:00
use_qt_module(LIBRARIES_VARIABLE "QT_TEST_LIBRARIES" PREFIX "${QT_PACKAGE_PREFIX}" MODULE "Test")
2020-06-23 02:00:00 +02:00
foreach (TEST ${QT_TESTS})
2020-06-16 00:34:59 +02:00
configure_test_target(TEST_NAME "${TEST}_tests" SRC_FILES "tests/${TEST}.cpp" LIBRARIES "${QT_TEST_LIBRARIES}")
endforeach ()