Skip to content

Commit

Permalink
Merge pull request #136 from zeux/cmake-inconly
Browse files Browse the repository at this point in the history
CMake: Fix include path discovery when using FindVulkan.cmake
  • Loading branch information
zeux authored Aug 4, 2023
2 parents 02295c2 + 3f3e0cb commit c1fc502
Showing 1 changed file with 13 additions and 21 deletions.
34 changes: 13 additions & 21 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,33 +65,25 @@ 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 targets
# 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(" Vulkan as path")
if(TARGET volk)
target_include_directories(volk PUBLIC "${VULKAN_HEADERS_INSTALL_DIR}/include")
endif()
target_include_directories(volk_headers INTERFACE "${VULKAN_HEADERS_INSTALL_DIR}/include")
elseif(TARGET Vulkan::Vulkan)
message(" Vulkan as target")
if(TARGET volk)
target_link_libraries(volk PUBLIC Vulkan::Vulkan)
endif()
target_link_libraries(volk_headers INTERFACE Vulkan::Vulkan)
elseif(TARGET Vulkan::Headers)
message(" Vulkan headers as another cmake target")
if(TARGET volk)
target_link_libraries(volk PUBLIC Vulkan::Headers)
endif()
target_link_libraries(volk_headers INTERFACE Vulkan::Headers)
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(" Vulkan as VULKAN_SDK path")
message("volk: using VULKAN_SDK environment variable")
set(VOLK_INCLUDES "$ENV{VULKAN_SDK}/include")
endif()

if(VOLK_INCLUDES)
if(TARGET volk)
target_include_directories(volk PUBLIC "$ENV{VULKAN_SDK}/include")
target_include_directories(volk PUBLIC "${VOLK_INCLUDES}")
endif()
target_include_directories(volk_headers INTERFACE "$ENV{VULKAN_SDK}/include")
target_include_directories(volk_headers INTERFACE "${VOLK_INCLUDES}")
endif()
endif()

Expand Down

0 comments on commit c1fc502

Please sign in to comment.