Skip to content

Commit bca772c

Browse files
jkwak-workslangbotexpipiplus1
authored
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 <ellieh+slangbot@nvidia.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
1 parent efbfa78 commit bca772c

File tree

1 file changed

+25
-19
lines changed

1 file changed

+25
-19
lines changed

tools/CMakeLists.txt

+25-19
Original file line numberDiff line numberDiff line change
@@ -156,29 +156,35 @@ if(SLANG_ENABLE_GFX)
156156
${slang_SOURCE_DIR}
157157
${slang_SOURCE_DIR}/include
158158
INCLUDE_DIRECTORIES_PRIVATE ${NVAPI_INCLUDE_DIRS}
159-
REQUIRES copy-gfx-slang-modules
160159
INSTALL
161160
EXPORT_SET_NAME SlangTargets
162161
FOLDER gfx
163162
)
164-
set(modules_dest_dir $<TARGET_FILE_DIR:slang-test>)
165-
add_custom_target(
166-
copy-gfx-slang-modules
167-
COMMAND ${CMAKE_COMMAND} -E make_directory ${modules_dest_dir}
168-
COMMAND
169-
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/gfx/gfx.slang
170-
${modules_dest_dir}/gfx.slang
171-
COMMAND
172-
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/gfx/slang.slang
173-
${modules_dest_dir}/slang.slang
174-
WORKING_DIRECTORY ${slang_SOURCE_DIR}
175-
VERBATIM
176-
)
177-
set_target_properties(copy-gfx-slang-modules PROPERTIES FOLDER generators)
178-
install(
179-
FILES ${modules_dest_dir}/gfx.slang ${modules_dest_dir}/slang.slang
180-
DESTINATION ${runtime_subdir}
181-
)
163+
if(SLANG_ENABLE_TESTS)
164+
set(modules_dest_dir $<TARGET_FILE_DIR:slang-test>)
165+
add_custom_target(
166+
copy-gfx-slang-modules
167+
COMMAND ${CMAKE_COMMAND} -E make_directory ${modules_dest_dir}
168+
COMMAND
169+
${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_LIST_DIR}/gfx/gfx.slang
170+
${modules_dest_dir}/gfx.slang
171+
COMMAND
172+
${CMAKE_COMMAND} -E copy
173+
${CMAKE_CURRENT_LIST_DIR}/gfx/slang.slang
174+
${modules_dest_dir}/slang.slang
175+
WORKING_DIRECTORY ${slang_SOURCE_DIR}
176+
VERBATIM
177+
)
178+
set_target_properties(
179+
copy-gfx-slang-modules
180+
PROPERTIES FOLDER generators
181+
)
182+
install(
183+
FILES ${modules_dest_dir}/gfx.slang ${modules_dest_dir}/slang.slang
184+
DESTINATION ${runtime_subdir}
185+
)
186+
add_dependencies(gfx copy-gfx-slang-modules)
187+
endif()
182188

183189
slang_add_target(
184190
gfx-util

0 commit comments

Comments
 (0)