diff options
Diffstat (limited to 'cmake/QtTargetHelpers.cmake')
-rw-r--r-- | cmake/QtTargetHelpers.cmake | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index e669047ff1..d361a8096d 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -99,10 +99,13 @@ function(qt_internal_extend_target target) get_target_property(target_type ${target} TYPE) set(is_library FALSE) set(is_interface_lib FALSE) + set(is_executable FALSE) if(${target_type} STREQUAL "STATIC_LIBRARY" OR ${target_type} STREQUAL "SHARED_LIBRARY") set(is_library TRUE) elseif(target_type STREQUAL "INTERFACE_LIBRARY") set(is_interface_lib TRUE) + elseif(target_type STREQUAL "EXECUTABLE") + set(is_executable TRUE) endif() foreach(lib ${arg_PUBLIC_LIBRARIES} ${arg_LIBRARIES}) @@ -273,6 +276,20 @@ function(qt_internal_extend_target target) set_target_properties(${target} PROPERTIES _qt_extra_linker_script_exports "${arg_EXTRA_LINKER_SCRIPT_EXPORTS}") endif() + + if(is_executable) + # If linking against Gui, make sure to also build the default QPA plugin. + # This makes the experience of an initial Qt configuration to build and run one single + # test / executable nicer. + set(linked_libs ${arg_PUBLIC_LIBRARIES} ${arg_LIBRARIES}) + if(linked_libs MATCHES "(^|;)(${QT_CMAKE_EXPORT_NAMESPACE}::|Qt::)?Gui($|;)" AND + TARGET qpa_default_plugins) + add_dependencies("${target}" qpa_default_plugins) + endif() + + # For executables collect static plugins that these targets depend on. + qt_internal_import_plugins(${target} ${linked_libs}) + endif() endfunction() # Given CMAKE_CONFIG and ALL_CMAKE_CONFIGS, determines if a directory suffix needs to be appended @@ -462,6 +479,7 @@ function(qt_internal_setup_cmake_config_postfix) # If postfix is set by user avoid changing it, but save postfix variable that has # a non-default value for further warning. if("${${postfix_var}}" STREQUAL "") + set(${postfix_var} "${${default_postfix_var}}") set(${postfix_var} "${${default_postfix_var}}" PARENT_SCOPE) elseif(NOT "${${postfix_var}}" STREQUAL "${${default_postfix_var}}") list(APPEND custom_postfix_vars ${postfix_var}) |