From 7cef8cc6db88d1a5b0ce150db1ae0d52252d917c Mon Sep 17 00:00:00 2001 From: Robert Quill Date: Thu, 5 Sep 2024 10:03:01 +0100 Subject: [PATCH] Use a unique name for CMake build-time-make-directory. If CMake calls vulkan_compile_shader multiple times and the shader directory does not exist in the build directory then add_custom_target will be called multiple times with a target name of build-time-make-directory which is not allowed. Adding the filename of the input file to target name allows this to work and fixes the build. Signed-off-by: Robert Quill --- cmake/vulkan_shader_compiler.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/vulkan_shader_compiler.cmake b/cmake/vulkan_shader_compiler.cmake index 8eac684e..13b42fbf 100644 --- a/cmake/vulkan_shader_compiler.cmake +++ b/cmake/vulkan_shader_compiler.cmake @@ -34,7 +34,8 @@ function(vulkan_compile_shader) ## The directory may not be created so we need to ensure its present get_filename_component(SHADER_COMPILE_SPV_PATH ${SHADER_COMPILE_SPV_FILE_FULL} DIRECTORY) if(NOT EXISTS ${SHADER_COMPILE_SPV_PATH}) - add_custom_target(build-time-make-directory ALL + get_filename_component(SHADER_COMPILE_SPV_FILENAME ${SHADER_COMPILE_SPV_FILE_FULL} FILENAME) + add_custom_target(build-time-make-directory-${SHADER_COMPILE_SPV_FILENAME} ALL COMMAND ${CMAKE_COMMAND} -E make_directory ${SHADER_COMPILE_SPV_PATH}) endif() ## Requires custom command function as this is the only way to call