mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-30 18:29:37 -06:00
Merge topic 'find_vulkan_glslc'
467509d767 FindVulkan: Support for finding glslc
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4944
This commit is contained in:
10
Help/release/dev/FindVulkan-glslc.rst
Normal file
10
Help/release/dev/FindVulkan-glslc.rst
Normal file
@@ -0,0 +1,10 @@
|
||||
FindVulkan-glslc
|
||||
----------------
|
||||
|
||||
* The :module:`FindVulkan` module gained a new output variable
|
||||
``Vulkan_GLSLC_EXECUTABLE`` which contains the path to the
|
||||
GLSL SPIR-V compiler.
|
||||
|
||||
* The :module:`FindVulkan` module gained a new target
|
||||
``Vulkan::glslc`` which contains the path to the
|
||||
GLSL SPIR-V compiler.
|
||||
@@ -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()
|
||||
|
||||
@@ -13,3 +13,12 @@ add_executable(test_var main.c)
|
||||
target_include_directories(test_var PRIVATE ${Vulkan_INCLUDE_DIRS})
|
||||
target_link_libraries(test_var PRIVATE ${Vulkan_LIBRARIES})
|
||||
add_test(NAME test_var COMMAND test_var)
|
||||
|
||||
if(Vulkan_GLSLC_EXECUTABLE)
|
||||
add_test(NAME test_glslc
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
"-DVULKAN_GLSLC_EXECUTABLE=${Vulkan_GLSLC_EXECUTABLE}"
|
||||
"-DVULKAN_GLSLC_EXECUTABLE_TARGET=$<TARGET_FILE:Vulkan::glslc>"
|
||||
-P "${CMAKE_CURRENT_LIST_DIR}/Run-glslc.cmake"
|
||||
)
|
||||
endif()
|
||||
|
||||
20
Tests/FindVulkan/Test/Run-glslc.cmake
Normal file
20
Tests/FindVulkan/Test/Run-glslc.cmake
Normal file
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
|
||||
function(run_glslc exe exe_display)
|
||||
execute_process(COMMAND ${exe} --help
|
||||
OUTPUT_VARIABLE output
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
RESULT_VARIABLE result
|
||||
)
|
||||
|
||||
if(NOT result EQUAL 0)
|
||||
message(SEND_ERROR "Result of ${exe_display} --help is ${result}, should be 0")
|
||||
endif()
|
||||
|
||||
if(NOT output MATCHES "^glslc - Compile shaders into SPIR-V")
|
||||
message(SEND_ERROR "Output of ${exe_display} --help is \"${output}\", should begin with \"glslc - Compile shaders into SPIR-V\"")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
run_glslc("${VULKAN_GLSLC_EXECUTABLE}" "\${VULKAN_GLSLC_EXECUTABLE}")
|
||||
run_glslc("${VULKAN_GLSLC_EXECUTABLE_TARGET}" "Vulkan::glslc")
|
||||
@@ -2,10 +2,10 @@
|
||||
|
||||
int main()
|
||||
{
|
||||
VkInstanceCreateInfo instanceCreateInfo = {};
|
||||
VkInstanceCreateInfo instanceCreateInfo = { 0 };
|
||||
instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||
|
||||
VkApplicationInfo applicationInfo = {};
|
||||
VkApplicationInfo applicationInfo = { 0 };
|
||||
applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
|
||||
applicationInfo.apiVersion = VK_API_VERSION_1_0;
|
||||
applicationInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
|
||||
|
||||
Reference in New Issue
Block a user