Skip to content

Commit 5a6f34e

Browse files
authored
[libclc] Ensure directory exists for libclc files (#13529)
Some generators like Unix Makefiles wouldn't automatically ensure that this directory exists, which can break the build.
1 parent 96b07cf commit 5a6f34e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ function(add_libclc_alias alias target)
178178

179179
add_custom_command(
180180
OUTPUT ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/${alias_suffix}
181+
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
181182
COMMAND ${CMAKE_COMMAND} -E
182183
${LIBCLC_LINK_OR_COPY} ${target}.bc
183184
${alias_suffix}
@@ -288,6 +289,7 @@ macro(add_libclc_builtin_set arch_suffix)
288289
# Add prepare target
289290
set( obj_suffix ${arch_suffix}.bc )
290291
add_custom_command( OUTPUT ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/${obj_suffix}
292+
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
291293
COMMAND prepare_builtins -o ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/${obj_suffix}
292294
${builtins_opt_lib}
293295
DEPENDS ${builtins_opt_lib} prepare_builtins )
@@ -307,9 +309,11 @@ macro(add_libclc_builtin_set arch_suffix)
307309

308310
# Generate remangled variants if requested
309311
if( LIBCLC_GENERATE_REMANGLED_VARIANTS )
310-
set(dummy_in "${CMAKE_BINARY_DIR}/lib/clc/libclc_dummy_in.cc")
312+
set( dummy_in ${LIBCLC_LIBRARY_OUTPUT_INTDIR}/libclc_dummy_in.cc )
311313
add_custom_command( OUTPUT ${dummy_in}
312-
COMMAND ${CMAKE_COMMAND} -E touch ${dummy_in} )
314+
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
315+
COMMAND ${CMAKE_COMMAND} -E touch ${dummy_in}
316+
)
313317
set(long_widths l32 l64)
314318
set(char_signedness signed unsigned)
315319
if( ${obj_suffix} STREQUAL "libspirv-nvptx64--nvidiacl.bc")
@@ -326,6 +330,7 @@ macro(add_libclc_builtin_set arch_suffix)
326330
set( builtins_remangle_path
327331
"${LIBCLC_LIBRARY_OUTPUT_INTDIR}/remangled-${long_width}-${signedness}_char.${obj_suffix_mangled}" )
328332
add_custom_command( OUTPUT "${builtins_remangle_path}"
333+
COMMAND ${CMAKE_COMMAND} -E make_directory ${LIBCLC_LIBRARY_OUTPUT_INTDIR}
329334
COMMAND libclc::libclc-remangler
330335
-o "${builtins_remangle_path}"
331336
--long-width=${long_width}

0 commit comments

Comments
 (0)