diff options
author | Brad King <brad.king@kitware.com> | 2022-07-22 14:16:14 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-07-22 14:16:23 (GMT) |
commit | 96564c5b2d84568459c2b594a7db3baccb524260 (patch) | |
tree | 30a1f127ebb02b8f7d6047e221f8c899ed3ff570 /Tests | |
parent | 55895ed4a11e96e1c3e0da55885f705584a9ada7 (diff) | |
parent | 1277b873c9fbd345925ac790da15854b7d7e0dcf (diff) | |
download | CMake-96564c5b2d84568459c2b594a7db3baccb524260.zip CMake-96564c5b2d84568459c2b594a7db3baccb524260.tar.gz CMake-96564c5b2d84568459c2b594a7db3baccb524260.tar.bz2 |
Merge topic 'FindVulkan-dxc'
1277b873c9 FindVulkan: Add `dxc` (DirectX Shader Compiler) component
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !7474
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/FindVulkan/Test/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/Run-dxc_exe.cmake | 20 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/main-dxc_lib.cxx | 23 |
3 files changed, 58 insertions, 0 deletions
diff --git a/Tests/FindVulkan/Test/CMakeLists.txt b/Tests/FindVulkan/Test/CMakeLists.txt index 727e1ce..dfcfc15 100644 --- a/Tests/FindVulkan/Test/CMakeLists.txt +++ b/Tests/FindVulkan/Test/CMakeLists.txt @@ -8,7 +8,9 @@ set(components shaderc_combined SPIRV-Tools volk + dxc ) + if(APPLE) list(APPEND components MoltenVK) endif() @@ -80,6 +82,10 @@ add_executable(test_tgt_volk main-volk.cxx) target_link_libraries(test_tgt_volk Vulkan::volk) add_test(NAME test_tgt_volk COMMAND test_tgt_volk) +add_executable(test_tgt_dxc_lib main-dxc_lib.cxx) +target_link_libraries(test_tgt_dxc_lib Vulkan::dxc_lib) +add_test(NAME test_tgt_dxc_lib COMMAND test_tgt_dxc_lib) + if(Vulkan_GLSLC_EXECUTABLE) add_test(NAME test_glslc COMMAND ${CMAKE_COMMAND} @@ -97,3 +103,12 @@ if(Vulkan_GLSLANG_VALIDATOR_EXECUTABLE) -P "${CMAKE_CURRENT_LIST_DIR}/Run-glslangValidator.cmake" ) endif() + +if(Vulkan_dxc_EXECUTABLE) + add_test(NAME test_dxc_exe + COMMAND ${CMAKE_COMMAND} + "-DVULKAN_DXC_EXECUTABLE=${Vulkan_dxc_EXECUTABLE}" + "-DVULKAN_DXC_EXECUTABLE_TARGET=$<TARGET_FILE:Vulkan::dxc_exe>" + -P "${CMAKE_CURRENT_LIST_DIR}/Run-dxc_exe.cmake" + ) +endif() diff --git a/Tests/FindVulkan/Test/Run-dxc_exe.cmake b/Tests/FindVulkan/Test/Run-dxc_exe.cmake new file mode 100644 index 0000000..0d38855 --- /dev/null +++ b/Tests/FindVulkan/Test/Run-dxc_exe.cmake @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.12) + +function(run_dxc_exe 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 "^OVERVIEW: HLSL Compiler for ") + message(SEND_ERROR "Output of ${exe_display} --help is \"${output}\", should begin with \"OVERVIEW: HLSL Compiler for \"") + endif() +endfunction() + +run_dxc_exe("${VULKAN_DXC_EXECUTABLE}" "\${VULKAN_DXC_EXECUTABLE}") +run_dxc_exe("${VULKAN_DXC_EXECUTABLE_TARGET}" "Vulkan::dxc_exe") diff --git a/Tests/FindVulkan/Test/main-dxc_lib.cxx b/Tests/FindVulkan/Test/main-dxc_lib.cxx new file mode 100644 index 0000000..6ccb0de --- /dev/null +++ b/Tests/FindVulkan/Test/main-dxc_lib.cxx @@ -0,0 +1,23 @@ +#include <cstdio> + +#include "dxc/dxcapi.h" +#include "printf.h" + +int main() +{ + IDxcCompiler3* compiler; + DxcCreateInstance(CLSID_DxcCompiler, IID_PPV_ARGS(&compiler)); + + assert(compiler); + + IDxcVersionInfo* version; + compiler->QueryInterface(&version); + + uint32_t major, minor; + version->GetVersion(&major, &minor); + printf("DirectX Shader Compiler: %u.%u\n", major, minor); + version->Release(); + compiler->Release(); + + return 0; +} |