FindVulkan: Add 'volk' component

This commit is contained in:
Aiden Lambert
2022-06-21 16:03:06 -05:00
committed by Brad King
parent d94e09ec88
commit f849e33452
4 changed files with 65 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
findvulkan-volk
---------------
* The :module:`FindVulkan` module now includes a ``volk`` component
for the Volk open source vulkan meta-loader.

View File

@@ -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)

View File

@@ -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}

View File

@@ -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;
}