From dbe473bc83c6cec8bcb5e7d48a571a18e616ab89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20B=C3=B8e?= Date: Thu, 11 Nov 2021 12:48:28 +0100 Subject: [PATCH] cmake: Test the compiler before testing compiler flags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We used to test that the compiler works at all, before testing compiler flags. But during some toolchain refactoring this got re-arranged. This commit corrects the ordering. Signed-off-by: Sebastian Bøe --- CMakeLists.txt | 5 ----- cmake/app/boilerplate.cmake | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b34bdf021a6..f95c97ba3de 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,11 +36,6 @@ endif() # -fmacro-prefix-map=${ZEPHYR_BASE}= -# Verify that the toolchain can compile a dummy file, if it is not we -# won't be able to test for compatibility with certain C flags. -zephyr_check_compiler_flag(C "" toolchain_is_ok) -assert(toolchain_is_ok "The toolchain is unable to build a dummy C file. See CMakeError.log.") - # In some cases the "final" things are not used at all and "_prebuilt" # is the last station. See "logical_target_for_zephyr_elf" below for # details. diff --git a/cmake/app/boilerplate.cmake b/cmake/app/boilerplate.cmake index 1fb8499de7c..6102d739c9f 100644 --- a/cmake/app/boilerplate.cmake +++ b/cmake/app/boilerplate.cmake @@ -595,11 +595,18 @@ project(Zephyr-Kernel VERSION ${PROJECT_VERSION}) # windows now. list(APPEND CMAKE_ASM_SOURCE_FILE_EXTENSIONS "S") enable_language(C CXX ASM) + # The setup / configuration of the toolchain itself and the configuration of # supported compilation flags are now split, as this allows to use the toolchain # for generic purposes, for example DTS, and then test the toolchain for # supported flags at stage two. # Testing the toolchain flags requires the enable_language() to have been called in CMake. + +# Verify that the toolchain can compile a dummy file, if it is not we +# won't be able to test for compatibility with certain C flags. +zephyr_check_compiler_flag(C "" toolchain_is_ok) +assert(toolchain_is_ok "The toolchain is unable to build a dummy C file. See CMakeError.log.") + include(${ZEPHYR_BASE}/cmake/target_toolchain_flags.cmake) # 'project' sets PROJECT_BINARY_DIR to ${CMAKE_CURRENT_BINARY_DIR},