[libclc] [libclc] Enable DEPENDS_EXPLICIT_ONLY if cmake version >= 3.27 (PR #154084)
Wenju He via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 18 02:29:22 PDT 2025
https://github.com/wenju-he created https://github.com/llvm/llvm-project/pull/154084
Commit 0c21d6b4c8ad fixed sequential build of libclc on Windows by adding a target for each compile command.
This PR conditionally enables DEPENDS_EXPLICIT_ONLY and requires at least cmake version 3.27. DEPENDS_EXPLICIT_ONLY avoids adding too many targets.
>From a9a2b0a6f8271e125722858080c8a8c29309b997 Mon Sep 17 00:00:00 2001
From: Wenju He <wenju.he at intel.com>
Date: Mon, 18 Aug 2025 11:18:37 +0200
Subject: [PATCH] [libclc] Enable DEPENDS_EXPLICIT_ONLY if cmake version >=
3.27
Commit 0c21d6b4c8ad fixed sequential build of libclc on Windows by
adding a target for each compile command.
This PR conditionally enables DEPENDS_EXPLICIT_ONLY and requires at
least cmake version 3.27. DEPENDS_EXPLICIT_ONLY avoids adding too
many targets.
---
libclc/cmake/modules/AddLibclc.cmake | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/libclc/cmake/modules/AddLibclc.cmake b/libclc/cmake/modules/AddLibclc.cmake
index 89d5e1dd6f164..373452c623883 100644
--- a/libclc/cmake/modules/AddLibclc.cmake
+++ b/libclc/cmake/modules/AddLibclc.cmake
@@ -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}
@@ -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(
@@ -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 )
More information about the cfe-commits
mailing list