[llvm] Change quoting of CMake parameters in llvm_create_cross_target (PR #171467)

Johan Bengtsson via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 9 08:12:01 PST 2025


https://github.com/JohanBengtssonIAR created https://github.com/llvm/llvm-project/pull/171467

add_custom_command in CMake handles parameters enclosed by quotes and parameters containing quoted parts differently. In the first case the quotes are removed in the executed command line while they are retained for the second case.

Since the entire parameters setting CMAKE_MAKE_PROGRAM, CMAKE_C_COMPILER_LAUNCHER, and CMAKE_CXX_LAUNCHER was enclosed by quotes the recursive CMake call broke when either of these three cmake variables contained spaces.

>From 85200356ad72ed9184c8aae604ea85c82b72311b Mon Sep 17 00:00:00 2001
From: Johan Bengtsson <johan.bengtsson at iar.com>
Date: Tue, 9 Dec 2025 16:56:39 +0100
Subject: [PATCH] Change quoting of CMake parameters in
 llvm_create_cross_target

add_custom_command in CMake handles parameters enclosed by quotes and
parameters containing quoted parts differently. In the first case the quotes
are removed in the executed command line while they are retained for the second
case.

Since the entire parameters setting CMAKE_MAKE_PROGRAM,
CMAKE_C_COMPILER_LAUNCHER, and CMAKE_CXX_LAUNCHER was enclosed by quotes the
recursive CMake call broke when either of these three cmake variables contained
spaces.
---
 llvm/cmake/modules/CrossCompile.cmake | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/llvm/cmake/modules/CrossCompile.cmake b/llvm/cmake/modules/CrossCompile.cmake
index 6075e6abdde74..d0bd2ba4a70ac 100644
--- a/llvm/cmake/modules/CrossCompile.cmake
+++ b/llvm/cmake/modules/CrossCompile.cmake
@@ -85,9 +85,9 @@ function(llvm_create_cross_target project_name target_name toolchain buildtype)
 
   add_custom_command(OUTPUT ${${project_name}_${target_name}_BUILD}/CMakeCache.txt
     COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
-        "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}"
-        "-DCMAKE_C_COMPILER_LAUNCHER=${CMAKE_C_COMPILER_LAUNCHER}"
-        "-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}"
+        -DCMAKE_MAKE_PROGRAM="${CMAKE_MAKE_PROGRAM}"
+        -DCMAKE_C_COMPILER_LAUNCHER="${CMAKE_C_COMPILER_LAUNCHER}"
+        -DCMAKE_CXX_COMPILER_LAUNCHER="${CMAKE_CXX_COMPILER_LAUNCHER}"
         ${CROSS_TOOLCHAIN_FLAGS_${target_name}} ${CMAKE_CURRENT_SOURCE_DIR}
         ${CROSS_TOOLCHAIN_FLAGS_${project_name}_${target_name}}
         -DLLVM_TARGET_IS_CROSSCOMPILE_HOST=TRUE



More information about the llvm-commits mailing list