Skip to content
Commit 96e7df46 authored by Sebastian Bøe's avatar Sebastian Bøe Committed by Anas Nashif
Browse files

cmake: Give zephyr_library_* flags precedence over zephyr_* flags

This fixes https://github.com/zephyrproject-rtos/zephyr/issues/5097

.

The desired behaviour is that when a flag that is given through the
zephyr_* API conflicts with the zephyr_library_* API then precedence
will be given to the zephyr_library_* API. In other words, local
configuration overrides global configuration.

We choose to rely upon the compiler for sane behaviour when flags are
in conflict. Compilers generally give precedence to flags given late
on the command line. So to ensure that zephyr_library_* flags are
placed late on the command line we create a dummy interface library
and link with it to obtain the flags.

Other options were considered, source file properties would also have
higher priority. But that would have required some kind of
post-processing stage that applies all the source file properties.

Linking with a dummy interface library will place flags later on the
command line than the the flags from zephyr_interface because
zephyr_interface will be the first interface library that flags are
taken from.

Signed-off-by: default avatarSebastian Boe <sebastian.boe@nordicsemi.no>
parent 46e0afdf
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment