Skip to content

Commit

Permalink
Use a unique name for CMake build-time-make-directory (#395)
Browse files Browse the repository at this point in the history
* 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 <robert.quill@imgtec.com>

* Typo fix

Signed-off-by: Robert Quill <robert.quill@imgtec.com>

---------

Signed-off-by: Robert Quill <robert.quill@imgtec.com>
  • Loading branch information
robquill authored Sep 5, 2024
1 parent e79fa68 commit a242929
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cmake/vulkan_shader_compiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a242929

Please sign in to comment.