Skip to content

Commit aad5c2f

Browse files
[cmake] Honor CMAKE_VERBOSE_MAKEFILE when building external projects (#75749)
When the top-level CMake invocation has `CMAKE_VERBOSE_MAKEFILE=ON`, indicating the user wants to have verbose builds (i.e. all executed commands explicitly echoed), some of the subprojects and runtimes (such as compiler-rt, libcxx, etc) do not build in verbose mode. For example, with Ninja: ``` [ 99% 6252/6308] cd /build/runtimes/builtins-bins && /usr/local/bin/cmake --build . [ 0% 6/308] Building C object CMakeFiles/clang_rt.builtins-i386.dir/absvti2.c.o [ 0% 7/308] Building C object CMakeFiles/clang_rt.builtins-i386.dir/absvdi2.c.o [ 0% 8/308] Building C object CMakeFiles/clang_rt.builtins-i386.dir/absvsi2.c.o ... ``` This is because `llvm_ExternalProject_Add()` and `add_custom_libcxx()` use CMake's `ExternalProject_Add()` function to configure such subproject builds, and do not pass through the `CMAKE_VERBOSE_MAKEFILE` setting. Similar to what is done in `clang/CMakeLists.txt`, add `-DCMAKE_VERBOSE_MAKEFILE=ON` to the `ExternalProject_Add()` invocations in `llvm_ExternalProject_Add()` and `add_custom_libcxx()`, whenever the top-level CMake invocation had `CMAKE_VERBOSE_MAKEFILE` turned on.
1 parent c014454 commit aad5c2f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

compiler-rt/cmake/Modules/AddCompilerRT.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,13 +670,18 @@ macro(add_custom_libcxx name prefix)
670670
get_property(CXX_FLAGS CACHE CMAKE_CXX_FLAGS PROPERTY VALUE)
671671
set(LIBCXX_CXX_FLAGS "${LIBCXX_CXX_FLAGS} ${CXX_FLAGS}")
672672

673+
if(CMAKE_VERBOSE_MAKEFILE)
674+
set(verbose -DCMAKE_VERBOSE_MAKEFILE=ON)
675+
endif()
676+
673677
ExternalProject_Add(${name}
674678
DEPENDS ${name}-clobber ${LIBCXX_DEPS}
675679
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/${name}
676680
SOURCE_DIR ${LLVM_MAIN_SRC_DIR}/../runtimes
677681
BINARY_DIR ${prefix}
678682
CMAKE_ARGS ${CMAKE_PASSTHROUGH_VARIABLES}
679683
${compiler_args}
684+
${verbose}
680685
-DCMAKE_C_FLAGS=${LIBCXX_C_FLAGS}
681686
-DCMAKE_CXX_FLAGS=${LIBCXX_CXX_FLAGS}
682687
-DCMAKE_BUILD_TYPE=Release

llvm/cmake/modules/LLVMExternalProjectUtils.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,10 @@ function(llvm_ExternalProject_Add name source_dir)
319319
list(APPEND compiler_args -DCMAKE_ASM_COMPILER_TARGET=${ARG_TARGET_TRIPLE})
320320
endif()
321321

322+
if(CMAKE_VERBOSE_MAKEFILE)
323+
set(verbose -DCMAKE_VERBOSE_MAKEFILE=ON)
324+
endif()
325+
322326
ExternalProject_Add(${name}
323327
DEPENDS ${ARG_DEPENDS} llvm-config
324328
${name}-clobber
@@ -330,6 +334,7 @@ function(llvm_ExternalProject_Add name source_dir)
330334
CMAKE_ARGS ${${nameCanon}_CMAKE_ARGS}
331335
--no-warn-unused-cli
332336
${compiler_args}
337+
${verbose}
333338
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
334339
${sysroot_arg}
335340
-DLLVM_BINARY_DIR=${PROJECT_BINARY_DIR}

0 commit comments

Comments
 (0)