Merge pull request #15032 from LDong-Arm/response_file_escape

CMake: Fix escaping of quotes in response file
pull/15029/head
Martin Kojtal 2021-09-01 15:23:09 +01:00 committed by GitHub
commit 79bc5ac43d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 10 deletions

View File

@ -7,17 +7,9 @@ function(mbed_generate_options_for_linker target output_response_file_path)
"$<TARGET_PROPERTY:${target},INTERFACE_COMPILE_DEFINITIONS>" "$<TARGET_PROPERTY:${target},INTERFACE_COMPILE_DEFINITIONS>"
) )
# Remove macro definitions that contain spaces as the lack of escape sequences and quotation marks # Append -D to all macros and quote them as we pass these as response file to cxx compiler
# in the macro when retrieved using generator expressions causes linker errors.
# This includes string macros, array macros, and macros with operations.
# TODO CMake: Add escape sequences and quotation marks where necessary instead of removing these macros.
set(_compile_definitions set(_compile_definitions
"$<FILTER:${_compile_definitions},EXCLUDE, +>" "$<$<BOOL:${_compile_definitions}>:'-D$<JOIN:${_compile_definitions},' '-D>'>"
)
# 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>>"
) )
file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt" CONTENT "${_compile_definitions}\n") 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) set(${output_response_file_path} @${CMAKE_CURRENT_BINARY_DIR}/compile_time_defs.txt PARENT_SCOPE)