on xenial help sign in
Only generate .qmltypes files manually, no need to do it build-time.
d554ebbMichał Sawicz
cmake/modules/QmlPlugins.cmake+20−21
@@ -12,6 +12,12 @@ if(NOT TARGET qmlplugindump)
12 set_target_properties(qmlplugindump PROPERTIES IMPORTED_LOCATION ${qmlplugindump_exe})
12 set_target_properties(qmlplugindump PROPERTIES IMPORTED_LOCATION ${qmlplugindump_exe})
13endif()
13endif()
14
14
15+#
16+# A custom target for building the qmltypes files manually.
17+#
18+if (NOT TARGET qmltypes)
19+ add_custom_target(qmltypes)
20+endif()
15
21
16# Creates a target for copying resource files into build dir and optionally installing them.
22# Creates a target for copying resource files into build dir and optionally installing them.
17#
23#
@@ -51,6 +57,7 @@ macro(export_qmlfiles PLUGIN PATH)
51 ${QMLFILES_SEARCH_PATH}/*.png
57 ${QMLFILES_SEARCH_PATH}/*.png
52 ${QMLFILES_SEARCH_PATH}/*.sci
58 ${QMLFILES_SEARCH_PATH}/*.sci
53 ${QMLFILES_SEARCH_PATH}/*.svg
59 ${QMLFILES_SEARCH_PATH}/*.svg
60+ ${QMLFILES_SEARCH_PATH}/*.qmltypes
54 ${QMLFILES_SEARCH_PATH}/qmldir
61 ${QMLFILES_SEARCH_PATH}/qmldir
55 )
62 )
56
63
@@ -69,14 +76,14 @@ macro(export_qmlfiles PLUGIN PATH)
69 DESTINATION ${QMLFILES_DESTINATION}/${PATH}
76 DESTINATION ${QMLFILES_DESTINATION}/${PATH}
70 )
77 )
71 endif()
78 endif()
72−endmacro(export_qmlfiles)
79+endmacro()
73
80
74
81
75−# Creates a target for generating the typeinfo file for a QML plugin and optionally installs it
82+# Creates a target for generating the typeinfo file for a QML plugin and optionally installs
76−# and additional targets.
83+# additional targets.
77#
84#
78# Files will be copied into ${BINARY_DIR}/${path} or ${CMAKE_CURRENT_BINARY_DIR} and installed
85# Files will be copied into ${BINARY_DIR}/${path} or ${CMAKE_CURRENT_BINARY_DIR} and installed
79−# into ${DESTINATION}/${path}. If you don't pass BINARY_DIR, it's assumed that current source
86+# into ${DESTINATION}/${path}. If you don't pass BINARY_DIR, it's assumed that current source
80# path ends with ${path}.
87# path ends with ${path}.
81#
88#
82# The generated file will be named after the last segment of the plugin name, e.g. Foo.qmltypes.
89# The generated file will be named after the last segment of the plugin name, e.g. Foo.qmltypes.
@@ -90,7 +97,8 @@ endmacro(export_qmlfiles)
90# )
97# )
91#
98#
92# Created target:
99# Created target:
93−# - ${TARGET_PREFIX}${plugin}-qmltypes - Generates the qmltypes file in the binary dir.
100+# - ${TARGET_PREFIX}${plugin}-qmltypes - Generates the qmltypes file in the source dir.
101+# It will be made a dependency of the "qmltypes" target.
94
102
95macro(export_qmlplugin PLUGIN VERSION PATH)
103macro(export_qmlplugin PLUGIN VERSION PATH)
96 set(single BINARY_DIR DESTINATION TARGET_PREFIX ENVIRONMENT)
104 set(single BINARY_DIR DESTINATION TARGET_PREFIX ENVIRONMENT)
@@ -110,23 +118,14 @@ macro(export_qmlplugin PLUGIN VERSION PATH)
110 # Find the last segment of the plugin name to use as qmltypes basename
118 # Find the last segment of the plugin name to use as qmltypes basename
111 string(REGEX MATCH "[^.]+$" plugin_suffix ${PLUGIN})
119 string(REGEX MATCH "[^.]+$" plugin_suffix ${PLUGIN})
112 set(target_prefix ${QMLPLUGIN_TARGET_PREFIX}${PLUGIN})
120 set(target_prefix ${QMLPLUGIN_TARGET_PREFIX}${PLUGIN})
113− set(qmltypes_path ${qmlplugin_dir}/${plugin_suffix}.qmltypes)
121+ set(qmltypes_path ${CMAKE_CURRENT_SOURCE_DIR}/${plugin_suffix}.qmltypes)
114
122
115− # Only generate typeinfo if not cross compiling
116− if(NOT CMAKE_CROSSCOMPILING)
117− add_custom_target(${target_prefix}-qmltypes ALL
123+ add_custom_target(${target_prefix}-qmltypes
118− COMMAND env ${QMLPLUGIN_ENVIRONMENT} ${qmlplugindump_executable} -notrelocatable
124+ COMMAND env ${QMLPLUGIN_ENVIRONMENT} ${qmlplugindump_executable} -notrelocatable
119− ${PLUGIN} ${VERSION} ${QMLPLUGIN_BINARY_DIR} > ${qmltypes_path}
125+ ${PLUGIN} ${VERSION} ${QMLPLUGIN_BINARY_DIR} > ${qmltypes_path}
120− )
126+ )
121− add_dependencies(${target_prefix}-qmltypes ${target_prefix}-qmlfiles ${QMLPLUGIN_TARGETS})
127+ add_dependencies(${target_prefix}-qmltypes ${target_prefix}-qmlfiles ${QMLPLUGIN_TARGETS})
122−
128+ add_dependencies(qmltypes ${target_prefix}-qmltypes)
123− if (QMLPLUGIN_DESTINATION)
124− # Install the typeinfo file
125− install(FILES ${qmltypes_path}
126− DESTINATION ${QMLPLUGIN_DESTINATION}/${PATH}
127− )
128− endif()
129− endif()
130
129
131 set_target_properties(${QMLPLUGIN_TARGETS} PROPERTIES
130 set_target_properties(${QMLPLUGIN_TARGETS} PROPERTIES
132 ARCHIVE_OUTPUT_DIRECTORY ${qmlplugin_dir}
131 ARCHIVE_OUTPUT_DIRECTORY ${qmlplugin_dir}