From bb25536a3db657b41ae31e1690d230ef8722b57d Mon Sep 17 00:00:00 2001 From: Alexandru Croitor Date: Wed, 30 Jun 2021 12:37:14 +0200 Subject: 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 Reviewed-by: Assam Boudjelthia Reviewed-by: Alexandru Croitor --- cmake/FindWrapVulkanHeaders.cmake | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 cmake/FindWrapVulkanHeaders.cmake (limited to 'cmake/FindWrapVulkanHeaders.cmake') diff --git a/cmake/FindWrapVulkanHeaders.cmake b/cmake/FindWrapVulkanHeaders.cmake new file mode 100644 index 0000000000..a079e07300 --- /dev/null +++ b/cmake/FindWrapVulkanHeaders.cmake @@ -0,0 +1,23 @@ +# 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 WrapVulkanHeaders::WrapVulkanHeaders) + set(WrapVulkanHeaders_FOUND ON) + return() +endif() + +set(WrapVulkanHeaders_FOUND OFF) + +find_package(Vulkan ${WrapVulkanHeaders_FIND_VERSION} QUIET) + +# We are interested only in include headers. The libraries might be missing, so we can't check the +# _FOUND variable. +if(Vulkan_INCLUDE_DIR) + set(WrapVulkanHeaders_FOUND ON) + + add_library(WrapVulkanHeaders::WrapVulkanHeaders INTERFACE IMPORTED) + target_include_directories(WrapVulkanHeaders::WrapVulkanHeaders INTERFACE + ${Vulkan_INCLUDE_DIR}) +endif() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(WrapVulkanHeaders DEFAULT_MSG Vulkan_INCLUDE_DIR) -- cgit v1.2.3