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.6 6.5 6.2
Change-Id: I51a8864743b87fd6ec4ba7179e13f311c5bee403
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
(cherry picked from commit 2dbae968e7
)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
476adce4a7
commit
91a25a8e3c
|
@ -1826,6 +1826,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
|
||||
|
@ -2104,6 +2133,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