diff options
author | Brad King <brad.king@kitware.com> | 2022-05-20 13:08:33 +0000 |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-05-20 09:08:44 -0400 |
commit | 92c7c2c39ac4d1547f325e6e71421024020a352c (patch) | |
tree | 0a9bc37f03a9030958f40b4cb978d122095bb7d9 /Tests | |
parent | 0631433745d56d0c4f7342ea67ece533d7408b0c (diff) | |
parent | 7974fcd1a77e6a1e8c625ac62824e07f37e0ab3a (diff) | |
download | cmake-92c7c2c39ac4d1547f325e6e71421024020a352c.tar.gz |
Merge topic 'findvulkan-improvements'
7974fcd1a7 FindVulkan: remove noop on CMAKE_MODULE_PATH in tests
acdb5fe0e8 FindVulkan: Add component for `glslc` and `glslangValidator`
998ee49779 FindVulkan: ensure policy CMP0057 is NEW to use `IN_LIST` with `if()`
9f8720e74c FindVulkan: Add component for `glslang`
8d133f49e3 FindVulkan: Add component for `SPIRV-Tools`
6e4d20921d FindVulkan: Add component for `shaderc_combined`
2f46b8d723 FindVulkan: Move `mark_as_advanced` right after `find_*` calls.
08a420af4a FindVulkan: Factorize code for library/executable search
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7225
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FindVulkan/Test/CMakeLists.txt | 41 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/main-SPIRV-Tools.c | 15 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/main-glslang.cxx | 24 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/main-shaderc_combined.cxx | 14 |
4 files changed, 92 insertions, 2 deletions
diff --git a/Tests/FindVulkan/Test/CMakeLists.txt b/Tests/FindVulkan/Test/CMakeLists.txt index 7ae8a1104a..a492daa702 100644 --- a/Tests/FindVulkan/Test/CMakeLists.txt +++ b/Tests/FindVulkan/Test/CMakeLists.txt @@ -1,9 +1,13 @@ cmake_minimum_required(VERSION 3.4) +cmake_policy(SET CMP0091 NEW) project(TestFindVulkan C CXX) include(CTest) -SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../) -find_package(Vulkan REQUIRED) +find_package(Vulkan REQUIRED + COMPONENTS + glslang + shaderc_combined + SPIRV-Tools) add_executable(test_tgt main.c) target_link_libraries(test_tgt Vulkan::Vulkan) @@ -23,6 +27,39 @@ target_include_directories(test_var_dl PRIVATE ${Vulkan_INCLUDE_DIRS}) target_link_libraries(test_var_dl ${CMAKE_DL_LIBS}) add_test(NAME test_var_dl COMMAND test_var_dl) +add_executable(test_tgt_glslang main-glslang.cxx) +target_link_libraries(test_tgt_glslang Vulkan::glslang) +add_test(NAME test_tgt_glslang COMMAND test_tgt_glslang) + +get_property(glslang_debug_location TARGET Vulkan::glslang PROPERTY IMPORTED_LOCATION_DEBUG) +if(NOT glslang_debug_location) + set_property(TARGET test_tgt_glslang + PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + +add_executable(test_tgt_shaderc_combined main-shaderc_combined.cxx) +target_link_libraries(test_tgt_shaderc_combined Vulkan::shaderc_combined) +add_test(NAME test_tgt_shaderc_combined COMMAND test_tgt_shaderc_combined) + +get_property(shaderc_combined_debug_location TARGET Vulkan::shaderc_combined PROPERTY IMPORTED_LOCATION_DEBUG) +if(NOT shaderc_combined_debug_location) + set_property(TARGET test_tgt_shaderc_combined + PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + +add_executable(test_tgt_SPIRV-Tools main-SPIRV-Tools.c) +target_link_libraries(test_tgt_SPIRV-Tools Vulkan::SPIRV-Tools) +add_test(NAME test_tgt_SPIRV-Tools COMMAND test_tgt_SPIRV-Tools) + +get_property(SPIRV-Tools_debug_location TARGET Vulkan::SPIRV-Tools PROPERTY IMPORTED_LOCATION_DEBUG) +if(NOT SPIRV-Tools_debug_location) + set_property(TARGET test_tgt_SPIRV-Tools + PROPERTY + MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") +endif() + if(Vulkan_GLSLC_EXECUTABLE) add_test(NAME test_glslc COMMAND ${CMAKE_COMMAND} diff --git a/Tests/FindVulkan/Test/main-SPIRV-Tools.c b/Tests/FindVulkan/Test/main-SPIRV-Tools.c new file mode 100644 index 0000000000..097198dba7 --- /dev/null +++ b/Tests/FindVulkan/Test/main-SPIRV-Tools.c @@ -0,0 +1,15 @@ +#include <assert.h> +#include <spirv-tools/libspirv.h> +#include <stdio.h> + +int main() +{ + const char* spv_version = spvSoftwareVersionString(); + const char* spv_details = spvSoftwareVersionDetailsString(); + assert(spv_version); + assert(spv_details); + + printf("SPIRV-Tools version: %s (details: %s)", spv_version, spv_details); + + return 0; +} diff --git a/Tests/FindVulkan/Test/main-glslang.cxx b/Tests/FindVulkan/Test/main-glslang.cxx new file mode 100644 index 0000000000..81b18d641e --- /dev/null +++ b/Tests/FindVulkan/Test/main-glslang.cxx @@ -0,0 +1,24 @@ +#include <cassert> +#include <iostream> + +#include <glslang/Public/ShaderLang.h> + +int main() +{ + const glslang::Version glslang_version = glslang::GetVersion(); + const char* glslang_essl_version = glslang::GetEsslVersionString(); + const char* glslang_glsl_version = glslang::GetGlslVersionString(); + const int glslang_khronos_tool_id = glslang::GetKhronosToolId(); + + std::cout << "glslang Version: " << glslang_version.major << '.' + << glslang_version.minor << '.' << glslang_version.patch + << " (glsl version: " << glslang_glsl_version + << ", essl version:" << glslang_essl_version + << ", khronos tool:" << glslang_khronos_tool_id << ')' + << std::endl; + + assert(glslang_essl_version); + assert(glslang_glsl_version); + + return 0; +} diff --git a/Tests/FindVulkan/Test/main-shaderc_combined.cxx b/Tests/FindVulkan/Test/main-shaderc_combined.cxx new file mode 100644 index 0000000000..30449fbebc --- /dev/null +++ b/Tests/FindVulkan/Test/main-shaderc_combined.cxx @@ -0,0 +1,14 @@ +#include <assert.h> +#include <shaderc/shaderc.h> +#include <stdio.h> + +int main() +{ + unsigned int shaderc_version, shaderc_revision; + shaderc_get_spv_version(&shaderc_version, &shaderc_revision); + + printf("shaderc version: %u (revision: %u)", shaderc_version, + shaderc_revision); + + return 0; +} |