From 4211068f10d22f3c3d8d97147fbfb8186dac5c74 Mon Sep 17 00:00:00 2001 From: Charles Giessen Date: Mon, 1 Mar 2021 20:59:49 -0700 Subject: [PATCH] cmake: Add VK_BOOTSTRAP_VULKAN_HEADER_DIR build option --- CMakeLists.txt | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f9e0f1..8766779 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,19 +2,27 @@ cmake_minimum_required(VERSION 3.10 FATAL_ERROR) project(VulkanBootstrap) add_library(vk-boostrap-vulkan-headers INTERFACE) -find_package(Vulkan QUIET) -if(${Vulkan_INCLUDE_DIR} STREQUAL "Vulkan_INCLUDE_DIR-NOTFOUND") - include(FetchContent) - FetchContent_Declare( - VulkanHeaders - GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers - GIT_TAG v1.2.171 - ) - FetchContent_MakeAvailable(VulkanHeaders) - target_link_libraries(vk-boostrap-vulkan-headers INTERFACE Vulkan::Headers) -else() - set_target_properties(vk-boostrap-vulkan-headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${Vulkan_INCLUDE_DIR}) +set(VK_BOOTSTRAP_VULKAN_HEADER_DIR "" CACHE STRING "Specify the location of the Vulkan-Headers include directory.") +mark_as_advanced(VK_BOOTSTRAP_VULKAN_HEADER_DIR) + +if(NOT "${VK_BOOTSTRAP_VULKAN_HEADER_DIR}" STREQUAL "") + target_include_directories(vk-boostrap-vulkan-headers INTERFACE ${VK_BOOTSTRAP_VULKAN_HEADER_DIR}) +else () + find_package(Vulkan QUIET) + + if(${Vulkan_INCLUDE_DIR} STREQUAL "Vulkan_INCLUDE_DIR-NOTFOUND") + include(FetchContent) + FetchContent_Declare( + VulkanHeaders + GIT_REPOSITORY https://github.com/KhronosGroup/Vulkan-Headers + GIT_TAG v1.2.171 + ) + FetchContent_MakeAvailable(VulkanHeaders) + target_link_libraries(vk-boostrap-vulkan-headers INTERFACE Vulkan::Headers) + else() + set_target_properties(vk-boostrap-vulkan-headers PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${Vulkan_INCLUDE_DIR}) + endif() endif() add_library(vk-bootstrap src/VkBootstrap.h src/VkBootstrap.cpp)