[llvm] d4d9de3 - [CMake] Support passing arguments to build tool for external projects

Andrew Ng via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 6 03:10:47 PST 2022


Author: Andrew Ng
Date: 2022-01-06T11:09:39Z
New Revision: d4d9de362b6ac2aac67e557f819c57dcfe79e2fe

URL: https://github.com/llvm/llvm-project/commit/d4d9de362b6ac2aac67e557f819c57dcfe79e2fe
DIFF: https://github.com/llvm/llvm-project/commit/d4d9de362b6ac2aac67e557f819c57dcfe79e2fe.diff

LOG: [CMake] Support passing arguments to build tool for external projects

Add CMake variable LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS to allow
arguments to be passed to the native tool used in CMake --build
invocations for external projects.

Can be used to pass extra arguments for enhanced versions of build
tools, e.g. distributed build options.

Differential Revision: https://reviews.llvm.org/D115815

Added: 
    

Modified: 
    llvm/CMakeLists.txt
    llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index edc2c8cded9c2..9548dfff0e2a7 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -176,6 +176,10 @@ if(LLVM_CCACHE_BUILD)
   endif()
 endif()
 
+set(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS "" CACHE STRING
+  "Optional arguments for the native tool used in CMake --build invocations for external projects.")
+mark_as_advanced(LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS)
+
 option(LLVM_DEPENDENCY_DEBUGGING "Dependency debugging mode to verify correctly expressed library dependencies (Darwin only)" OFF)
 
 # Some features of the LLVM build may be disallowed when dependency debugging is

diff  --git a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
index 5f19098614db7..7c417b41cd344 100644
--- a/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
+++ b/llvm/cmake/modules/LLVMExternalProjectUtils.cmake
@@ -11,8 +11,14 @@ function(llvm_ExternalProject_BuildCmd out_var target bin_dir)
     # Use special command for Makefiles to support parallelism.
     set(${out_var} "$(MAKE)" "-C" "${bin_dir}" "${target}" PARENT_SCOPE)
   else()
+    set(tool_args "${LLVM_EXTERNAL_PROJECT_BUILD_TOOL_ARGS}")
+    if(NOT tool_args STREQUAL "")
+      string(CONFIGURE "${tool_args}" tool_args @ONLY)
+      string(PREPEND tool_args "-- ")
+      separate_arguments(tool_args UNIX_COMMAND "${tool_args}")
+    endif()
     set(${out_var} ${CMAKE_COMMAND} --build ${bin_dir} --target ${target}
-                                    --config ${ARG_CONFIGURATION} PARENT_SCOPE)
+                                    --config ${ARG_CONFIGURATION} ${tool_args} PARENT_SCOPE)
   endif()
 endfunction()
 


        


More information about the llvm-commits mailing list