diff options
author | Aiden Lambert <aidenramen29@gmail.com> | 2022-06-21 21:03:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-06-22 13:46:46 (GMT) |
commit | f849e33452df159eceec9ae1e8d3d127caafc907 (patch) | |
tree | e5b835d9e06b3a29073571f3fa16171851b85f79 | |
parent | d94e09ec88c99434941029cde07b6c1e6bd0dde1 (diff) | |
download | CMake-f849e33452df159eceec9ae1e8d3d127caafc907.zip CMake-f849e33452df159eceec9ae1e8d3d127caafc907.tar.gz CMake-f849e33452df159eceec9ae1e8d3d127caafc907.tar.bz2 |
FindVulkan: Add 'volk' component
-rw-r--r-- | Help/release/dev/findvulkan-volk.rst | 5 | ||||
-rw-r--r-- | Modules/FindVulkan.cmake | 41 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/main-volk.cxx | 14 |
4 files changed, 65 insertions, 0 deletions
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 <iostream> + +#include <volk/volk.h> + +int main() +{ + if (volkInitialize() != VK_SUCCESS) { + std::cout << "volk initialization success!" << std::endl; + } else { + std::cout << "volk initialization failure!" << std::endl; + } + + return 0; +} |