cmake: export build flags to external build systems excluding SHELL tag

Fixes: #28230

The introduction of CMake SHELL prefix in compile options to avoid
symbol de-duplication caused the build flag export feature to fail.

The export itself works, but unfortunately CMake only strips `SHELL`
prefix for its own compiler invocation, and not when exporting the build
flags.

This causes `SHELL` to be present in the Makefile.exports.<language>
files, leading to problems in external build systems.

This is fixed by using `zephyr_get_compile_options_for_lang()` that
strips `SHELL` and use the returned value for the export handling.

To ensure all compile options has been defined, then the inclusion of
`cmake/makefile_exports` has been moved to the end of
`zephyr/CMakeLists.txt` file.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2020-09-09 15:42:32 +02:00 committed by Carles Cufí
commit a5917f0af4
2 changed files with 12 additions and 6 deletions

View file

@ -1322,11 +1322,6 @@ add_subdirectory(cmake/flash)
add_subdirectory(cmake/usage)
add_subdirectory(cmake/reports)
add_subdirectory_ifdef(
CONFIG_MAKEFILE_EXPORTS
cmake/makefile_exports
)
if(NOT CONFIG_TEST)
if(CONFIG_ASSERT AND (NOT CONFIG_FORCE_NO_ASSERT))
message(WARNING "__ASSERT() statements are globally ENABLED")
@ -1370,3 +1365,9 @@ endif()
# Note, the compile flags are moved, but the system include is still present here.
zephyr_compile_options($<TARGET_PROPERTY:compiler,nostdinc>)
target_include_directories(zephyr_interface SYSTEM INTERFACE $<TARGET_PROPERTY:compiler,nostdinc_include>)
# Finally export all build flags from Zephyr
add_subdirectory_ifdef(
CONFIG_MAKEFILE_EXPORTS
cmake/makefile_exports
)