aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-10-27 12:32:20 +0100
committerFabian Kosmale <fabian.kosmale@qt.io>2020-11-06 13:00:54 +0100
commitcd513c3e1767c7ca3626d4150609fd704c02e4f1 (patch)
tree2431c89352a499537dee6a304899b78527be284c /src
parent4a9e5c5e89e403b492f08c5a4a1f5334a8b21ad3 (diff)
CMake: Clean up logic to prepare building pure QML modules
Make sure we don't create bogus typeinfo entries, do create a target if there are no C++ files, and do install created targets. This way we do build the qmlcachegen-created files and link them into a library which is subsequently deployed. It's not a real plugin, though, and we need to specially handle this in QML. That's material for a separate change. Change-Id: I516d4611b6041a23489ce57df38dd83114dcc5de Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r--src/qml/Qt6QmlBuildInternals.cmake14
-rw-r--r--src/qml/Qt6QmlMacros.cmake23
2 files changed, 28 insertions, 9 deletions
diff --git a/src/qml/Qt6QmlBuildInternals.cmake b/src/qml/Qt6QmlBuildInternals.cmake
index c2018d71f8..a9b20235ad 100644
--- a/src/qml/Qt6QmlBuildInternals.cmake
+++ b/src/qml/Qt6QmlBuildInternals.cmake
@@ -91,7 +91,7 @@ function(qt_internal_add_qml_module target)
endif()
- if (arg_CPP_PLUGIN)
+ if (arg_CPP_PLUGIN OR arg_SOURCES)
set(no_create_option DO_NOT_CREATE_TARGET)
endif()
@@ -121,6 +121,16 @@ function(qt_internal_add_qml_module target)
qt_path_join(qml_module_install_dir ${QT_INSTALL_DIR} "${INSTALL_QMLDIR}/${arg_TARGET_PATH}")
+ set(qml_module_build_dir "")
+ if(NOT QT_WILL_INSTALL)
+ qt_path_join(qml_module_build_dir ${QT_INSTALL_DIR} "${INSTALL_QMLDIR}/${arg_TARGET_PATH}")
+ set(qml_module_build_dir OUTPUT_DIRECTORY "${qml_module_build_dir}")
+ endif()
+
+ if (arg_SOURCES AND NOT arg_TYPEINFO)
+ set(arg_TYPEINFO "plugins.qmltypes")
+ endif()
+
qt6_add_qml_module(${target}
${designer_supported_arg}
${no_create_option}
@@ -138,8 +148,8 @@ function(qt_internal_add_qml_module target)
OPTIONAL_IMPORTS "${arg_OPTIONAL_IMPORTS}"
TYPEINFO "${arg_TYPEINFO}"
DO_NOT_INSTALL_METADATA
- DO_NOT_CREATE_TARGET
INSTALL_QML_FILES
+ ${qml_module_build_dir}
INSTALL_LOCATION "${qml_module_install_dir}"
DEPENDENCIES ${arg_DEPENDENCIES}
RESOURCE_EXPORT "${INSTALL_CMAKE_NAMESPACE}${target}Targets"
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index b4acf4076d..c6b11d5ba1 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -225,13 +225,20 @@ function(qt6_add_qml_module target)
QT_QML_MODULE_RESOURCE_EXPORT "${arg_RESOURCE_EXPORT}"
)
- if (arg_OUTPUT_DIRECTORY AND NOT DO_NOT_CREATE_TARGET)
- set_target_properties(${target}
- PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
- ARCHIVE_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
- )
+ if (NOT DO_NOT_CREATE_TARGET)
+ if (arg_OUTPUT_DIRECTORY)
+ set_target_properties(${target}
+ PROPERTIES
+ LIBRARY_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
+ ARCHIVE_OUTPUT_DIRECTORY "${arg_OUTPUT_DIRECTORY}"
+ )
+ elseif (should_install)
+ install(TARGETS ${target}
+ DESTINATION "${arg_INSTALL_LOCATION}"
+ )
+ endif()
endif()
+
if (arg_OUTPUT_DIRECTORY)
set(target_output_dir ${arg_OUTPUT_DIRECTORY})
else()
@@ -281,13 +288,15 @@ function(qt6_add_qml_module target)
endif()
if (arg_TYPEINFO)
string(APPEND qmldir_file_contents "typeinfo ${arg_TYPEINFO}\n")
- else()
+ elseif (arg_SOURCES)
# This always need to be written out since at the moment we have cases
# where qmltyperegistrar is not run with the plugin but on a module
# e.g: src/qml generates the qmltypes for src/imports/qtqml.
# When this has been fixed/standardized we should move this to
# qt6_qml_type_registration() so that it is written out when the
# plugins.qmltypes is actually generated.
+ # However, if there are no sources, then this is a pure QML module. In
+ # that case there cannot be a plugins.qmltypes file.
string(APPEND qmldir_file_contents "typeinfo plugins.qmltypes\n")
endif()