cmake: move testing of compile flag in environment to top CMakeLists.txt

This moves the test of compile flags set in environment from generic
toolchain to top-level ${ZEPHYR_BASE}/CMakeLists.txt.

In order to cleanup and make Zephyr CMake modules more generic then
the testing of specific compile flags and warn user is not really a
toolchain module responsible but a implementation detail of the project
itself as to how compile flags should be applied in a project.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
This commit is contained in:
Torsten Rasmussen 2022-08-22 16:45:23 +02:00 committed by Carles Cufí
parent 356960bcb5
commit 9a12f8b68b
2 changed files with 11 additions and 9 deletions

View File

@ -131,6 +131,17 @@ foreach(optional_include_dir
endif()
endforeach()
# Don't inherit compiler flags from the environment
foreach(var AFLAGS CFLAGS CXXFLAGS CPPFLAGS LDFLAGS)
if(DEFINED ENV{${var}})
message(WARNING "The environment variable '${var}' was set to $ENV{${var}}, "
"but Zephyr ignores flags from the environment. Use 'cmake "
"-DEXTRA_${var}=$ENV{${var}}' instead."
)
unset(ENV{${var}})
endif()
endforeach()
zephyr_compile_definitions(
KERNEL
__ZEPHYR__=1

View File

@ -20,15 +20,6 @@ if(NOT TOOLCHAIN_ROOT)
endif()
zephyr_file(APPLICATION_ROOT TOOLCHAIN_ROOT)
# Don't inherit compiler flags from the environment
foreach(var AFLAGS CFLAGS CXXFLAGS CPPFLAGS LDFLAGS)
if(DEFINED ENV{${var}})
message(WARNING "The environment variable '${var}' was set to $ENV{${var}},
but Zephyr ignores flags from the environment. Use 'cmake -DEXTRA_${var}=$ENV{${var}}' instead.")
unset(ENV{${var}})
endif()
endforeach()
# Host-tools don't unconditionally set TOOLCHAIN_HOME anymore,
# but in case Zephyr's SDK toolchain is used, set TOOLCHAIN_HOME
if("${ZEPHYR_TOOLCHAIN_VARIANT}" STREQUAL "zephyr")