Put the QML plugins to the non-config directory
The generated qmldir files that are used by QML engine specify the relative path to the QML plugins that are build within modules. So it's usually expected that plugins are located on the same level as the qmldir files. In Multi-Config builds all libraries are located in the build-specific directories by default. In this case QML engine is unable to locate the plugin and the application cannot be run without extra manual steps. This fixes this issue, by using the top-level plugin OUTPUT_DIRECTORY for the "default"(first) config as RUNTIME/LIBRARY_OUTPUT_DIRECTORY. In Windows platforms we need to make the same for non-static backing libraries, since we cannot rely on RPATH there. Task-number: QTBUG-99061 Pick-to: 6.2 6.5 6.6 6.7 Change-Id: I51a8864743b87fd6ec4ba7179e13f311c5bee403 Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
48241a49d9
commit
2dbae968e7
|
@ -1828,6 +1828,35 @@ function(_qt_internal_qml_get_symbols_to_keep
|
|||
set(${out_var_constructor} "${constructor_content}" PARENT_SCOPE)
|
||||
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
|
||||
|
@ -2106,6 +2135,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}")
|
||||
|
|
Loading…
Reference in New Issue