aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/Qt6QmlMacros.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/Qt6QmlMacros.cmake')
-rw-r--r--src/qml/Qt6QmlMacros.cmake31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/qml/Qt6QmlMacros.cmake b/src/qml/Qt6QmlMacros.cmake
index d805d37feb..cc38a30998 100644
--- a/src/qml/Qt6QmlMacros.cmake
+++ b/src/qml/Qt6QmlMacros.cmake
@@ -994,6 +994,35 @@ function(_qt_internal_write_deferred_qmldir_file target)
endfunction()
+function(_qt_internal_set_qml_target_multi_config_output_directory target output_directory)
+ # In multi-config builds we need to make sure that at least one configuration has the dynamic
+ # plugin that is located next to qmldir file, otherwise QML engine won't be able to load the
+ # plugin.
+ get_cmake_property(is_multi_config GENERATOR_IS_MULTI_CONFIG)
+ if(is_multi_config)
+ # We don't care about static plugins here since, they are linked at build time and
+ # their location doesn't affect the runtime.
+ get_target_property(target_type ${target} TYPE)
+ if(target_type STREQUAL "SHARED_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY")
+ if(NOT "${output_directory}")
+ set(output_directory "${CMAKE_CURRENT_BINARY_DIR}")
+ endif()
+
+ list(GET CMAKE_CONFIGURATION_TYPES 0 default_config)
+ string(JOIN "" output_directory_with_default_config
+ "$<IF:$<CONFIG:${default_config}>,"
+ "${output_directory},"
+ "${output_directory}/$<CONFIG>"
+ ">"
+ )
+ set_target_properties(${target} PROPERTIES
+ RUNTIME_OUTPUT_DIRECTORY "${output_directory_with_default_config}"
+ LIBRARY_OUTPUT_DIRECTORY "${output_directory_with_default_config}"
+ )
+ endif()
+ endif()
+endfunction()
+
function(qt6_add_qml_plugin target)
set(args_option
STATIC
@@ -1188,6 +1217,8 @@ function(qt6_add_qml_plugin target)
)
endif()
+ _qt_internal_set_qml_target_multi_config_output_directory(${target} "${arg_OUTPUT_DIRECTORY}")
+
if(NOT arg_NO_GENERATE_PLUGIN_SOURCE)
set(generated_cpp_file_name_base "${target}_${arg_CLASS_NAME}")
set(register_types_function_name "qml_register_types_${escaped_uri}")