From f849e33452df159eceec9ae1e8d3d127caafc907 Mon Sep 17 00:00:00 2001 From: Aiden Lambert Date: Tue, 21 Jun 2022 16:03:06 -0500 Subject: FindVulkan: Add 'volk' component --- Help/release/dev/findvulkan-volk.rst | 5 +++++ Modules/FindVulkan.cmake | 41 ++++++++++++++++++++++++++++++++++++ Tests/FindVulkan/Test/CMakeLists.txt | 5 +++++ Tests/FindVulkan/Test/main-volk.cxx | 14 ++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 Help/release/dev/findvulkan-volk.rst create mode 100644 Tests/FindVulkan/Test/main-volk.cxx diff --git a/Help/release/dev/findvulkan-volk.rst b/Help/release/dev/findvulkan-volk.rst new file mode 100644 index 0000000..cb77078 --- /dev/null +++ b/Help/release/dev/findvulkan-volk.rst @@ -0,0 +1,5 @@ +findvulkan-volk +--------------- + +* The :module:`FindVulkan` module now includes a ``volk`` component + for the Volk open source vulkan meta-loader. diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index 8b322ed..78b07c4 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -70,6 +70,11 @@ This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found: Defined if SDK has the Khronos library which implement a subset of Vulkan API over Apple Metal graphics framework. (MoltenVK). +``Vulkan::volk`` + .. versionadded:: 3.25 + + Defined if SDK has the Vulkan meta-loader (volk). + Result Variables ^^^^^^^^^^^^^^^^ @@ -109,6 +114,10 @@ This module defines the following variables: .. versionadded:: 3.24 True, if the SDK has the MoltenVK library. +``Vulkan_volk_FOUND`` + .. versionadded:: 3.25 + + True, if the SDK has the volk library. The module will also defines these cache variables: @@ -137,6 +146,11 @@ The module will also defines these cache variables: Path to the MoltenVK library. +``Vulkan_volk_LIBRARY`` + .. versionadded:: 3.25 + + Path to the volk library. + Hints ^^^^^ @@ -374,6 +388,13 @@ if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS) ) mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR) endif() +if(volk IN_LIST Vulkan_FIND_COMPONENTS) + find_library(Vulkan_volk_LIBRARY + NAMES volk + HINTS + ${_Vulkan_hint_library_search_paths}) + mark_as_advanced(Vulkan_Volk_LIBRARY) +endif() if(Vulkan_GLSLC_EXECUTABLE) set(Vulkan_glslc_FOUND TRUE) @@ -437,6 +458,7 @@ _Vulkan_set_library_component_found(glslang glslang-genericcodegen) _Vulkan_set_library_component_found(shaderc_combined) _Vulkan_set_library_component_found(SPIRV-Tools) +_Vulkan_set_library_component_found(volk) if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY) set(Vulkan_MoltenVK_FOUND TRUE) @@ -723,6 +745,25 @@ if(Vulkan_FOUND) IMPORTED_LOCATION_DEBUG "${Vulkan_SPIRV-Tools_DEBUG_LIBRARY}") endif() endif() + + if(Vulkan_volk_LIBRARY AND NOT TARGET Vulkan::volk) + add_library(Vulkan::volk STATIC IMPORTED) + set_property(TARGET Vulkan::volk + PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") + set_property(TARGET Vulkan::volk APPEND + PROPERTY + IMPORTED_CONFIGURATIONS Release) + set_property(TARGET Vulkan::volk APPEND + PROPERTY + IMPORTED_LOCATION_RELEASE "${Vulkan_volk_LIBRARY}") + + if (NOT WIN32) + set_property(TARGET Vulkan::volk APPEND + PROPERTY + IMPORTED_LINK_INTERFACE_LIBRARIES dl) + endif() + endif() endif() if(Vulkan_MoltenVK_FOUND) diff --git a/Tests/FindVulkan/Test/CMakeLists.txt b/Tests/FindVulkan/Test/CMakeLists.txt index 42543ac..727e1ce 100644 --- a/Tests/FindVulkan/Test/CMakeLists.txt +++ b/Tests/FindVulkan/Test/CMakeLists.txt @@ -7,6 +7,7 @@ set(components glslang shaderc_combined SPIRV-Tools + volk ) if(APPLE) list(APPEND components MoltenVK) @@ -75,6 +76,10 @@ if(APPLE) add_test(NAME test_tgt_MoltenVK COMMAND test_tgt_MoltenVK) endif() +add_executable(test_tgt_volk main-volk.cxx) +target_link_libraries(test_tgt_volk Vulkan::volk) +add_test(NAME test_tgt_volk COMMAND test_tgt_volk) + if(Vulkan_GLSLC_EXECUTABLE) add_test(NAME test_glslc COMMAND ${CMAKE_COMMAND} diff --git a/Tests/FindVulkan/Test/main-volk.cxx b/Tests/FindVulkan/Test/main-volk.cxx new file mode 100644 index 0000000..2ec9fb4 --- /dev/null +++ b/Tests/FindVulkan/Test/main-volk.cxx @@ -0,0 +1,14 @@ +#include + +#include + +int main() +{ + if (volkInitialize() != VK_SUCCESS) { + std::cout << "volk initialization success!" << std::endl; + } else { + std::cout << "volk initialization failure!" << std::endl; + } + + return 0; +} -- cgit v0.12