From a2429292b77eb4fd184cc90361daac6b205237bb Mon Sep 17 00:00:00 2001 From: Robert Quill Date: Thu, 5 Sep 2024 11:37:12 +0100 Subject: [PATCH] Use a unique name for CMake build-time-make-directory (#395) * 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 * Typo fix Signed-off-by: Robert Quill --------- 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..ca0b1bcc 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} NAME) + 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