diff options
author | Andrei Golubev <andrei.golubev@qt.io> | 2021-10-20 11:14:52 +0200 |
---|---|---|
committer | Andrei Golubev <andrei.golubev@qt.io> | 2021-11-16 09:02:57 +0100 |
commit | 6ec7953257ef1155aef8a0a4b8379205ee850283 (patch) | |
tree | 1dac0463d8500bb3a90c37095a09890607423ec7 /src/qml/Qt6QmlMacros.cmake | |
parent | 88dfbe0deaa780f1cb5793d644341367d02e3073 (diff) |
qmltc: support user-specified namespaces in the generated code
Already during the prototyping phase, conflicts in class names were
encountered within Qt code base. Those could be avoided by namespaces.
Initial qmltc logic was using meaningless "q_qmltc" namespace, so let's
improve that by allowing user-specified namespaces + making Qt's own
QML files (compiled to C++) being available under QT_NAMESPACE. The
latter is achieved by providing (and using) the internal version of a
qmltc-invoking function
Task-number: QTBUG-84368
Task-number: QTBUG-96040
Change-Id: I99cdf1baba8838c093b6b469f6744869f72af093
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/Qt6QmlMacros.cmake')
-rw-r--r-- | src/qml/Qt6QmlMacros.cmake | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake index 7374b7d16e..d7ff650c1b 100644 --- a/src/qml/Qt6QmlMacros.cmake +++ b/src/qml/Qt6QmlMacros.cmake @@ -1014,7 +1014,7 @@ endfunction() # Compile Qml files (.qml) to C++ source files with Qml Type Compiler (qmltc). function(qt6_target_compile_qml_to_cpp target) set(args_option "") - set(args_single "") + set(args_single NAMESPACE) set(args_multi FILES) # TODO: add qmltypes argument @@ -1056,6 +1056,11 @@ function(qt6_target_compile_qml_to_cpp target) set(qmltc_executable "$<COMMAND_CONFIG:${qmltc_executable}>") endif() + set(common_args "") + if(arg_NAMESPACE) + list(APPEND common_args --namespace "${arg_NAMESPACE}") + endif() + foreach(qml_file_src IN LISTS arg_FILES) if(NOT qml_file_src MATCHES "\\.(qml)$") list(APPEND non_qml_files ${qml_file_src}) @@ -1096,6 +1101,7 @@ function(qt6_target_compile_qml_to_cpp target) --header "${compiled_header}" --impl "${compiled_cpp}" --resource-path "${file_resource_path}" + ${common_args} ${file_absolute} COMMAND_EXPAND_LISTS DEPENDS |