This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 65aa5415a7 cmake: fix the fdiagnostics-color handle issue
65aa5415a7 is described below

commit 65aa5415a72ac5038c8281d20e7c5eded113866a
Author: guoshichao <guoshic...@xiaomi.com>
AuthorDate: Fri Oct 18 19:58:18 2024 +0800

    cmake: fix the fdiagnostics-color handle issue
    
    Signed-off-by: guoshichao <guoshic...@xiaomi.com>
---
 CMakeLists.txt               | 6 +++---
 arch/arm/src/cmake/gcc.cmake | 5 -----
 cmake/nuttx_toolchain.cmake  | 7 +++++++
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 35a3799e82..51d312571a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -391,14 +391,14 @@ list(APPEND CMAKE_MODULE_PATH 
${CMAKE_SOURCE_DIR}/arch/${CONFIG_ARCH}/src/cmake)
 set(CMAKE_TOOLCHAIN_FILE
     "${CMAKE_SOURCE_DIR}/arch/${CONFIG_ARCH}/src/cmake/Toolchain.cmake")
 
-# include common toolchain setting
-include(nuttx_toolchain)
-
 # Define project #############################################################
 # This triggers configuration
 
 project(NuttX LANGUAGES C CXX ASM)
 
+# include common toolchain setting
+include(nuttx_toolchain)
+
 if(WIN32)
   enable_language(ASM_MASM)
 endif()
diff --git a/arch/arm/src/cmake/gcc.cmake b/arch/arm/src/cmake/gcc.cmake
index 1ebc6a2dfe..4e046e7cb6 100644
--- a/arch/arm/src/cmake/gcc.cmake
+++ b/arch/arm/src/cmake/gcc.cmake
@@ -53,11 +53,6 @@ endif()
 
 set(NO_LTO "-fno-lto")
 
-if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.9)
-  # force color for gcc > 4.9
-  add_compile_options(-fdiagnostics-color=always)
-endif()
-
 # Workaround to skip -Warray-bounds check due to bug of GCC-12: Wrong warning
 # array subscript [0] is outside array bounds:
 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105523
diff --git a/cmake/nuttx_toolchain.cmake b/cmake/nuttx_toolchain.cmake
index 01e7b89c40..05ddf354b0 100644
--- a/cmake/nuttx_toolchain.cmake
+++ b/cmake/nuttx_toolchain.cmake
@@ -23,6 +23,13 @@
 # search. If the manual of the newly supported toolchain is different, you can
 # override these methods in the toolchain
 
+if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU")
+  if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 4.9)
+    # force color for gcc > 4.9
+    add_compile_options(-fdiagnostics-color=always)
+  endif()
+endif()
+
 # Support CMake to define additional configuration options
 
 if(EXTRA_FLAGS)

Reply via email to