Consider the main target flags related properties when building object libraries

The object libraries that are side products from building plugins
should also consider the properties that control the flag handling of
their main plugin targets, otherwise they will inherit the
PlatformInternal flags without knowing what their parent decide.

Functionality now considers QT_SKIP_WARNINGS_ARE_ERRORS and
_qt_internal_use_exceptions properties. The list can be extended in the
future.

Change-Id: If304b3b382d6cd05064bc87e11d3cc87ba7c0d7b
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
Alexey Edelev 2024-09-10 18:20:51 +02:00
parent ed57f8ab6d
commit f90e29fd5c
3 changed files with 12 additions and 2 deletions

View File

@ -339,7 +339,8 @@ function(qt_internal_add_plugin target)
if(target_type STREQUAL STATIC_LIBRARY)
if(qt_module_target)
qt_internal_link_internal_platform_for_object_library("${plugin_init_target}")
qt_internal_link_internal_platform_for_object_library("${plugin_init_target}"
PARENT_TARGET "${target}")
endif()
endif()

View File

@ -111,7 +111,8 @@ function(qt_internal_record_rcc_object_files target resource_targets)
endif()
set_property(TARGET ${target} APPEND PROPERTY _qt_rcc_objects "${rcc_object_file_path}")
qt_internal_link_internal_platform_for_object_library("${out_target}")
qt_internal_link_internal_platform_for_object_library("${out_target}"
PARENT_TARGET "${target}")
endforeach()
endfunction()

View File

@ -1457,6 +1457,7 @@ function(qt_internal_is_target_skipped_for_examples target out_var)
endfunction()
function(qt_internal_link_internal_platform_for_object_library target)
cmake_parse_arguments(arg "" "PARENT_TARGET" "" ${ARGN})
# We need to apply iOS bitcode flags to object libraries that are associated with internal
# modules or plugins (e.g. object libraries added by qt_internal_add_resource,
# qt_internal_add_plugin, etc.)
@ -1464,6 +1465,13 @@ function(qt_internal_link_internal_platform_for_object_library target)
# present by default.
# Achieve this by compiling the cpp files with the PlatformModuleInternal compile flags.
target_link_libraries("${target}" PRIVATE Qt::PlatformModuleInternal)
if(arg_PARENT_TARGET AND TARGET "${arg_PARENT_TARGET}")
foreach(property QT_SKIP_WARNINGS_ARE_ERRORS _qt_internal_use_exceptions)
set_property(TARGET "${target}" PROPERTY
${property} "$<BOOL:$<TARGET_PROPERTY:${arg_PARENT_TARGET},${property}>>")
endforeach()
endif()
endfunction()
# Use ${dep_target}'s include dirs when building ${target}.