diff --git a/CMakeLists.txt b/CMakeLists.txt index b34ef7beb65..6dcb8bf28ee 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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_include_directories(zephyr_interface SYSTEM INTERFACE $) + +# Finally export all build flags from Zephyr +add_subdirectory_ifdef( + CONFIG_MAKEFILE_EXPORTS + cmake/makefile_exports + ) diff --git a/cmake/makefile_exports/CMakeLists.txt b/cmake/makefile_exports/CMakeLists.txt index e864c02135a..7120c9826f0 100644 --- a/cmake/makefile_exports/CMakeLists.txt +++ b/cmake/makefile_exports/CMakeLists.txt @@ -1,6 +1,11 @@ # Copyright (c) 2020 Nordic Semiconductor ASA # SPDX-License-Identifier: Apache-2.0 + +zephyr_get_compile_options_for_lang(ASM ASM_compile_options) +zephyr_get_compile_options_for_lang(C C_compile_options) +zephyr_get_compile_options_for_lang(CXX CXX_compile_options) + set(exports " CC = ${CMAKE_C_COMPILER} @@ -11,7 +16,7 @@ AS = ${CMAKE_AS} AR = ${CMAKE_AR} NM = ${CMAKE_NM} GDB = ${CMAKE_GDB} -Z_CFLAGS = -I$, -I> -isystem $, -isystem > -D$, -D> $, > +Z_CFLAGS = -I$, -I> -isystem $, -isystem > -D$, -D> $<$:${ASM_compile_options}> $<$:${C_compile_options}> $<$:${CXX_compile_options}> " )