summaryrefslogtreecommitdiff
path: root/accounts/gkleen@skadhi/shell/quickshell-plugins/CMakeLists.txt
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2026-09-23 21:08:35 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2026-09-23 21:08:35 +0200
commitae9a80c1f012686c1f65fce7ce76fdd1b77b0b71 (patch)
tree141f738276cf84c6b7e5633c2bd5f2b44e9b0b75 /accounts/gkleen@skadhi/shell/quickshell-plugins/CMakeLists.txt
parent6a763272038e637a8a03dd9059d43a1ff44921dd (diff)
downloadnixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.tar
nixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.tar.gz
nixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.tar.bz2
nixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.tar.xz
nixos-ae9a80c1f012686c1f65fce7ce76fdd1b77b0b71.zip
...
Diffstat (limited to 'accounts/gkleen@skadhi/shell/quickshell-plugins/CMakeLists.txt')
-rw-r--r--accounts/gkleen@skadhi/shell/quickshell-plugins/CMakeLists.txt190
1 files changed, 190 insertions, 0 deletions
diff --git a/accounts/gkleen@skadhi/shell/quickshell-plugins/CMakeLists.txt b/accounts/gkleen@skadhi/shell/quickshell-plugins/CMakeLists.txt
new file mode 100644
index 00000000..6b4f0d48
--- /dev/null
+++ b/accounts/gkleen@skadhi/shell/quickshell-plugins/CMakeLists.txt
@@ -0,0 +1,190 @@
1set(INSTALL_QMLDIR "" CACHE STRING "QML install dir")
2set(INSTALL_QML_PREFIX "" CACHE STRING "QML install prefix")
3
4# There doesn't seem to be a standard cross-distro qml install path.
5if ("${INSTALL_QMLDIR}" STREQUAL "" AND "${INSTALL_QML_PREFIX}" STREQUAL "")
6 message(WARNING "Neither INSTALL_QMLDIR nor INSTALL_QML_PREFIX is set. QML modules will not be installed.")
7else()
8 if ("${INSTALL_QMLDIR}" STREQUAL "")
9 set(QML_FULL_INSTALLDIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_QML_PREFIX}")
10 else()
11 set(QML_FULL_INSTALLDIR "${INSTALL_QMLDIR}")
12 endif()
13
14 message(STATUS "QML install dir: ${QML_FULL_INSTALLDIR}")
15endif()
16
17# Install a given target as a QML module. This is mostly pulled from ECM, as there does not seem
18# to be an official way to do it.
19# see https://github.com/KDE/extra-cmake-modules/blob/fe0f606bf7f222e36f7560fd7a2c33ef993e23bb/modules/ECMQmlModule6.cmake#L160
20function(install_qml_module arg_TARGET)
21 if (NOT DEFINED QML_FULL_INSTALLDIR)
22 return()
23 endif()
24
25 qt_query_qml_module(${arg_TARGET}
26 URI module_uri
27 VERSION module_version
28 PLUGIN_TARGET module_plugin_target
29 TARGET_PATH module_target_path
30 QMLDIR module_qmldir
31 TYPEINFO module_typeinfo
32 QML_FILES module_qml_files
33 RESOURCES module_resources
34 )
35
36 set(module_dir "${QML_FULL_INSTALLDIR}/${module_target_path}")
37
38 if (NOT TARGET "${module_plugin_target}")
39 message(FATAL_ERROR "install_qml_modules called for a target without a plugin")
40 endif()
41
42 get_target_property(target_type "${arg_TARGET}" TYPE)
43 if (NOT "${target_type}" STREQUAL "STATIC_LIBRARY")
44 install(
45 TARGETS "${arg_TARGET}"
46 LIBRARY DESTINATION "${module_dir}"
47 RUNTIME DESTINATION "${module_dir}"
48 )
49
50 install(
51 TARGETS "${module_plugin_target}"
52 LIBRARY DESTINATION "${module_dir}"
53 RUNTIME DESTINATION "${module_dir}"
54 )
55 endif()
56
57 install(FILES "${module_qmldir}" DESTINATION "${module_dir}")
58 install(FILES "${module_typeinfo}" DESTINATION "${module_dir}")
59
60 # Install QML files
61 list(LENGTH module_qml_files num_files)
62 if (NOT "${module_qml_files}" MATCHES "NOTFOUND" AND ${num_files} GREATER 0)
63 qt_query_qml_module(${arg_TARGET} QML_FILES_DEPLOY_PATHS qml_files_deploy_paths)
64
65 math(EXPR last_index "${num_files} - 1")
66 foreach(i RANGE 0 ${last_index})
67 list(GET module_qml_files ${i} src_file)
68 list(GET qml_files_deploy_paths ${i} deploy_path)
69 get_filename_component(dst_name "${deploy_path}" NAME)
70 get_filename_component(dest_dir "${deploy_path}" DIRECTORY)
71 install(FILES "${src_file}" DESTINATION "${module_dir}/${dest_dir}" RENAME "${dst_name}")
72 endforeach()
73 endif()
74
75 # Install resources
76 list(LENGTH module_resources num_files)
77 if (NOT "${module_resources}" MATCHES "NOTFOUND" AND ${num_files} GREATER 0)
78 qt_query_qml_module(${arg_TARGET} RESOURCES_DEPLOY_PATHS resources_deploy_paths)
79
80 math(EXPR last_index "${num_files} - 1")
81 foreach(i RANGE 0 ${last_index})
82 list(GET module_resources ${i} src_file)
83 list(GET resources_deploy_paths ${i} deploy_path)
84 get_filename_component(dst_name "${deploy_path}" NAME)
85 get_filename_component(dest_dir "${deploy_path}" DIRECTORY)
86 install(FILES "${src_file}" DESTINATION "${module_dir}/${dest_dir}" RENAME "${dst_name}")
87 endforeach()
88 endif()
89endfunction()
90
91
92cmake_minimum_required(VERSION 3.20)
93project(custom LANGUAGES CXX)
94
95find_package(Qt6 REQUIRED COMPONENTS Core Qml DBus)
96
97qt_standard_project_setup(REQUIRES 6.6)
98
99qt6_policy(SET QTP0001 NEW)
100qt6_add_qml_module(customplugin
101 URI "Custom"
102 PLUGIN_TARGET customplugin
103)
104
105set_source_files_properties(org.keepassxc.KeePassXC.MainWindow.xml PROPERTIES
106 CLASSNAME DBusKeePassXC
107 NO_NAMESPACE TRUE
108)
109qt_add_dbus_interface(DBUS_INTERFACES
110 org.keepassxc.KeePassXC.MainWindow.xml
111 dbus_keepassxc
112)
113
114set_source_files_properties(org.freedesktop.systemd1.Manager.xml PROPERTIES
115 CLASSNAME DBusSystemdManager
116 NO_NAMESPACE TRUE
117 INCLUDE ListUnitsEntry.hpp
118)
119qt_add_dbus_interface(DBUS_INTERFACES
120 org.freedesktop.systemd1.Manager.xml
121 dbus_systemd_manager
122)
123
124set_source_files_properties(org.freedesktop.login1.Manager.xml PROPERTIES
125 CLASSNAME DBusLogindManager
126 NO_NAMESPACE TRUE
127)
128qt_add_dbus_interface(DBUS_INTERFACES
129 org.freedesktop.login1.Manager.xml
130 dbus_logind_manager
131)
132
133set_source_files_properties(org.freedesktop.login1.Session.xml PROPERTIES
134 CLASSNAME DBusLogindSession
135 NO_NAMESPACE TRUE
136)
137qt_add_dbus_interface(DBUS_INTERFACES
138 org.freedesktop.login1.Session.xml
139 dbus_logind_session
140)
141
142set_source_files_properties(org.freedesktop.systemd1.Unit.xml PROPERTIES
143 CLASSNAME DBusSystemdUnit
144 NO_NAMESPACE TRUE
145)
146qt_add_dbus_interface(DBUS_INTERFACES
147 org.freedesktop.systemd1.Unit.xml
148 dbus_systemd_unit
149)
150
151set_source_files_properties(org.freedesktop.systemd1.Service.xml PROPERTIES
152 CLASSNAME DBusSystemdService
153 NO_NAMESPACE TRUE
154)
155qt_add_dbus_interface(DBUS_INTERFACES
156 org.freedesktop.systemd1.Service.xml
157 dbus_systemd_service
158)
159
160set_source_files_properties(org.freedesktop.DBus.Properties.xml PROPERTIES
161 CLASSNAME DBusProperties
162 NO_NAMESPACE TRUE
163)
164qt_add_dbus_interface(DBUS_INTERFACES
165 org.freedesktop.DBus.Properties.xml
166 dbus_properties
167)
168
169include_directories(${CMAKE_SOURCE_DIR}/build)
170include_directories(${QUICKSHELL_SRC}/src)
171
172target_compile_features(customplugin PUBLIC cxx_std_26)
173
174target_link_libraries(customplugin PRIVATE
175 Qt6::Core
176 Qt6::Qml
177 Qt6::DBus
178)
179
180target_sources(customplugin PRIVATE
181 Chrono.cpp Chrono.hpp
182 FileSelector.cpp FileSelector.hpp
183 KeePassXC.cpp KeePassXC.hpp
184 Systemd.cpp Systemd.hpp
185 ListUnitsEntry.cpp ListUnitsEntry.hpp
186 ${DBUS_INTERFACES}
187 ${QUICKSHELL_SRC}/src/core/model.cpp ${QUICKSHELL_SRC}/src/core/model.hpp
188)
189
190install_qml_module(customplugin)