CMake: Fix exclusion of QtFoo in QtBarDepends for 3rd party libs

When configuring a static Qt with the -qt-zlib option and the build
system creates a 3rd party header module QtZlib, syncqt
does not generate a QtZlib header file that would include all its
public headers.

Then when the QtSvgDepends header is generated, it would add an
 #include <QtZlib> which would break compilation of the QtSvg PCH
file (which compiles QtSvgDepends).

We have logic to exclude addition of headers from regular 3rd party
static libraries, but not header only 3rd party libraries.

Adjust the code to handle header-only 3rd party libraries, as well as
make sure it works across repos by exporting the relevant properties.

As a drive-by, also rename and export some other informational
properties.

Amends af00402d64
Amends 6fdeaea24f
Amends be2745e478

Pick-to: 6.2 6.3
Change-Id: I087f50b193dd845e4a5ec906e8851d63122faf80
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
This commit is contained in:
Alexandru Croitor 2022-02-22 16:57:00 +01:00
parent 2f6faca901
commit 56abd7e4e0
3 changed files with 39 additions and 22 deletions

View File

@ -181,9 +181,14 @@ function(qt_internal_add_3rdparty_library target)
ARCHIVE_OUTPUT_DIRECTORY "${QT_BUILD_DIR}/${INSTALL_LIBDIR}"
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
QT_MODULE_IS_3RDPARTY_LIBRARY TRUE
QT_MODULE_SKIP_DEPENDS_INCLUDE TRUE
_qt_module_is_3rdparty_library TRUE
_qt_module_skip_depends_include TRUE
)
set_property(TARGET "${target}"
APPEND PROPERTY EXPORT_PROPERTIES _qt_module_is_3rdparty_library)
set_property(TARGET "${target}"
APPEND PROPERTY EXPORT_PROPERTIES _qt_module_skip_depends_include)
qt_handle_multi_config_output_dirs("${target}")
set_target_properties(${target} PROPERTIES
@ -335,4 +340,13 @@ function(qt_internal_add_3rdparty_header_module target)
EXTERNAL_HEADERS ${arg_EXTERNAL_HEADERS}
EXTERNAL_HEADERS_DIR ${arg_EXTERNAL_HEADERS_DIR}
)
set_target_properties(${target} PROPERTIES
_qt_module_is_3rdparty_header_library TRUE
_qt_module_skip_depends_include TRUE
)
set_property(TARGET "${target}"
APPEND PROPERTY EXPORT_PROPERTIES _qt_module_is_3rdparty_header_library)
set_property(TARGET "${target}"
APPEND PROPERTY EXPORT_PROPERTIES _qt_module_skip_depends_include)
endfunction()

View File

@ -278,7 +278,9 @@ function(qt_internal_add_module target)
endif()
if (arg_SKIP_DEPENDS_INCLUDE)
set_target_properties(${target} PROPERTIES QT_MODULE_SKIP_DEPENDS_INCLUDE TRUE)
set_target_properties(${target} PROPERTIES _qt_module_skip_depends_include TRUE)
set_property(TARGET "${target}" APPEND PROPERTY
EXPORT_PROPERTIES _qt_module_skip_depends_include)
endif()
if(is_framework)
set_target_properties(${target} PROPERTIES

View File

@ -178,24 +178,25 @@ function(qt_internal_create_module_depends_file target)
# Normalize module by stripping leading "Qt::" and trailing "Private"
if (dep MATCHES "(Qt|${QT_CMAKE_EXPORT_NAMESPACE})::([-_A-Za-z0-9]+)")
set(dep "${CMAKE_MATCH_2}")
if (TARGET Qt::${dep})
get_target_property(dep_type Qt::${dep} TYPE)
if (NOT dep_type STREQUAL "INTERFACE_LIBRARY")
get_target_property(skip_module_depends_include Qt::${dep} QT_MODULE_SKIP_DEPENDS_INCLUDE)
if (skip_module_depends_include)
continue()
endif()
else()
get_target_property(is_versionless_target Qt::${dep} _qt_is_versionless_target)
set(real_dep_target "Qt::${dep}")
if(TARGET "${real_dep_target}")
get_target_property(is_versionless_target "${real_dep_target}"
_qt_is_versionless_target)
if(is_versionless_target)
get_target_property(module_has_headers ${QT_CMAKE_EXPORT_NAMESPACE}::${dep}
_qt_module_has_headers)
else()
get_target_property(module_has_headers Qt::${dep} _qt_module_has_headers)
set(real_dep_target "${QT_CMAKE_EXPORT_NAMESPACE}::${dep}")
endif()
if (NOT module_has_headers)
get_target_property(skip_module_depends_include "${real_dep_target}"
_qt_module_skip_depends_include)
if(skip_module_depends_include)
continue()
endif()
get_target_property(module_has_headers "${real_dep_target}"
_qt_module_has_headers)
if(NOT module_has_headers)
continue()
endif()
endif()
endif()
@ -742,7 +743,7 @@ function(qt_internal_create_config_file_for_standalone_tests)
continue()
endif()
get_target_property(is_3rd_party "${m}" QT_MODULE_IS_3RDPARTY_LIBRARY)
get_target_property(is_3rd_party "${m}" _qt_module_is_3rdparty_library)
if(NOT is_3rd_party)
list(APPEND modules "${m}")
endif()