diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2022-02-23 16:10:50 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-03-02 17:14:31 +0000 |
commit | 4f5a7b20da1bcb696e7b1d7191dbac63699ca918 (patch) | |
tree | 4a5a578b57c5df1e4a8a52df1ec5b716baf7b7eb /src | |
parent | 03dcd24435ae3f5f4ca633e84373bdd18300928c (diff) |
qml: Add build qmldir import path of the current module in prefix builds
Prefix builds with installed qtbase but non-installed qtdeclarative
result in default import paths being insufficient:
QLibraryInfo::path(QLibraryInfo::QmlImportsPath) would return the
install location (e.g. <install>/qtbase/qml/) while QML modules are put
into the qtdeclarative's build dir (e.g. <build>/qtdeclarative/qml)
This results in qmltc failing to locate builtins and modules and thus
failing the build. Same applies (should at least) to qmlsc and qmllint
We can mitigate this by detecting whether we build a specific qt module
in a prefix-build and add an extra import location. The assumption is
that we only build one module at a time (others are installed already)
and user projects wouldn't need / experience the same behavior
Fixes: QTBUG-98011
Fixes: QTBUG-101163
Change-Id: Ie73e1e6dc39e3afd0056db432eeae012a99b7179
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
(cherry picked from commit 6f67326bda744da2c35ee7148177e3872c6e004c)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index 3e69d5d12e..886d3cdc2c 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -671,6 +671,20 @@ macro(_qt_internal_genex_getoption var target property) set(${var} "$<BOOL:$<TARGET_PROPERTY:${target},${property}>>") endmacro() +function(_qt_internal_extend_qml_import_paths import_paths_var) + set(local_var ${${import_paths_var}}) + + # prepend extra import path which is a current module's build dir: we need + # this to ensure correct importing of QML modules when having a prefix-build + # with QLibraryInfo::path(QLibraryInfo::QmlImportsPath) pointing to the + # install location + if(QT_BUILDING_QT AND QT_WILL_INSTALL) + list(PREPEND local_var -I "${QT_BUILD_DIR}/${INSTALL_QMLDIR}") + endif() + + set(${import_paths_var} ${local_var} PARENT_SCOPE) +endfunction() + function(_qt_internal_target_enable_qmllint target) set(lint_target ${target}_qmllint) if(TARGET ${lint_target}) @@ -719,6 +733,8 @@ function(_qt_internal_target_enable_qmllint target) list(APPEND import_args -I "${QT_QML_OUTPUT_DIRECTORY}") endif() + _qt_internal_extend_qml_import_paths(import_args) + set(cmd ${QT_TOOL_COMMAND_WRAPPER_PATH} ${QT_CMAKE_EXPORT_NAMESPACE}::qmllint @@ -1081,6 +1097,8 @@ function(qt6_target_compile_qml_to_cpp target) list(APPEND common_args -I "${import_path}") endforeach() + _qt_internal_extend_qml_import_paths(common_args) + # we explicitly depend on qmldir (due to `-i ${qmldir_file}`) but also # implicitly on the generated qmltypes file, which is a part of qmldir set(qml_module_files) @@ -1556,7 +1574,6 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS) endfunction() endif() - function(qt6_target_qml_sources target) get_target_property(uri ${target} QT_QML_MODULE_URI) @@ -1690,6 +1707,7 @@ function(qt6_target_qml_sources target) # The application binary directory is part of the default import path. list(APPEND import_paths -I "$<TARGET_PROPERTY:${target},BINARY_DIR>") endif() + _qt_internal_extend_qml_import_paths(import_paths) set(cachegen_args ${import_paths} -i "${qmldir_file}" |