diff --git a/cmake/FindWrapOpenSSLHeaders.cmake b/cmake/FindWrapOpenSSLHeaders.cmake index ea422a68ba6..afaf77ac482 100644 --- a/cmake/FindWrapOpenSSLHeaders.cmake +++ b/cmake/FindWrapOpenSSLHeaders.cmake @@ -28,6 +28,9 @@ if(OPENSSL_INCLUDE_DIR) add_library(WrapOpenSSLHeaders::WrapOpenSSLHeaders INTERFACE IMPORTED) target_include_directories(WrapOpenSSLHeaders::WrapOpenSSLHeaders INTERFACE ${OPENSSL_INCLUDE_DIR}) + + set_target_properties(WrapOpenSSLHeaders::WrapOpenSSLHeaders PROPERTIES + _qt_is_nolink_target TRUE) endif() include(FindPackageHandleStandardArgs) diff --git a/cmake/FindWrapVulkanHeaders.cmake b/cmake/FindWrapVulkanHeaders.cmake index 766f1e29eb4..ccbcf7f7082 100644 --- a/cmake/FindWrapVulkanHeaders.cmake +++ b/cmake/FindWrapVulkanHeaders.cmake @@ -18,6 +18,12 @@ if(Vulkan_INCLUDE_DIR) target_include_directories(WrapVulkanHeaders::WrapVulkanHeaders INTERFACE ${Vulkan_INCLUDE_DIR}) + set_target_properties(WrapVulkanHeaders::WrapVulkanHeaders PROPERTIES + _qt_is_nolink_target TRUE) + + set_target_properties(WrapVulkanHeaders::WrapVulkanHeaders PROPERTIES + _qt_skip_include_dir_for_pri TRUE) + # Also propagate MoltenVK include directory on Apple platforms if found. # Assumes the folder structure of the LunarG Vulkan SDK. if(APPLE) diff --git a/cmake/QtFindPackageHelpers.cmake b/cmake/QtFindPackageHelpers.cmake index 9f8ae1a9a9e..da0b19a8d5f 100644 --- a/cmake/QtFindPackageHelpers.cmake +++ b/cmake/QtFindPackageHelpers.cmake @@ -269,6 +269,29 @@ function(qt_record_extra_qt_main_tools_package_dependency main_target_name "${main_target_name}" "${qtfied_package_name_versioned}" "${dep_package_version}") endfunction() +# Record an extra 3rd party target as a dependency for ${main_target_name}. +# +# Adds a find_package(${dep_target_package_name}) in ${main_target_name}Dependencies.cmake. +# +# Needed to record a dependency on the package that provides WrapVulkanHeaders::WrapVulkanHeaders. +# The package version, components, whether the package is optional, etc, are queried from the +# ${dep_target} target properties. +function(qt_record_extra_third_party_dependency main_target_name dep_target) + if(NOT TARGET "${main_target_name}") + qt_get_tool_target_name(main_target_name "${main_target_name}") + endif() + if(TARGET "${main_target_name}") + get_target_property(extra_deps "${main_target_name}" _qt_extra_third_party_dep_targets) + if(NOT extra_deps) + set(extra_deps "") + endif() + + list(APPEND extra_deps "${dep_target}") + set_target_properties("${main_target_name}" PROPERTIES _qt_extra_third_party_dep_targets + "${extra_deps}") + endif() +endfunction() + # This function stores the list of Qt targets a library depend on, # along with their version info, for usage in ${target}Depends.cmake file function(qt_register_target_dependencies target public_libs private_libs) diff --git a/cmake/QtPostProcessHelpers.cmake b/cmake/QtPostProcessHelpers.cmake index 5d3e9492062..248989c81cd 100644 --- a/cmake/QtPostProcessHelpers.cmake +++ b/cmake/QtPostProcessHelpers.cmake @@ -25,7 +25,7 @@ macro(qt_collect_third_party_deps target) endif() unset(_target_is_static) - foreach(dep ${${depends_var}} ${optional_public_depends}) + foreach(dep ${${depends_var}} ${optional_public_depends} ${extra_third_party_deps}) # Gather third party packages that should be found when using the Qt module. # Also handle nolink target dependencies. string(REGEX REPLACE "_nolink$" "" base_dep "${dep}") @@ -138,6 +138,12 @@ function(qt_internal_create_module_depends_file target) list(APPEND target_deps "${extra_depends}") endif() + # Extra 3rd party targets who's packages should be considered dependencies. + get_target_property(extra_third_party_deps "${target}" _qt_extra_third_party_dep_targets) + if(NOT extra_third_party_deps) + set(extra_third_party_deps "") + endif() + # Used for assembling the content of an include/Module/ModuleDepends.h header. set(qtdeps "") diff --git a/cmake/QtPriHelpers.cmake b/cmake/QtPriHelpers.cmake index 49d7310db4e..fa31ea9a5c0 100644 --- a/cmake/QtPriHelpers.cmake +++ b/cmake/QtPriHelpers.cmake @@ -36,7 +36,16 @@ function(qt_generate_qmake_libraries_pri_content module_name output_root_dir out list(APPEND lib_libs "$") endif() list(APPEND lib_libdir "$") - list(APPEND lib_incdir "$") + + get_target_property(skip_include_dir "${lib_target}" _qt_skip_include_dir_for_pri) + if(skip_include_dir) + set(target_include_dir "") + else() + set(target_include_dir + "$") + endif() + + list(APPEND lib_incdir "${target_include_dir}") list(APPEND lib_defines "$") else() if(lib_target MATCHES "/([^/]+).framework$") @@ -120,14 +129,35 @@ function(qt_get_direct_module_dependencies target out_var) endfunction() # Return a list of qmake library names for a given list of targets. -# For example, Vulkan::Vulkan_nolink is mapped to vulkan/nolink. +# For example, Foo::Foo_nolink is mapped to foo/nolink. +# Also targets with the _qt_is_nolink_target property are mapped to nolink as well. function(qt_internal_map_targets_to_qmake_libs out_var) set(result "") foreach(target ${ARGN}) + # Unwrap optional targets. Needed for Vulkan. + if(target MATCHES "^\\$$") + set(target ${CMAKE_MATCH_1}) + endif() + + set(is_no_link_target FALSE) + + # First case of detecting nolink targets (possibly not needed anymore) string(REGEX REPLACE "_nolink$" "" stripped_target "${target}") + if(NOT target STREQUAL stripped_target) + set(is_no_link_target TRUE) + endif() + + # Second case of detecting nolink targets. + if(TARGET "${target}") + get_target_property(marked_as_no_link_target "${target}" _qt_is_nolink_target) + if(marked_as_no_link_target) + set(is_no_link_target TRUE) + endif() + endif() + qt_internal_map_target_to_qmake_lib(${stripped_target} qmake_lib) if(NOT "${qmake_lib}" STREQUAL "") - if(NOT target STREQUAL stripped_target) + if(is_no_link_target) string(APPEND qmake_lib "/nolink") endif() list(APPEND result "${qmake_lib}") diff --git a/cmake/QtPublicWalkLibsHelpers.cmake b/cmake/QtPublicWalkLibsHelpers.cmake index 19eef91356a..7267bc96779 100644 --- a/cmake/QtPublicWalkLibsHelpers.cmake +++ b/cmake/QtPublicWalkLibsHelpers.cmake @@ -148,6 +148,13 @@ function(__qt_internal_walk_libs continue() endif() + # Skip optional dependencies for now. They are likely to be handled manually for prl + # file purposes (like nolink handling). And for one of the other operations, we don't + # have a use case yet. This might be revisited. + if(lib MATCHES "^\\$") + + target_link_libraries("${target}" INTERFACE "$") + + qt_record_extra_third_party_dependency("${target}" "${dep_target}") +endfunction() diff --git a/src/gui/CMakeLists.txt b/src/gui/CMakeLists.txt index 1befa1612da..378ea3e3215 100644 --- a/src/gui/CMakeLists.txt +++ b/src/gui/CMakeLists.txt @@ -869,9 +869,11 @@ qt_internal_extend_target(Gui CONDITION QT_FEATURE_vulkan vulkan/qvulkanfunctions.cpp vulkan/qvulkaninstance.cpp vulkan/qvulkaninstance.h vulkan/qvulkanwindow.cpp vulkan/qvulkanwindow.h vulkan/qvulkanwindow_p.h - PUBLIC_LIBRARIES - WrapVulkanHeaders::WrapVulkanHeaders ) +if(QT_FEATURE_vulkan) + qt_internal_add_target_include_dirs_and_optionally_propagate( + Gui WrapVulkanHeaders::WrapVulkanHeaders) +endif() #### Keys ignored in scope 111:.:vulkan:vulkan/vulkan.pri:QT_FEATURE_vkgen: # special case begin diff --git a/src/opengl/CMakeLists.txt b/src/opengl/CMakeLists.txt index 11345b5dc1d..03ace0cad77 100644 --- a/src/opengl/CMakeLists.txt +++ b/src/opengl/CMakeLists.txt @@ -90,9 +90,11 @@ qt_internal_extend_target(OpenGL CONDITION NOT QT_FEATURE_opengles2 qt_internal_extend_target(OpenGL CONDITION QT_FEATURE_vulkan SOURCES qvkconvenience.cpp qvkconvenience_p.h - PUBLIC_LIBRARIES - WrapVulkanHeaders::WrapVulkanHeaders ) +if(QT_FEATURE_vulkan) + qt_internal_add_target_include_dirs_and_optionally_propagate( + OpenGL WrapVulkanHeaders::WrapVulkanHeaders) +endif() qt_internal_extend_target(OpenGL CONDITION QT_FEATURE_egl SOURCES