cmake: split extra library from library group

Signed-off-by: chao an <anchao@xiaomi.com>
This commit is contained in:
chao an 2023-10-31 22:58:18 +08:00 committed by Xiang Xiao
parent bc2dfe49f4
commit a3eb42f469
4 changed files with 25 additions and 12 deletions

View file

@ -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>)

View file

@ -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)

View file

@ -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)

View file

@ -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)