zephyr/cmake/linker
Daniel DeGrasse 0ea212918f cmake: extensions: use INTERFACE_SOURCES as property for code relocation
In order to enable code relocation, we use a custom target
(code_data_relocation_target), and add files we wish to relocate, as
well as which sections should be relocated to the COMPILE_DEFINITIONS
property for the target.

This approach has been fragile, because COMPILE_DEFINITIONS can also be
added to for all targets using `add_definitions`. This means if another
part of the project uses `add_definitions` and
CONFIG_CODE_DATA_RELOCATION is on, a warning will appear about the
"file" not being found. The "file" of course, is just the definition
added by `add_definitions`.

To work around this, switch to overloading the INTERFACE_SOURCES
property. This property should be a bit more robust, because nobody else
will add sources to the code_data_relocation_target.

However, this approach has the downside that the CMake documentation
pstates targets created with `add_custom_target()` (which the
code_data_relocation_target is) do not have an INTERFACE scope for
their sources- so while this approach works, it is not officially
supported by CMake

Fixes #60220

Signed-off-by: Daniel DeGrasse <daniel.degrasse@nxp.com>
2024-11-16 13:35:36 -05:00
..
arcmwdt cmake: extensions: use INTERFACE_SOURCES as property for code relocation 2024-11-16 13:35:36 -05:00
armlink
ld cmake: extensions: use INTERFACE_SOURCES as property for code relocation 2024-11-16 13:35:36 -05:00
lld
xt-ld cmake: xcc: remove TOOLCHAIN_LIBS 2024-10-15 19:08:47 -04:00
linker_flags_template.cmake cmake: move specs compiler and linker flags to toolchain properties 2024-10-04 16:34:35 +01:00
linker_libraries_template.cmake
linker_script_common.cmake
target_template.cmake