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 9f5a45340f cmake: Use EXTRAFLAGS to define customized compilation 
options
9f5a45340f is described below

commit 9f5a45340ffd709e4a30b91f941e324a3797ba69
Author: chao an <anchao.arc...@bytedance.com>
AuthorDate: Sat Jan 18 09:09:25 2025 +0800

    cmake: Use EXTRAFLAGS to define customized compilation options
    
    align them with the usage habits of makefile
    
    cmake:
    
    cmake -B build -DBOARD_CONFIG=sim/nsh -GNinja -DEXTRAFLAGS="-DCONFIG_AAA=1 
-DCONFIG_BBB=1 -Werror"
    
    makefile:
    
    make -j12 EXTRAFLAGS="-DCONFIG_AAA=1 -DCONFIG_BBB=1 -Werror"
    
    Signed-off-by: chao an <anchao.arc...@bytedance.com>
---
 cmake/nuttx_add_library.cmake |  7 +++++++
 cmake/nuttx_mkconfig.cmake    | 16 ----------------
 2 files changed, 7 insertions(+), 16 deletions(-)

diff --git a/cmake/nuttx_add_library.cmake b/cmake/nuttx_add_library.cmake
index 380696af0a..1b9b409f6b 100644
--- a/cmake/nuttx_add_library.cmake
+++ b/cmake/nuttx_add_library.cmake
@@ -53,6 +53,13 @@ function(nuttx_add_library_internal target)
     ${target}
     PRIVATE $<GENEX_EVAL:$<TARGET_PROPERTY:nuttx,NUTTX_INCLUDE_DIRECTORIES>>)
 
+  # add extra flags into command line
+
+  if(DEFINED EXTRAFLAGS)
+    string(REPLACE " " ";" eflags "${EXTRAFLAGS}")
+    target_compile_options(${target} PRIVATE ${eflags})
+  endif()
+
   # Set install config for all library
   install(TARGETS ${target})
 endfunction()
diff --git a/cmake/nuttx_mkconfig.cmake b/cmake/nuttx_mkconfig.cmake
index 8b334c2b67..e5ff721a44 100644
--- a/cmake/nuttx_mkconfig.cmake
+++ b/cmake/nuttx_mkconfig.cmake
@@ -135,22 +135,6 @@ foreach(NameAndValue ${ConfigContents})
   endif()
 endforeach()
 
-# cmake-format: off
-# add support of set custom command options to config.h
-# Use the -D parameter to pass the config to header file.
-# NOTE which must start with the CONFIG_ prefix.
-# eg:
-#    cmake -DCONFIG_AAA=1 -DCONFIG_BBB=1 -B build -DBOARD_CONFIG=sim/nsh 
-GNinja
-# cmake-format: on
-
-get_cmake_property(cache_vars CACHE_VARIABLES)
-foreach(var ${cache_vars})
-  string(REGEX MATCH "^CONFIG_[^=]+" name ${var})
-  if(name)
-    file(APPEND ${CONFIG_H} "#define ${var} ${${var}}\n")
-  endif()
-endforeach()
-
 file(APPEND ${CONFIG_H}
      "\n/* Sanity Checks *****************************************/\n\n")
 file(APPEND ${CONFIG_H}

Reply via email to