Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions libclc/cmake/modules/AddLibclc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ function(compile_to_bc)
get_filename_component( ARG_OUTPUT_DIR ${ARG_OUTPUT} DIRECTORY )
file( MAKE_DIRECTORY ${ARG_OUTPUT_DIR} )

set( COMMAND_ADDITIONAL_OPTIONS )
if( CMAKE_VERSION VERSION_GREATER_EQUAL "3.27" )
list( APPEND COMMAND_ADDITIONAL_OPTIONS DEPENDS_EXPLICIT_ONLY )
endif()

add_custom_command(
OUTPUT ${ARG_OUTPUT}${TMP_SUFFIX}
COMMAND ${clang_exe}
Expand All @@ -64,13 +69,13 @@ function(compile_to_bc)
${ARG_INPUT}
${ARG_DEPENDENCIES}
DEPFILE ${ARG_OUTPUT}.d
${COMMAND_ADDITIONAL_OPTIONS}
)
# FIXME: The target is added to ensure the parallel build of source files.
# However, this may result in a large number of targets.
# Starting with CMake 3.27, DEPENDS_EXPLICIT_ONLY can be used with
# add_custom_command to enable parallel build.
# Refer to https://gitlab.kitware.com/cmake/cmake/-/issues/17097 for details.
add_custom_target( ${ARG_TARGET} DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} )
# If DEPENDS_EXPLICIT_ONLY isn't available, add target to ensure the parallel
# build of source files on Windows.
if( CMAKE_VERSION VERSION_LESS "3.27" )
add_custom_target( ${ARG_TARGET} DEPENDS ${ARG_OUTPUT}${TMP_SUFFIX} )
endif()

if( ${FILE_EXT} STREQUAL ".ll" )
add_custom_command(
Expand Down Expand Up @@ -324,7 +329,9 @@ function(add_libclc_builtin_set)
-I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
DEPENDENCIES ${input_file_dep}
)
list( APPEND compile_tgts ${tgt} )
if( CMAKE_VERSION VERSION_LESS "3.27" )
list( APPEND compile_tgts ${tgt} )
endif()

# Collect all files originating in LLVM IR separately
get_filename_component( file_ext ${file} EXT )
Expand Down
Loading