FindVulkan¶
在 3.7 版被加入.
Finds Vulkan, a low-overhead, cross-platform 3D graphics and computing API,
along with related development tools typically provided by the Vulkan SDK. This
includes commonly used utilities such as shader compilers and SPIR-V tools
(e.g., DXC, glslc
, glslang
, etc.) that support Vulkan-based development
workflows.
Components¶
在 3.24 版被加入.
This module supports several optional components that can be specified with the
find_package()
command:
find_package(Vulkan [COMPONENTS <components>...])
Each component provides a corresponding imported target. Supported components include:
glslc
在 3.24 版被加入.
Finds the SPIR-V compiler. This optional component is always implied automatically for backward compatibility, even if not requested.
glslangValidator
在 3.24 版被加入.
Finds the
glslangValidator
tool that is used to compile GLSL and HLSL shaders into SPIR-V. This optional component is always implied automatically for backward compatibility, even if not requested.glslang
在 3.24 版被加入.
Finds the Khronos-reference front-end shader parser and SPIR-V code generation library (
glslang
).shaderc_combined
在 3.24 版被加入.
Finds the Google static library used for Vulkan shader compilation.
SPIRV-Tools
在 3.24 版被加入.
Finds Khronos library for analyzing and transforming SPIR-V modules.
MoltenVK
在 3.24 版被加入.
Finds the Khronos MoltenVK library, which is available on macOS, and implements a subset of Vulkan API over Apple Metal graphics framework.
dxc
在 3.25 版被加入.
Finds the DirectX Shader Compiler (DXC), including the library and command-line tool. Note that Visual Studio also provides a DXC tool, but the version included with the Vulkan SDK is typically required for Vulkan development, as it has Vulkan capability enabled.
volk
在 3.25 版被加入.
Finds the Vulkan meta-loader
volk
library, a vector-optimized library of kernels.
Imported Targets¶
This module provides the following Imported Targets:
Vulkan::Vulkan
Target encapsulating the main Vulkan library usage requirements, available if Vulkan is found.
Vulkan::glslc
在 3.19 版被加入.
Imported executable target encapsulating the GLSLC SPIR-V compiler usage requirements, available if
glslc
is found.Vulkan::Headers
在 3.21 版被加入.
Target encapsulating the usage requirements needed to include Vulkan headers. It provides only the include directories and does not link to any library. This is useful for applications that load the Vulkan library dynamically at runtime. This target is available if Vulkan is found.
Vulkan::glslangValidator
在 3.21 版被加入.
Imported executable target encapsulating the
glslangValidator
usage requirements, available if this tool is found.Vulkan::glslang
在 3.24 版被加入.
Target encapsulating the
glslang
library usage requirements, available ifglslang
is found in the SDK.Vulkan::shaderc_combined
在 3.24 版被加入.
Target encapsulating the
shaderc_combined
library usage requirements, available if this library is found in the SDK.Vulkan::SPIRV-Tools
在 3.24 版被加入.
Target encapsulating the SPIRV-Tools library usage requirements, available if this library is found in the SDK.
Vulkan::MoltenVK
在 3.24 版被加入.
Target encapsulating the MoltenVK library usage requirements, available if this library is found in the SDK.
Vulkan::volk
在 3.25 版被加入.
Target encapsulating the
volk
library usage requirements, available ifvolk
is found in the SDK.Vulkan::dxc_lib
在 3.25 版被加入.
Target encapsulating the usage requirements for the DirectX shader compiler library, available if DXC library is found in the SDK.
Vulkan::dxc_exe
在 3.25 版被加入.
Imported executable target providing usage requirements for the DirectX shader compiler CLI tool, available if SDK has this tool.
結果變數¶
This module defines the following variables:
Vulkan_FOUND
Boolean indicating whether (the requested version of) Vulkan and all required components are found.
Vulkan_VERSION
在 3.23 版被加入.
The version of Vulkan found. Value is retrieved from
vulkan/vulkan_core.h
.Vulkan_INCLUDE_DIRS
Include directories needed to use the main Vulkan library.
Vulkan_LIBRARIES
Libraries needed to link against to use the main Vulkan library.
Vulkan_glslc_FOUND
在 3.24 版被加入.
Boolean indicating whether the SDK provides the
glslc
executable.Vulkan_glslangValidator_FOUND
在 3.24 版被加入.
Boolean indicating whether the SDK provides the
glslangValidator
executable.Vulkan_glslang_FOUND
在 3.24 版被加入.
Boolean indicating whether the SDK provides the
glslang
library.Vulkan_shaderc_combined_FOUND
在 3.24 版被加入.
Boolean indicating whether the SDK provides the
shaderc_combined
library.Vulkan_SPIRV-Tools_FOUND
在 3.24 版被加入.
Boolean indicating whether the SDK provides the SPIRV-Tools library.
Vulkan_MoltenVK_FOUND
在 3.24 版被加入.
Boolean indicating whether the SDK provides the MoltenVK library.
Vulkan_volk_FOUND
在 3.25 版被加入.
Boolean indicating whether the SDK provides the volk library.
Vulkan_dxc_lib_FOUND
在 3.25 版被加入.
Boolean indicating whether the SDK provides the DirectX shader compiler library.
Vulkan_dxc_exe_FOUND
在 3.25 版被加入.
Boolean indicating whether the SDK provides the DirectX shader compiler CLI tool.
快取變數¶
The following cache variables may also be set:
Vulkan_INCLUDE_DIR
The directory containing Vulkan headers.
Vulkan_LIBRARY
The path to the Vulkan library.
Vulkan_GLSLC_EXECUTABLE
在 3.19 版被加入.
The path to the GLSL SPIR-V compiler.
Vulkan_GLSLANG_VALIDATOR_EXECUTABLE
在 3.21 版被加入.
The path to the
glslangValidator
tool.Vulkan_glslang_LIBRARY
在 3.24 版被加入.
The path to the
glslang
library.Vulkan_shaderc_combined_LIBRARY
在 3.24 版被加入.
The path to the
shaderc_combined
library.Vulkan_SPIRV-Tools_LIBRARY
在 3.24 版被加入.
The path to the SPIRV-Tools library.
Vulkan_MoltenVK_LIBRARY
在 3.24 版被加入.
The path to the MoltenVK library.
Vulkan_volk_LIBRARY
在 3.25 版被加入.
The path to the
volk
library.Vulkan_dxc_LIBRARY
在 3.25 版被加入.
The path to the DirectX shader compiler library.
Vulkan_dxc_EXECUTABLE
在 3.25 版被加入.
The path to the DirectX shader compiler CLI tool.
Hints¶
This module accepts the following variables:
VULKAN_SDK
This environment variable can be optionally set to specify the location of the Vulkan SDK root directory for the given architecture. It is typically set by sourcing the toplevel
setup-env.sh
script of the Vulkan SDK directory into the shell environment.
範例¶
Finding the Vulkan library and linking it to a project target:
find_package(Vulkan)
target_link_libraries(project_target PRIVATE Vulkan::Vulkan)
Finding the Vulkan library along with additional components:
find_package(Vulkan COMPONENTS volk)
target_link_libraries(project_target PRIVATE Vulkan::Vulkan Vulkan::volk)