Skip to content

Commit

Permalink
cmake: split extra library from library group
Browse files Browse the repository at this point in the history
Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao authored and zhhyu7 committed Nov 30, 2023
1 parent cbfc54d commit b4d9496
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
19 changes: 10 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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>)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion arch/risc-v/src/cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 11 additions & 1 deletion cmake/nuttx_add_library.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -181,6 +181,16 @@ 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 target)
set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${target})
endfunction()

# Import static library
#
function(nuttx_library_import library_name library_path)
Expand Down

0 comments on commit b4d9496

Please sign in to comment.