Skip to content

Commit

Permalink
CMake: Fix escaping of quotes in response file
Browse files Browse the repository at this point in the history
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\".
  • Loading branch information
LDong-Arm committed Aug 31, 2021
1 parent 539d1c7 commit e539009
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/cmake/mbed_toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
"$<$<BOOL:${_compile_definitions}>:-D$<JOIN:${_compile_definitions}, -D>>"
"$<$<BOOL:${_compile_definitions}>:'-D$<JOIN:${_compile_definitions},' '-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)
Expand Down

0 comments on commit e539009

Please sign in to comment.