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:Sebastian Boe <sebastian.boe@nordicsemi.no>
Loading
Please sign in to comment