From 6f05dd9d1dd2efd2fa8597e7b20d68ffd9c33716 Mon Sep 17 00:00:00 2001 From: Castor215 <132155746+Castor215@users.noreply.github.com> Date: Sun, 12 Nov 2023 21:02:23 +0000 Subject: [PATCH] externals: allow user to use system Vulkan headers (#7155) --- externals/CMakeLists.txt | 10 +++++++++- externals/cmake-modules/CitraHandleSystemLibs.cmake | 3 +++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index d695d2558..d150cb640 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -376,7 +376,15 @@ endif() # vulkan-headers add_library(vulkan-headers INTERFACE) -target_include_directories(vulkan-headers SYSTEM INTERFACE ./vulkan-headers/include) +if(USE_SYSTEM_VULKAN_HEADERS) + find_package(Vulkan REQUIRED) + if(TARGET Vulkan::Headers) + message(STATUS "Found Vulkan headers") + target_link_libraries(vulkan-headers INTERFACE Vulkan::Headers) + endif() +else() + target_include_directories(vulkan-headers SYSTEM INTERFACE ./vulkan-headers/include) +endif() if (APPLE) target_include_directories(vulkan-headers SYSTEM INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/MoltenVK) endif() diff --git a/externals/cmake-modules/CitraHandleSystemLibs.cmake b/externals/cmake-modules/CitraHandleSystemLibs.cmake index f72115056..44f156b75 100644 --- a/externals/cmake-modules/CitraHandleSystemLibs.cmake +++ b/externals/cmake-modules/CitraHandleSystemLibs.cmake @@ -24,6 +24,7 @@ option(USE_SYSTEM_CUBEB "Use the system cubeb (instead of the bundled one)" OFF) option(USE_SYSTEM_LODEPNG "Use the system lodepng (instead of the bundled one)" OFF) option(USE_SYSTEM_OPENAL "Use the system OpenAL (instead of the bundled one)" OFF) option(USE_SYSTEM_VMA "Use the system VulkanMemoryAllocator (instead of the bundled one)" OFF) +option(USE_SYSTEM_VULKAN_HEADERS "Use the system Vulkan headers (instead of the bundled ones)" OFF) # Qt and MoltenVK are handled separately CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_SDL2 "Disable system SDL2" OFF "USE_SYSTEM_LIBS" OFF) @@ -47,6 +48,7 @@ CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_CUBEB "Disable system cubeb" OFF "USE_SYST CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_LODEPNG "Disable system lodepng" OFF "USE_SYSTEM_LIBS" OFF) CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_OPENAL "Disable system OpenAL" OFF "USE_SYSTEM_LIBS" OFF) CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_VMA "Disable system VulkanMemoryAllocator" OFF "USE_SYSTEM_LIBS" OFF) +CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_VULKAN_HEADERS "Disable system Vulkan headers" OFF "USE_SYSTEM_LIBS" OFF) set(LIB_VAR_LIST SDL2 @@ -70,6 +72,7 @@ set(LIB_VAR_LIST LODEPNG OPENAL VMA + VULKAN_HEADERS ) # First, check that USE_SYSTEM_XXX is not used with USE_SYSTEM_LIBS