qt5base-lts/cmake/FindWrapVulkan.cmake
Alexandru Croitor bb25536a3d CMake: Fix Vulkan to be found when targeting Android
Introduce two new packages WrapVulkanHeaders and WrapVulkan similar to
the OpenSSL wrapper packages.

WrapVulkanHeaders uses FindVulkan and is marked as found if Vulkan
headers are found (that's the only part the Qt build requires).

The WrapVulkan package is currently not used, but is there for
symmetry.

The Vulkan feature is now disabled by default on QNX, because the
QNX toolchain file in the CI does not set
CMAKE_FIND_ROOT_PATH_MODE-like variables and CMake ends up finding
host Vulkan headers causing the build to break.

Pick-to: 6.2
Fixes: QTBUG-92157
Change-Id: I05309821f866456cd42e7f85bf8b76ba099df656
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-07-01 18:57:50 +02:00

21 lines
681 B
CMake

# We can't create the same interface imported target multiple times, CMake will complain if we do
# that. This can happen if the find_package call is done in multiple different subdirectories.
if(TARGET WrapVulkan::WrapVulkan)
set(WrapVulkan_FOUND ON)
return()
endif()
set(WrapVulkan_FOUND OFF)
find_package(Vulkan ${WrapVulkan_FIND_VERSION} QUIET)
if(Vulkan_FOUND)
set(WrapVulkan_FOUND ON)
add_library(WrapVulkan::WrapVulkan INTERFACE IMPORTED)
target_link_libraries(WrapVulkan::WrapVulkan INTERFACE Vulkan::Vulkan)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(WrapVulkan DEFAULT_MSG Vulkan_LIBRARY Vulkan_INCLUDE_DIR)