You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2023/12/06 15:56:27 UTC
(nuttx) 03/04: cmake: split extra library from library group
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
commit a3eb42f469eec52bd87436588b7ed1218cc824fd
Author: chao an <an...@xiaomi.com>
AuthorDate: Tue Oct 31 22:58:18 2023 +0800
cmake: split extra library from library group
Signed-off-by: chao an <an...@xiaomi.com>
---
CMakeLists.txt | 19 ++++++++++---------
arch/arm/src/cmake/platform.cmake | 2 +-
arch/risc-v/src/cmake/platform.cmake | 2 +-
cmake/nuttx_add_library.cmake | 14 +++++++++++++-
4 files changed, 25 insertions(+), 12 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fe98f1c649..efddcd1be9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -595,14 +595,15 @@ endif()
get_property(nuttx_apps_libs GLOBAL PROPERTY NUTTX_APPS_LIBRARIES)
get_property(nuttx_extra_libs GLOBAL PROPERTY NUTTX_EXTRA_LIBRARIES)
-set(nuttx_libs ${nuttx_kernel_libs} ${nuttx_system_libs} ${nuttx_apps_libs}
- ${nuttx_extra_libs})
+set(nuttx_libs ${nuttx_kernel_libs} ${nuttx_system_libs} ${nuttx_apps_libs})
if(NOT CONFIG_ARCH_SIM)
+
# TODO: nostart/nodefault not applicable to nuttx toolchain
target_link_libraries(
- nuttx PRIVATE ${NUTTX_EXTRA_FLAGS} -Wl,--script=${ldscript}
- -Wl,--start-group ${nuttx_libs} -Wl,--end-group)
+ nuttx
+ PRIVATE ${NUTTX_EXTRA_FLAGS} -Wl,--script=${ldscript} -Wl,--start-group
+ ${nuttx_libs} ${nuttx_extra_libs} -Wl,--end-group)
# generate binary outputs in different formats (.bin, .hex, etc)
nuttx_generate_outputs(nuttx)
@@ -635,8 +636,8 @@ elseif(WIN32)
add_custom_command(
OUTPUT ${CMAKE_BINARY_DIR}/nuttx_all.lib
COMMAND ${CMAKE_AR} /OUT:${CMAKE_BINARY_DIR}/nuttx_all.lib
- ${nuttx_libs_paths}
- DEPENDS ${nuttx_libs}
+ ${nuttx_libs_paths} ${nuttx_extra_libs}
+ DEPENDS ${nuttx_libs} ${nuttx_extra_libs}
VERBATIM)
add_custom_target(nuttx_all-lib DEPENDS ${CMAKE_BINARY_DIR}/nuttx_all.lib)
add_dependencies(nuttx nuttx_all-lib)
@@ -692,10 +693,10 @@ else()
COMMAND
${CMAKE_C_COMPILER} ARGS -r $<$<BOOL:${CONFIG_SIM_M32}>:-m32>
$<TARGET_OBJECTS:sim_head> $<$<NOT:$<BOOL:${APPLE}>>:-Wl,--start-group>
- ${nuttx_libs_paths} $<$<NOT:$<BOOL:${APPLE}>>:-Wl,--end-group> -o
- nuttx.rel
+ ${nuttx_libs_paths} ${nuttx_extra_libs}
+ $<$<NOT:$<BOOL:${APPLE}>>:-Wl,--end-group> -o nuttx.rel
COMMAND ${CMAKE_OBJCOPY} --redefine-syms=nuttx-names.dat nuttx.rel
- DEPENDS ${nuttx_libs_paths} sim_head
+ DEPENDS ${nuttx_libs} ${nuttx_extra_libs} sim_head
COMMAND_EXPAND_LISTS)
add_custom_target(nuttx-rel DEPENDS nuttx.rel
$<$<NOT:$<BOOL:${APPLE}>>:nuttx.ld>)
diff --git a/arch/arm/src/cmake/platform.cmake b/arch/arm/src/cmake/platform.cmake
index 7463745b74..5337cf994d 100644
--- a/arch/arm/src/cmake/platform.cmake
+++ b/arch/arm/src/cmake/platform.cmake
@@ -100,7 +100,7 @@ if(CONFIG_ARCH_COVERAGE)
list(APPEND EXTRA_LIB ${extra_library})
endif()
-set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${EXTRA_LIB})
+nuttx_add_extra_library(${EXTRA_LIB})
separate_arguments(CMAKE_C_FLAG_ARGS NATIVE_COMMAND ${CMAKE_C_FLAGS})
set(PREPROCES ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} -E -P -x c)
diff --git a/arch/risc-v/src/cmake/platform.cmake b/arch/risc-v/src/cmake/platform.cmake
index 8280e5e37b..79893f8388 100644
--- a/arch/risc-v/src/cmake/platform.cmake
+++ b/arch/risc-v/src/cmake/platform.cmake
@@ -56,7 +56,7 @@ if(CONFIG_ARCH_COVERAGE)
list(APPEND EXTRA_LIB ${extra_library})
endif()
-set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${EXTRA_LIB})
+nuttx_add_extra_library(${EXTRA_LIB})
separate_arguments(CMAKE_C_FLAG_ARGS NATIVE_COMMAND ${CMAKE_C_FLAGS})
set(PREPROCES ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} -E -P -x c)
diff --git a/cmake/nuttx_add_library.cmake b/cmake/nuttx_add_library.cmake
index 9795aed5f1..997ed228ed 100644
--- a/cmake/nuttx_add_library.cmake
+++ b/cmake/nuttx_add_library.cmake
@@ -171,7 +171,7 @@ define_property(
function(nuttx_add_library target)
add_library(${target} ${ARGN})
- set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${target})
+ set_property(GLOBAL APPEND PROPERTY NUTTX_SYSTEM_LIBRARIES ${target})
get_target_property(target_type ${target} TYPE)
if(${target_type} STREQUAL "STATIC_LIBRARY")
@@ -181,6 +181,18 @@ function(nuttx_add_library target)
nuttx_add_library_internal(${target})
endfunction()
+# =============================================================================
+#
+# nuttx_add_extra_library
+#
+# Add extra library to extra attribute
+#
+function(nuttx_add_extra_library)
+ foreach(target ${ARGN})
+ set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${target})
+ endforeach()
+endfunction()
+
# Import static library
#
function(nuttx_library_import library_name library_path)