Skip to content

Commit 265f350

Browse files
committed
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.
1 parent ca592d2 commit 265f350

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

tools/CMakeLists.txt

+21-19
Original file line numberDiff line numberDiff line change
@@ -156,29 +156,31 @@ 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 ${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+
)
182+
add_dependencies(gfx copy-gfx-slang-modules)
183+
endif()
182184

183185
slang_add_target(
184186
gfx-util

0 commit comments

Comments
 (0)