From bca772ca02bbe9c0f1201c7ae177a10ccff84958 Mon Sep 17 00:00:00 2001 From: Jay Kwak <82421531+jkwak-work@users.noreply.github.com> Date: Fri, 28 Feb 2025 15:15:55 -0800 Subject: Fix build error when SLANG_ENABLE_TESTS is set to OFF (#6420) * Fix build error when SLANG_ENABLE_TESTS is set to OFF When SLANG_ENABLE_TESTS is disabled but SLANG_ENABLE_GFX is enabled, cmake was failing. It turned out that gfx build target was trying to copy some of files to the directory where slang-test uses. When SLANG_ENABLE_TESTS is disabled, the directory information became unavailable, because slang-test target became unavailable. This commit makes the copying behavior conditional on SLANG_ENABLE_TESTS in the gfx build target. * format code (#42) Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> --------- Co-authored-by: slangbot Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska --- tools/CMakeLists.txt | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'tools') diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index 9968d7ca8..7c2e80e61 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -156,29 +156,35 @@ if(SLANG_ENABLE_GFX) ${slang_SOURCE_DIR} ${slang_SOURCE_DIR}/include INCLUDE_DIRECTORIES_PRIVATE ${NVAPI_INCLUDE_DIRS} - REQUIRES copy-gfx-slang-modules INSTALL EXPORT_SET_NAME SlangTargets FOLDER gfx ) - set(modules_dest_dir $) - add_custom_target( - copy-gfx-slang-modules - COMMAND ${CMAKE_COMMAND} -E make_directory ${modules_dest_dir} - COMMAND - ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/gfx/gfx.slang - ${modules_dest_dir}/gfx.slang - COMMAND - ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/gfx/slang.slang - ${modules_dest_dir}/slang.slang - WORKING_DIRECTORY ${slang_SOURCE_DIR} - VERBATIM - ) - set_target_properties(copy-gfx-slang-modules PROPERTIES FOLDER generators) - install( - FILES ${modules_dest_dir}/gfx.slang ${modules_dest_dir}/slang.slang - DESTINATION ${runtime_subdir} - ) + if(SLANG_ENABLE_TESTS) + set(modules_dest_dir $) + add_custom_target( + copy-gfx-slang-modules + COMMAND ${CMAKE_COMMAND} -E make_directory ${modules_dest_dir} + COMMAND + ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/gfx/gfx.slang + ${modules_dest_dir}/gfx.slang + COMMAND + ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_LIST_DIR}/gfx/slang.slang + ${modules_dest_dir}/slang.slang + WORKING_DIRECTORY ${slang_SOURCE_DIR} + VERBATIM + ) + set_target_properties( + copy-gfx-slang-modules + PROPERTIES FOLDER generators + ) + install( + FILES ${modules_dest_dir}/gfx.slang ${modules_dest_dir}/slang.slang + DESTINATION ${runtime_subdir} + ) + add_dependencies(gfx copy-gfx-slang-modules) + endif() slang_add_target( gfx-util -- cgit v1.2.3