Skip to content

Commit a14d247

Browse files
committed
[clang][CMake] Fix clang headers when using ninja multi config
1 parent 1555d9e commit a14d247

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

clang/lib/Headers/CMakeLists.txt

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,25 @@ set(riscv_generated_files)
395395

396396
function(copy_header_to_output_dir src_dir file)
397397
set(src ${src_dir}/${file})
398-
set(dst ${output_dir}/${file})
399-
add_custom_command(OUTPUT ${dst}
400-
DEPENDS ${src}
401-
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
402-
COMMENT "Copying clang's ${file}...")
403-
list(APPEND out_files ${dst})
398+
if("${CMAKE_CFG_INTDIR}" STREQUAL ".")
399+
set(dst ${output_dir}/${file})
400+
add_custom_command(OUTPUT ${dst}
401+
DEPENDS ${src}
402+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
403+
COMMENT "Copying clang's ${file}...")
404+
list(APPEND out_files ${dst})
405+
else()
406+
foreach(BUILD_MODE ${CMAKE_CONFIGURATION_TYPES})
407+
# Replace the special string with a per config directory.
408+
string(REPLACE ${CMAKE_CFG_INTDIR} ${BUILD_MODE} per_conf_output_dir ${output_dir})
409+
set(dst ${per_conf_output_dir}/${file})
410+
add_custom_command(OUTPUT ${dst}
411+
DEPENDS ${src}
412+
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
413+
COMMENT "Copying clang's ${file}...")
414+
list(APPEND out_files ${dst})
415+
endforeach()
416+
endif()
404417
set(out_files ${out_files} PARENT_SCOPE)
405418
endfunction(copy_header_to_output_dir)
406419

0 commit comments

Comments
 (0)