Skip to content

Commit 556cfe2

Browse files
committed
[RESIVIT] Use CMake qt_qml_add_module() for org.asteroid.controls
This one (for now at least) retains the manually written plugin instead of generating one since it also changes the default font instead of just calling qmlRegisterType for each C++ QML component: QGuiApplication::setFont(QFont("Noto Sans")); If another way to accomplish the same task globally for anything using org.asteroid.controls is found the same as one commit above for org.asteroid.utils can also be done here and controls_plugin.* can be done away with.
1 parent 69866f3 commit 556cfe2

File tree

2 files changed

+26
-39
lines changed

2 files changed

+26
-39
lines changed

src/controls/CMakeLists.txt

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,24 @@ foreach(control ${controls})
4242
list(APPEND controls-qml "qml/${control}.qml")
4343
endforeach()
4444

45-
add_library(asteroidcontrolsplugin ${SRC} ${HEADERS})
45+
set_source_files_properties(qml/Dims.qml
46+
PROPERTIES QT_QML_SINGLETON_TYPE TRUE)
4647

47-
qt_add_resources(asteroidcontrolsplugin "asteroidcontrolsplugin_qrc"
48-
PREFIX "/org/asteroid/controls/"
49-
FILES "${controls-qml}")
48+
qt_add_qml_module(asteroidcontrolsplugin
49+
URI org.asteroid.controls
50+
VERSION 1.0
51+
PLUGIN_TARGET asteroidcontrolsplugin
52+
NO_GENERATE_PLUGIN_SOURCE
53+
#NO_PLUGIN_OPTIONAL
54+
QML_FILES
55+
${controls-qml}
56+
#ENABLE_TYPE_COMPILER
57+
SOURCES
58+
${SRC} ${HEADERS}
59+
)
60+
61+
# TODO: drop debug once AOT produces less warnings etc
62+
set_target_properties(asteroidcontrolsplugin PROPERTIES QT_QMLCACHEGEN_ARGUMENTS "--verbose")
5063

5164
qt6_add_shaders(asteroidcontrolsplugin "asteroidcontrolsplugin_shaders"
5265
PREFIX "/org/asteroid/controls/"
@@ -55,6 +68,14 @@ qt6_add_shaders(asteroidcontrolsplugin "asteroidcontrolsplugin_shaders"
5568
PRECOMPILE
5669
OPTIMIZED)
5770

71+
target_link_libraries(asteroidcontrolsplugin
72+
PUBLIC
73+
#Qt::Qml
74+
Qt::Quick # src/{application_p,flatmesh{,node},icon}.*
75+
PRIVATE
76+
Qt::Svg # src/icon.cpp
77+
)
78+
5879
set(controls-docs "$<LIST:TRANSFORM,$<LIST:TRANSFORM,$<LOWER_CASE:${controls}>,PREPEND,qml->,APPEND,.html>")
5980
set(doc-dir "${CMAKE_BINARY_DIR}/doc/html")
6081
set(full-controls-docs "$<LIST:TRANSFORM,${controls-docs},PREPEND,${doc-dir}>")
@@ -70,12 +91,7 @@ add_custom_command(
7091
COMMENT "Generating HTML format Reference documentation..." VERBATIM
7192
)
7293

73-
target_link_libraries(asteroidcontrolsplugin
74-
Qt::Qml
75-
Qt::Quick
76-
Qt::Svg)
77-
7894
install(TARGETS asteroidcontrolsplugin
7995
DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/controls)
80-
install(FILES qmldir
96+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qmldir
8197
DESTINATION ${INSTALL_QML_IMPORT_DIR}/org/asteroid/controls)

src/controls/qmldir

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)