summaryrefslogtreecommitdiffstats
path: root/cmake/QtPriHelpers.cmake
diff options
context:
space:
mode:
authorAlexandru Croitor <alexandru.croitor@qt.io>2021-07-27 13:54:56 +0200
committerAlexandru Croitor <alexandru.croitor@qt.io>2021-07-29 16:38:50 +0200
commit3c233175523a61e734dd5cd9bdcbb2994566f7f0 (patch)
treee86357c7c9a383f8ebcbb19488ef6bf5e167a752 /cmake/QtPriHelpers.cmake
parent3b2157ed9e738ea03028afd5e8a71b5c54eb3937 (diff)
CMake: Make WrapVulkanHeaders target optional for QtGui consumers
If Vulkan headers are present on the system when qtbase is configured, QtGui and QtOpenGL should be compiled with Vulkan support. If a user project uses a Qt built with Vulkan support, but their system is missing Vulkan headers, the project configuration needs to succeed. The project will get compilation errors if it uses Vulkan headers, but that's intended. This use case was broken when fixing Vulkan to be found when building Qt for Android. Fix the regression with a combination of things 1) Mark the WrapVulkanHeaders package as optional (already the case) 2) Use the include directories directly when compiling Gui and OpenGL 3) Propagate WrapVulkanHeaders::WrapVulkanHeaders link requirement to consumers only if the target exists. It won't exist if Vulkan include dirs are not found This also requires some changes in pri and prl file generation. For prl file generation, we don't want to link to the WrapVulkanHeaders target, so we filter out all dependencies that use TARGET_NAME_IF_EXISTS for anything that calls __qt_internal_walk_libs which includes qt_collect_libs. For pri files, we make sure to generate a uses=vulkan/nolink clause by inspecting a new _qt_is_nolink_target property on the target. We also don't add include dirs to the pri file if the new _qt_skip_include_dir_for_pri property is set. This is intended for Vulkan, because there is separate qmake logic to try and find the include dirs when configuring a user project. As a drive-by, fix nolink handling for WrapOpenSSLHeaders. Amends bb25536a3db657b41ae31e1690d230ef8722b57d Amends 7b9904849fe1a43f0db8216076a9e974ebca5c78 Pick-to: 6.2 Fixes: QTBUG-95391 Change-Id: I21e2f4be5c386f9e40033e4691f4786a91ba0e2d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'cmake/QtPriHelpers.cmake')
-rw-r--r--cmake/QtPriHelpers.cmake36
1 files changed, 33 insertions, 3 deletions
diff --git a/cmake/QtPriHelpers.cmake b/cmake/QtPriHelpers.cmake
index 49d7310db4..fa31ea9a5c 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 "$<TARGET_LINKER_FILE:${lib_target}>")
endif()
list(APPEND lib_libdir "$<TARGET_PROPERTY:${lib_target},INTERFACE_LINK_DIRECTORIES>")
- list(APPEND lib_incdir "$<TARGET_PROPERTY:${lib_target},INTERFACE_INCLUDE_DIRECTORIES>")
+
+ 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
+ "$<TARGET_PROPERTY:${lib_target},INTERFACE_INCLUDE_DIRECTORIES>")
+ endif()
+
+ list(APPEND lib_incdir "${target_include_dir}")
list(APPEND lib_defines "$<TARGET_PROPERTY:${lib_target},INTERFACE_COMPILE_DEFINITIONS>")
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 "^\\$<TARGET_NAME_IF_EXISTS:(.*)>$")
+ 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}")