From 548440dd4bc1f92bef41863819ecaf054d924b6c Mon Sep 17 00:00:00 2001 From: Alexey Edelev Date: Wed, 10 Aug 2022 15:58:15 +0200 Subject: [PATCH] Remove HEADER_MODULE from qt_internal_extend_target MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current qt_internal_extend_target interface expects that the caller will pass the HEADER_MODULE argument on each call. This is not correct, since the argument doesn't affect the target internals, but only help to decide how to modify the target according to its type. The target type meanwhile can be always read from target properties. So this solution is more consistent. Change-Id: Ie84a2226ceb71cb5272670e5d43bdfc7a101360a Reviewed-by: Jörg Bornemann Reviewed-by: Qt CI Bot --- cmake/QtModuleHelpers.cmake | 1 - cmake/QtTargetHelpers.cmake | 16 ++++++++++------ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cmake/QtModuleHelpers.cmake b/cmake/QtModuleHelpers.cmake index de36e53ad8..ce07945ec3 100644 --- a/cmake/QtModuleHelpers.cmake +++ b/cmake/QtModuleHelpers.cmake @@ -545,7 +545,6 @@ function(qt_internal_add_module target) qt_internal_add_repo_local_defines("${target}") qt_internal_extend_target("${target}" - ${header_module} SOURCES ${arg_SOURCES} INCLUDE_DIRECTORIES ${private_includes} diff --git a/cmake/QtTargetHelpers.cmake b/cmake/QtTargetHelpers.cmake index 4106fe66af..fefc582f04 100644 --- a/cmake/QtTargetHelpers.cmake +++ b/cmake/QtTargetHelpers.cmake @@ -13,7 +13,7 @@ function(qt_internal_extend_target target) if (NOT TARGET "${target}") message(FATAL_ERROR "Trying to extend non-existing target \"${target}\".") endif() - qt_parse_all_arguments(arg "qt_extend_target" "HEADER_MODULE" "PRECOMPILED_HEADER" + qt_parse_all_arguments(arg "qt_extend_target" "" "PRECOMPILED_HEADER" "CONDITION;${__default_public_args};${__default_private_args};${__default_private_module_args};COMPILE_FLAGS;NO_PCH_SOURCES" ${ARGN}) if ("x${arg_CONDITION}" STREQUAL x) set(arg_CONDITION ON) @@ -37,9 +37,13 @@ function(qt_internal_extend_target target) get_target_property(target_type ${target} TYPE) set(is_library FALSE) + set(is_interface_lib 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) endif() + foreach(lib ${arg_PUBLIC_LIBRARIES} ${arg_LIBRARIES}) # Automatically generate PCH for 'target' using public dependencies. # But only if 'target' is a library/module that does not specify its own PCH file. @@ -58,9 +62,9 @@ function(qt_internal_extend_target target) # CMake versions less than 3.19 don't support adding the source files to the PRIVATE scope # of the INTERFACE libraries. These PRIVATE sources are only needed by IDEs to display # them in a project tree, so to avoid build issues and appearing the sources in - # INTERFACE_SOURCES property of HEADER_MODULE let's simply exclude them for compatibility - # with CMake versions less than 3.19. - if(NOT arg_HEADER_MODULE OR CMAKE_VERSION VERSION_GREATER_EQUAL "3.19") + # INTERFACE_SOURCES property of INTERFACE_LIBRARY let's simply exclude them for + # compatibility with CMake versions less than 3.19. + if(NOT is_interface_lib OR CMAKE_VERSION VERSION_GREATER_EQUAL "3.19") target_sources("${target}" PRIVATE ${arg_SOURCES} ${dbus_sources}) if (arg_COMPILE_FLAGS) set_source_files_properties(${arg_SOURCES} PROPERTIES @@ -70,7 +74,7 @@ function(qt_internal_extend_target target) set(public_visibility_option "PUBLIC") set(private_visibility_option "PRIVATE") - if(arg_HEADER_MODULE) + if(is_interface_lib) set(public_visibility_option "INTERFACE") set(private_visibility_option "INTERFACE") endif() @@ -90,7 +94,7 @@ function(qt_internal_extend_target target) ${public_visibility_option} ${arg_PUBLIC_LINK_OPTIONS} ${private_visibility_option} ${arg_LINK_OPTIONS}) - if(NOT arg_HEADER_MODULE) + if(NOT is_interface_lib) set_property (TARGET "${target}" APPEND PROPERTY AUTOMOC_MOC_OPTIONS "${arg_MOC_OPTIONS}" )