Files
OpenCL-CTS/test_conformance/vulkan/shaders/CMakeLists.txt
Ahmed Hesham 485964d87c Add CMake installation rules (#2184)
Add installation rules for all the binary targets.

Targets are installed under `<CMAKE_INSTALL_PREFIX>/bin/<CONFIG>` where
`<CONFIG>` is `CMAKE_BUILD_TYPE` for single-config generators, e.g. Unix
Makefiles and Ninja, or the build configuration for multi-config
generators, e.g. Ninja Multi-Config and Visual Studio.

This creates the target `install` on Unix and `INSTALL` on Windows.
2025-02-18 20:47:56 -08:00

55 lines
1.8 KiB
CMake

find_program(
Vulkan_glslang_binary
NAMES glslang
HINTS $ENV{VULKAN_SDK})
if(${Vulkan_glslang_binary} STREQUAL "Vulkan_glslang_binary-NOTFOUND")
message(FATAL_ERROR "glslang tool (part of Vulkan SDK) is a prerequisite to compile shaders to spir-v")
else()
message(STATUS "Found glslang: ${Vulkan_glslang_binary}")
if(NOT DEFINED VULKAN_TEST_RESOURCES)
set(VULKAN_TEST_RESOURCES ${CMAKE_CURRENT_BINARY_DIR})
endif()
set(vulkan_spirv_files "")
add_custom_command(
OUTPUT ${VULKAN_TEST_RESOURCES}/buffer.spv
COMMAND ${Vulkan_glslang_binary}
--target-env vulkan1.0
-o ${VULKAN_TEST_RESOURCES}/buffer.spv
${CMAKE_CURRENT_SOURCE_DIR}/buffer.comp
DEPENDS buffer.comp
VERBATIM)
list(APPEND vulkan_spirv_files ${VULKAN_TEST_RESOURCES}/buffer.spv)
file(STRINGS "image2D_test_formats.txt" image2D_formats)
foreach(format ${image2D_formats})
list(GET format 1 GLSL_FORMAT)
list(GET format 2 GLSL_TYPE_PREFIX)
configure_file(image2D.comp.in image2D_${GLSL_FORMAT}.comp)
add_custom_command(
OUTPUT ${VULKAN_TEST_RESOURCES}/image2D_${GLSL_FORMAT}.spv
COMMAND ${Vulkan_glslang_binary}
--target-env vulkan1.0
-o ${VULKAN_TEST_RESOURCES}/image2D_${GLSL_FORMAT}.spv
${CMAKE_CURRENT_BINARY_DIR}/image2D_${GLSL_FORMAT}.comp
DEPENDS image2D_${GLSL_FORMAT}.comp
VERBATIM)
list(APPEND vulkan_spirv_files ${VULKAN_TEST_RESOURCES}/image2D_${GLSL_FORMAT}.spv)
endforeach()
add_custom_target(vulkan_shaders DEPENDS ${vulkan_spirv_files})
include(GNUInstallDirs)
install(DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
DESTINATION
${CMAKE_INSTALL_BINDIR}/$<CONFIG>)
endif()