aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2023-01-26 09:57:23 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-01-26 16:51:19 +0000
commit7ba71dca0e7e755d0a653fb701b19e36a0b35ea6 (patch)
treed52c67b088503f944dc4ccc876cfa0c741ef1de4
parente31a4def53e92e2f89a364e3ebec58deacd98d5c (diff)
CMake: Fix qt6_generate_foreign_qml_types
We had the tst_qmlsplitlib test failing in in-source builds only, because qt6_wrap_cpp is called on the generated sources and this sets SKIP_AUTOMOC ON. Later in the build, the consumer of the corresponding moc_XXX.cpp.json file errors out, because it cannot find the file. The test worked in out-of-source builds, because the paths of the generated files were relative: add_custom_command generated the files in the build dir. qt6_wrap_cpp got the relative paths and assumed them relative to the source dir and did set SKIP_AUTOMOC on non-existent source files. AUTOMOC took care of generating moc_XXX.cpp and moc_XXX.cpp.json, and all was well. Clearly, the consumer of the moc_XXX.cpp.json files expects them to be generated by AUTOMOC. Fix this by - using absolute paths for the generated files to make sure target_sources gets the correct paths - removing the qt6_wrap_cpp call Fixes: QTBUG-110117 Change-Id: I01bcd8e37f57cf30ea06a7dd1fd8844367b58a14 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> (cherry picked from commit 2d97f9bdf0d21997a6ee7e43d1364803842aa635) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/qml/Qt6QmlMacros.cmake12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index 2205d178cd..ba3270f0f6 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -2237,8 +2237,17 @@ function(qt6_generate_foreign_qml_types source_target destination_qml_target)
message(FATAL_ERROR "Need target metatypes.json file")
endif()
+ get_target_property(automoc_enabled ${destination_qml_target} AUTOMOC)
+ if(NOT automoc_enabled)
+ message(FATAL_ERROR "qt6_generate_foreign_qml_types requires AUTOMOC to be enabled "
+ "on target '${destination_qml_target}'.")
+ endif()
+
set(registration_files_base ${source_target}_${destination_qml_target})
- set(additional_sources ${registration_files_base}.cpp ${registration_files_base}.h)
+ set(additional_sources
+ "${CMAKE_CURRENT_BINARY_DIR}/${registration_files_base}.cpp"
+ "${CMAKE_CURRENT_BINARY_DIR}/${registration_files_base}.h"
+ )
_qt_internal_get_tool_wrapper_script_path(tool_wrapper)
add_custom_command(
@@ -2259,7 +2268,6 @@ function(qt6_generate_foreign_qml_types source_target destination_qml_target)
)
target_sources(${destination_qml_target} PRIVATE ${additional_sources})
- qt6_wrap_cpp(${additional_sources} TARGET ${destination_qml_target})
endfunction()
if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)