From e539009e8c19ad50c85667a748b8bd095867e80b Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Tue, 31 Aug 2021 11:14:42 +0100 Subject: [PATCH] CMake: Fix escaping of quotes in response file We put macros in a response file compile_time_defs.txt and pass it to the compiler. When contents of the response file get extracted, a macro like -DFOO=\"BAR\" gets unescaped into -DFOO="BAR" which sets FOO to BAR without quotes. To fix this, add a pair of single quotes around each macro, e.g. '-DFOO=\"BAR\"' in the response file which becomes one-level processed into -DFOO=\"BAR\". --- tools/cmake/mbed_toolchain.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cmake/mbed_toolchain.cmake b/tools/cmake/mbed_toolchain.cmake index 139828921ba2..21c2a27df06e 100644 --- a/tools/cmake/mbed_toolchain.cmake +++ b/tools/cmake/mbed_toolchain.cmake @@ -17,7 +17,7 @@ function(mbed_generate_options_for_linker target output_response_file_path) # Append -D to all macros as we pass these as response file to cxx compiler set(_compile_definitions - "$<$:-D$>" + "$<$:'-D$'>" ) file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n") set(${output_response_file_path} @${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt PARENT_SCOPE)