From ba56c6c102bc6637c0c1d9733f1ef85d20339a39 Mon Sep 17 00:00:00 2001 From: xuxin19 Date: Mon, 4 Nov 2024 14:16:49 +0800 Subject: [PATCH] cmake(bugfix):make sure the extra_lib only added once Signed-off-by: xuxin19 --- cmake/nuttx_add_library.cmake | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/nuttx_add_library.cmake b/cmake/nuttx_add_library.cmake index 8eede604ef44b..fc97281d9fff3 100644 --- a/cmake/nuttx_add_library.cmake +++ b/cmake/nuttx_add_library.cmake @@ -201,11 +201,13 @@ function(nuttx_add_extra_library) # define the target name of the extra library string(REGEX REPLACE "[^a-zA-Z0-9]" "_" extra_target "${extra_lib}") # set the absolute path of the library for the import target - nuttx_library_import(${extra_target} ${extra_lib}) - set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${extra_target}) - if(CONFIG_BUILD_PROTECTED) - set_property(GLOBAL APPEND PROPERTY NUTTX_USER_EXTRA_LIBRARIES - ${extra_target}) + if(NOT TARGET ${extra_target}) + nuttx_library_import(${extra_target} ${extra_lib}) + set_property(GLOBAL APPEND PROPERTY NUTTX_EXTRA_LIBRARIES ${extra_target}) + if(CONFIG_BUILD_PROTECTED) + set_property(GLOBAL APPEND PROPERTY NUTTX_USER_EXTRA_LIBRARIES + ${extra_target}) + endif() endif() endforeach() endfunction()