From 01b5e061d44af7cd29e25b5a0b62164ed79e7aeb Mon Sep 17 00:00:00 2001 From: jyxiong Date: Wed, 4 Sep 2024 11:11:01 +0800 Subject: [PATCH] CMake: Improve include path discovery --- CMakeLists.txt | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ddf3e6..d3684b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,21 +62,22 @@ endif() # Vulkan transitive dependency if(VOLK_PULL_IN_VULKAN) - # If CMake has the FindVulkan module and it works, use it. - find_package(Vulkan QUIET) - # Try an explicit CMake variable first, then any Vulkan paths # discovered by FindVulkan.cmake, then the $VULKAN_SDK environment # variable if nothing else works. if(VULKAN_HEADERS_INSTALL_DIR) message("volk: using VULKAN_HEADERS_INSTALL_DIR option") set(VOLK_INCLUDES "${VULKAN_HEADERS_INSTALL_DIR}/include") - elseif(Vulkan_INCLUDE_DIRS) - message("volk: using Vulkan_INCLUDE_DIRS from FindVulkan module") - set(VOLK_INCLUDES "${Vulkan_INCLUDE_DIRS}") - elseif(DEFINED ENV{VULKAN_SDK}) - message("volk: using VULKAN_SDK environment variable") - set(VOLK_INCLUDES "$ENV{VULKAN_SDK}/include") + else() + # If CMake has the FindVulkan module and it works, use it. + find_package(Vulkan QUIET) + if(Vulkan_INCLUDE_DIRS) + message("volk: using Vulkan_INCLUDE_DIRS from FindVulkan module") + set(VOLK_INCLUDES "${Vulkan_INCLUDE_DIRS}") + elseif(DEFINED ENV{VULKAN_SDK}) + message("volk: using VULKAN_SDK environment variable") + set(VOLK_INCLUDES "$ENV{VULKAN_SDK}/include") + endif() endif() if(VOLK_INCLUDES)