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

xiaoxiang781216 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 8f7dc8ee7bd cmake(bugfix): add HEAD source directly to nuttx target in 
cmake
8f7dc8ee7bd is described below

commit 8f7dc8ee7bd4f26c3a7a7c6c0faa113a20504eb6
Author: xuxin19 <[email protected]>
AuthorDate: Tue Jun 10 19:47:23 2025 +0800

    cmake(bugfix): add HEAD source directly to nuttx target in cmake
    
    In the current cmake build, all sources of arch will be added to libarch.a,
    which will cause a hidden problem: vector may be ignored by the linker.
    
    In the makefile, HEADSRC is a header link file independent of the static 
library,
    so there will be no such problem.
    
    In this patch, we also assign HEAD src in cmake directly to nuttx,
    so that it can directly participate in the link.
    
    Signed-off-by: xuxin19 <[email protected]>
---
 CMakeLists.txt                       | 4 +++-
 arch/arm/src/arm/CMakeLists.txt      | 2 +-
 arch/arm/src/armv7-a/CMakeLists.txt  | 2 +-
 arch/arm/src/armv7-r/CMakeLists.txt  | 2 +-
 arch/arm/src/armv8-r/CMakeLists.txt  | 2 +-
 arch/arm64/src/common/CMakeLists.txt | 4 +---
 6 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73ab3c8dbfe..e078375b53e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -652,7 +652,7 @@ endif()
 
 add_definitions(-D__NuttX__)
 
-add_compile_options($<$<COMPILE_LANGUAGE:ASM>:-D__ASSEMBLY__>)
+add_compile_definitions($<$<COMPILE_LANGUAGE:ASM>:__ASSEMBLY__>)
 
 # Setup main nuttx target ####################################################
 
@@ -702,6 +702,8 @@ if(CONFIG_ARCH_SIM)
     target_link_libraries(nuttx PRIVATE ${NUTTX_BINARY_DIR}/nuttx.rel)
   endif()
 else()
+  # Make nuttx target can inheriting common compilation properties
+  nuttx_add_library_internal(nuttx)
   # These flags apply to source files not part of the library. In sim build 
this
   # corresponds to "host" files, so we only do this on non-sim build
   target_compile_definitions(
diff --git a/arch/arm/src/arm/CMakeLists.txt b/arch/arm/src/arm/CMakeLists.txt
index b0a8f770d3e..9822bef23be 100644
--- a/arch/arm/src/arm/CMakeLists.txt
+++ b/arch/arm/src/arm/CMakeLists.txt
@@ -20,7 +20,7 @@
 #
 # 
##############################################################################
 
-set(SRCS arm_head.S)
+target_sources(nuttx PRIVATE arm_head.S)
 
 list(
   APPEND
diff --git a/arch/arm/src/armv7-a/CMakeLists.txt 
b/arch/arm/src/armv7-a/CMakeLists.txt
index 029fdfecf9b..b96cd738499 100644
--- a/arch/arm/src/armv7-a/CMakeLists.txt
+++ b/arch/arm/src/armv7-a/CMakeLists.txt
@@ -23,7 +23,7 @@
 # The vector table is the "head" object, i.e., the one that must forced into 
the
 # link in order to draw in all of the other components
 
-set(SRCS arm_vectortab.S)
+target_sources(nuttx PRIVATE arm_vectortab.S)
 
 # Common assembly language files
 
diff --git a/arch/arm/src/armv7-r/CMakeLists.txt 
b/arch/arm/src/armv7-r/CMakeLists.txt
index ca46fcf3105..a156a9847c3 100644
--- a/arch/arm/src/armv7-r/CMakeLists.txt
+++ b/arch/arm/src/armv7-r/CMakeLists.txt
@@ -22,7 +22,7 @@
 
 # The vector table
 
-set(SRCS arm_vectortab.S)
+target_sources(nuttx PRIVATE arm_vectortab.S)
 
 # Common assembly language files
 
diff --git a/arch/arm/src/armv8-r/CMakeLists.txt 
b/arch/arm/src/armv8-r/CMakeLists.txt
index 916f49d833a..0e3fca45c0b 100644
--- a/arch/arm/src/armv8-r/CMakeLists.txt
+++ b/arch/arm/src/armv8-r/CMakeLists.txt
@@ -22,7 +22,7 @@
 
 # The vector table
 
-set(SRCS arm_vectortab.S)
+target_sources(nuttx PRIVATE arm_vectortab.S)
 
 # Common assembly language files
 
diff --git a/arch/arm64/src/common/CMakeLists.txt 
b/arch/arm64/src/common/CMakeLists.txt
index 3da5d5e4868..9cfb36f032d 100644
--- a/arch/arm64/src/common/CMakeLists.txt
+++ b/arch/arm64/src/common/CMakeLists.txt
@@ -20,9 +20,7 @@
 #
 # 
##############################################################################
 
-set(SRCS arm64_head.S)
-
-# TODO: support kernel startup obj ctr0
+target_sources(nuttx PRIVATE arm64_head.S)
 
 list(APPEND SRCS arm64_vector_table.S arm64_vectors.S)
 list(APPEND SRCS arm64_fork_func.S)

Reply via email to