summaryrefslogtreecommitdiffstats
path: root/Tests/FindVulkan/Test
diff options
context:
space:
mode:
authorRyan Kawicki <Ryan.H.Kawicki@alumni.purdue.edu>2020-06-26 03:14:55 (GMT)
committerRyan Kawicki <Ryan.H.Kawicki@alumni.purdue.edu>2020-06-27 01:57:06 (GMT)
commit467509d7674d62deb9aaca6c9d68628eb108f146 (patch)
tree6f74342a12b62df413c627f6f642e9d81bb221a6 /Tests/FindVulkan/Test
parentaae35feea2048e6ffe4d47a068aa5246c89bd606 (diff)
downloadCMake-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 'Tests/FindVulkan/Test')
-rw-r--r--Tests/FindVulkan/Test/CMakeLists.txt9
-rw-r--r--Tests/FindVulkan/Test/Run-glslc.cmake20
-rw-r--r--Tests/FindVulkan/Test/main.c4
3 files changed, 31 insertions, 2 deletions
diff --git a/Tests/FindVulkan/Test/CMakeLists.txt b/Tests/FindVulkan/Test/CMakeLists.txt
index 0b13d53..9d36a0d 100644
--- a/Tests/FindVulkan/Test/CMakeLists.txt
+++ b/Tests/FindVulkan/Test/CMakeLists.txt
@@ -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()
diff --git a/Tests/FindVulkan/Test/Run-glslc.cmake b/Tests/FindVulkan/Test/Run-glslc.cmake
new file mode 100644
index 0000000..086eb9d
--- /dev/null
+++ b/Tests/FindVulkan/Test/Run-glslc.cmake
@@ -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")
diff --git a/Tests/FindVulkan/Test/main.c b/Tests/FindVulkan/Test/main.c
index b29c9ec..1bff651 100644
--- a/Tests/FindVulkan/Test/main.c
+++ b/Tests/FindVulkan/Test/main.c
@@ -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);