cmake/nuttx_add_library.cmake:add target that define in external module CMakeLists.txt

when nuttx's CMake build system calls an external module that already supports CMake,
since `add_library` may have been called internally,
it needs to provide a way to add its internally defined target to the final link.

Signed-off-by: xuxin19 <xuxin19@xiaomi.com>
This commit is contained in:
xuxin19 2024-02-21 17:08:48 +08:00 committed by archer
parent f4bc5b5c6b
commit 5452f013df

View file

@ -200,3 +200,22 @@ function(nuttx_library_import library_name library_path)
set_target_properties(${library_name} PROPERTIES IMPORTED_LOCATION
${library_path})
endfunction()
# nuttx_add_external_library
#
# the target library of add_library has been called in external CMakeLists.txt
# so that they can be added to the final link
#
# Usually used with Nuttx to include an external system that already supports
# CMake compilation
function(nuttx_add_external_library target)
cmake_parse_arguments(ARGS MODE "" "" ${ARGN})
if(NOT ARGS_MODE)
set_property(GLOBAL APPEND PROPERTY NUTTX_SYSTEM_LIBRARIES ${target})
elseif("${ARGS_MODE}" STREQUAL "APPS")
set_property(GLOBAL APPEND PROPERTY NUTTX_APPS_LIBRARIES ${target})
elseif("${ARGS_MODE}" STREQUAL "KERNEL")
set_property(GLOBAL APPEND PROPERTY NUTTX_KERNEL_LIBRARIES ${target})
endif()
nuttx_add_library_internal(${target})
endfunction()