Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CMake dependency error with custom linker scripts #406

Merged
merged 2 commits into from
Dec 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions tools/cmake/mbed_set_linker_script.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ function(mbed_setup_linker_script mbed_os_target mbed_baremetal_target target_de
add_custom_command(
OUTPUT
${LINKER_SCRIPT_PATH}
PRE_LINK
JojoS62 marked this conversation as resolved.
Show resolved Hide resolved
COMMAND
COMMAND
${CMAKE_COMMAND} -E echo "Preprocess linker script: ${RAW_LINKER_SCRIPT_NAME} -> ${LINKER_SCRIPT_NAME}"
COMMAND
${CMAKE_C_COMPILER} @${linker_defs_response_file}
Expand Down Expand Up @@ -115,7 +114,7 @@ endfunction(mbed_setup_linker_script)
function(mbed_set_custom_linker_script target new_linker_script_path)

set(RAW_LINKER_SCRIPT_PATHS ${CMAKE_CURRENT_SOURCE_DIR}/${new_linker_script_path})
set(CUSTOM_LINKER_SCRIPT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${target}.link_spript.ld)
set(CUSTOM_LINKER_SCRIPT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${target}.link_script.ld)
JojoS62 marked this conversation as resolved.
Show resolved Hide resolved

# To avoid path limits on Windows, we create a "response file" and set the path to it as a
# global property. We need this solely to pass the compile definitions to GCC's preprocessor,
Expand All @@ -130,7 +129,7 @@ function(mbed_set_custom_linker_script target new_linker_script_path)
${target}
PRE_LINK
COMMAND
${CMAKE_COMMAND} -E echo "Preprocess custom linker script: ${RAW_LINKER_SCRIPT_NAME} -> ${LINKER_SCRIPT_NAME}"
${CMAKE_COMMAND} -E echo "Preprocess custom linker script ${RAW_LINKER_SCRIPT_NAME} to ${LINKER_SCRIPT_NAME}"
JojoS62 marked this conversation as resolved.
Show resolved Hide resolved
COMMAND
${CMAKE_C_COMPILER} @${linker_defs_response_file}
-E -x assembler-with-cpp
Expand All @@ -151,6 +150,6 @@ function(mbed_set_custom_linker_script target new_linker_script_path)
PRIVATE
"-T" "${CUSTOM_LINKER_SCRIPT_PATH}"
)
set_property(TARGET ${target} APPEND PROPERTY LINK_DEPENDS ${CUSTOM_LINKER_SCRIPT_PATH})
set_property(TARGET ${target} APPEND PROPERTY LINK_DEPENDS ${RAW_LINKER_SCRIPT_PATHS})

endfunction(mbed_set_custom_linker_script)
Loading