cmake: Configure custom linker script Kconfig before usage

Allows having CMake variables inside of this Kconfig to e.g. use a
value that can specify a board directory or path relative to a
CMake file location variable

Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
Jamie McCrae 2025-01-08 08:12:10 +00:00 committed by Benjamin Cabé
commit 2e436564a6

View file

@ -1109,10 +1109,10 @@ set_ifndef( TOPT "${COMPILER_TOPT}")
set_ifndef( TOPT -Wl,-T) # Use this if the compiler driver doesn't set a value
if(CONFIG_HAVE_CUSTOM_LINKER_SCRIPT)
set(LINKER_SCRIPT ${APPLICATION_SOURCE_DIR}/${CONFIG_CUSTOM_LINKER_SCRIPT})
string(CONFIGURE ${APPLICATION_SOURCE_DIR}/${CONFIG_CUSTOM_LINKER_SCRIPT} LINKER_SCRIPT)
if(NOT EXISTS ${LINKER_SCRIPT})
set(LINKER_SCRIPT ${CONFIG_CUSTOM_LINKER_SCRIPT})
assert_exists(CONFIG_CUSTOM_LINKER_SCRIPT)
string(CONFIGURE ${CONFIG_CUSTOM_LINKER_SCRIPT} LINKER_SCRIPT)
assert_exists(LINKER_SCRIPT)
endif()
elseif(DEFINED BOARD_LINKER_SCRIPT)
set(LINKER_SCRIPT ${BOARD_LINKER_SCRIPT})