diff options
author | Ryan Kawicki <Ryan.H.Kawicki@alumni.purdue.edu> | 2020-06-26 03:14:55 (GMT) |
---|---|---|
committer | Ryan Kawicki <Ryan.H.Kawicki@alumni.purdue.edu> | 2020-06-27 01:57:06 (GMT) |
commit | 467509d7674d62deb9aaca6c9d68628eb108f146 (patch) | |
tree | 6f74342a12b62df413c627f6f642e9d81bb221a6 /Modules/FindVulkan.cmake | |
parent | aae35feea2048e6ffe4d47a068aa5246c89bd606 (diff) | |
download | CMake-467509d7674d62deb9aaca6c9d68628eb108f146.zip CMake-467509d7674d62deb9aaca6c9d68628eb108f146.tar.gz CMake-467509d7674d62deb9aaca6c9d68628eb108f146.tar.bz2 |
FindVulkan: Support for finding glslc
The GLSL SPIR-V compiler is part of the Vulkan SDK and may be used
by projects for compiling shaders as part of the build process.
This is not strictly required to build a Vulkan application, which
is why the variable is not part of the REQUIRED_VARs for the module.
Diffstat (limited to 'Modules/FindVulkan.cmake')
-rw-r--r-- | Modules/FindVulkan.cmake | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake index 4b999b6..89510b7 100644 --- a/Modules/FindVulkan.cmake +++ b/Modules/FindVulkan.cmake @@ -14,6 +14,9 @@ IMPORTED Targets This module defines :prop_tgt:`IMPORTED` target ``Vulkan::Vulkan``, if Vulkan has been found. +This module defines :prop_tgt:`IMPORTED` target ``Vulkan::glslc``, if +Vulkan and the GLSLC SPIR-V compiler has been found. + Result Variables ^^^^^^^^^^^^^^^^ @@ -23,10 +26,11 @@ This module defines the following variables:: Vulkan_INCLUDE_DIRS - include directories for Vulkan Vulkan_LIBRARIES - link against this library to use Vulkan -The module will also define two cache variables:: +The module will also define three cache variables:: - Vulkan_INCLUDE_DIR - the Vulkan include directory - Vulkan_LIBRARY - the path to the Vulkan library + 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 Hints ^^^^^ @@ -53,6 +57,11 @@ if(WIN32) "$ENV{VULKAN_SDK}/Lib" "$ENV{VULKAN_SDK}/Bin" ) + find_program(Vulkan_GLSLC_EXECUTABLE + NAMES glslc + HINTS + "$ENV{VULKAN_SDK}/Bin" + ) elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) find_library(Vulkan_LIBRARY NAMES vulkan-1 @@ -60,6 +69,11 @@ if(WIN32) "$ENV{VULKAN_SDK}/Lib32" "$ENV{VULKAN_SDK}/Bin32" ) + find_program(Vulkan_GLSLC_EXECUTABLE + NAMES glslc + HINTS + "$ENV{VULKAN_SDK}/Bin32" + ) endif() else() find_path(Vulkan_INCLUDE_DIR @@ -68,6 +82,9 @@ else() find_library(Vulkan_LIBRARY NAMES vulkan HINTS "$ENV{VULKAN_SDK}/lib") + find_program(Vulkan_GLSLC_EXECUTABLE + NAMES glslc + HINTS "$ENV{VULKAN_SDK}/bin") endif() set(Vulkan_LIBRARIES ${Vulkan_LIBRARY}) @@ -78,7 +95,7 @@ find_package_handle_standard_args(Vulkan DEFAULT_MSG Vulkan_LIBRARY Vulkan_INCLUDE_DIR) -mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY) +mark_as_advanced(Vulkan_INCLUDE_DIR Vulkan_LIBRARY Vulkan_GLSLC_EXECUTABLE) if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) add_library(Vulkan::Vulkan UNKNOWN IMPORTED) @@ -86,3 +103,8 @@ if(Vulkan_FOUND AND NOT TARGET Vulkan::Vulkan) IMPORTED_LOCATION "${Vulkan_LIBRARIES}" 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() |