diff options
author | PCJohn <peciva@fit.vut.cz> | 2021-05-22 13:34:17 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-05-24 16:53:15 (GMT) |
commit | 668ba68a7af9e7511e0e6c988ccfe297956a42b6 (patch) | |
tree | b9b0985700f021731746fe92904c6e473776b164 /Modules/FindVulkan.cmake | |
parent | 7ee3ccbbeabfcd27ebfbab48b05539134e63cb8f (diff) | |
download | CMake-668ba68a7af9e7511e0e6c988ccfe297956a42b6.zip CMake-668ba68a7af9e7511e0e6c988ccfe297956a42b6.tar.gz CMake-668ba68a7af9e7511e0e6c988ccfe297956a42b6.tar.bz2 |
FindVulkan: add Vulkan::Headers and Vulkan::glslangValidator targets
The `Vulkan::Headers` target complements existing Vulkan::Vulkan target.
It is the same except it omits the Vulkan library which supports
applications that loads the Vulkan library in at runtime.
The `Vulkan::glslangValidator` target provides the glslangValidator
executable which is the tool for converting between shader languages
(GLSL, SPIR-V, etc.).
Diffstat (limited to 'Modules/FindVulkan.cmake')
-rw-r--r-- | Modules/FindVulkan.cmake | 54 |
1 files changed, 48 insertions, 6 deletions
diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index ceb1921..4f48e13 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -13,12 +13,28 @@ and computing API. IMPORTED Targets ^^^^^^^^^^^^^^^^ -This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if -Vulkan has been found. +This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found: -.. versionadded:: 3.19 - This module defines :prop_tgt:`IMPORTED` target ``Vulkan::glslc``, if - Vulkan and the GLSLC SPIR-V compiler has been found. +``Vulkan::Vulkan`` + The main Vulkan library. + +``Vulkan::glslc`` + .. versionadded:: 3.19 + + The GLSLC SPIR-V compiler, if it has been found. + +``Vulkan::Headers`` + .. versionadded:: 3.21 + + Provides just Vulkan headers include paths, if found. No library is + included in this target. This can be useful for applications that + load Vulkan library dynamically. + +``Vulkan::glslangValidator`` + .. versionadded:: 3.21 + + The glslangValidator tool, if found. It is used to compile GLSL and + HLSL shaders into SPIR-V. Result Variables ^^^^^^^^^^^^^^^^ @@ -34,6 +50,7 @@ The module will also define three cache variables:: Vulkan_INCLUDE_DIR - the Vulkan include directory Vulkan_LIBRARY - the path to the Vulkan library Vulkan_GLSLC_EXECUTABLE - the path to the GLSL SPIR-V compiler + Vulkan_GLSLANG_VALIDATOR_EXECUTABLE - the path to the glslangValidator tool Hints ^^^^^ @@ -67,6 +84,11 @@ if(WIN32) HINTS "$ENV{VULKAN_SDK}/Bin" ) + find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE + NAMES glslangValidator + HINTS + "$ENV{VULKAN_SDK}/Bin" + ) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) find_library(Vulkan_LIBRARY NAMES vulkan-1 @@ -79,6 +101,11 @@ if(WIN32) HINTS "$ENV{VULKAN_SDK}/Bin32" ) + find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE + NAMES glslangValidator + HINTS + "$ENV{VULKAN_SDK}/Bin32" + ) endif() else() find_path(Vulkan_INCLUDE_DIR @@ -90,6 +117,9 @@ else() find_program(Vulkan_GLSLC_EXECUTABLE NAMES glslc HINTS "$ENV{VULKAN_SDK}/bin") + find_program(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE + NAMES glslangValidator + HINTS "$ENV{VULKAN_SDK}/bin") endif() set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) @@ -100,7 +130,8 @@ find_package_handle_standard_args(Vulkan DEFAULT_MSG Vulkan_LIBRARY Vulkan_INCLUDE_DIR) -mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY Vulkan_GLSLC_EXECUTABLE) +mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY Vulkan_GLSLC_EXECUTABLE + Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) add_library(Vulkan::Vulkan UNKNOWN IMPORTED) @@ -109,7 +140,18 @@ if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") endif() +if(Vulkan_FOUND AND NOT TARGET Vulkan::Headers) + add_library(Vulkan::Headers INTERFACE IMPORTED) + set_target_properties(Vulkan::Headers PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_INCLUDE_DIRS}") +endif() + if(Vulkan_FOUND AND Vulkan_GLSLC_EXECUTABLE AND NOT TARGET Vulkan::glslc) add_executable(Vulkan::glslc IMPORTED) set_property(TARGET Vulkan::glslc PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLC_EXECUTABLE}") endif() + +if(Vulkan_FOUND AND Vulkan_GLSLANG_VALIDATOR_EXECUTABLE AND NOT TARGET Vulkan::glslangValidator) + add_executable(Vulkan::glslangValidator IMPORTED) + set_property(TARGET Vulkan::glslangValidator PROPERTY IMPORTED_LOCATION "${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}") +endif() |