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 f6db05a94fd3ccf72fe6f46e54cc4e433c2a6ede
Author: xuxin19 <[email protected]>
AuthorDate: Thu Dec 5 20:30:18 2024 +0800

    cmake(enhance):add target we can dump all CMake lib targets
    
    `cmake --build -t dump_targets`
    list all lib target current generator need to build
    
    Signed-off-by: xuxin19 <[email protected]>
---
 cmake/nuttx_add_library.cmake |  6 ++++++
 cmake/nuttx_extensions.cmake  | 15 +++++++++++++++
 2 files changed, 21 insertions(+)

diff --git a/cmake/nuttx_add_library.cmake b/cmake/nuttx_add_library.cmake
index 1b9b409f6b5..2b4c1172bf1 100644
--- a/cmake/nuttx_add_library.cmake
+++ b/cmake/nuttx_add_library.cmake
@@ -62,6 +62,12 @@ function(nuttx_add_library_internal target)
 
   # Set install config for all library
   install(TARGETS ${target})
+  # Set target information for debug and dump
+  set_property(
+    TARGET nuttx_target_interface
+    APPEND
+    PROPERTY ALL_TARGETS ${target})
+  file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/targets "${target}\n")
 endfunction()
 
 # Auxiliary libraries
diff --git a/cmake/nuttx_extensions.cmake b/cmake/nuttx_extensions.cmake
index c10b97b5848..89594dcdcfa 100644
--- a/cmake/nuttx_extensions.cmake
+++ b/cmake/nuttx_extensions.cmake
@@ -28,6 +28,10 @@ include(nuttx_parse_function_args)
 # compiler options and include path needed by all apps libraries.
 add_custom_target(nuttx_apps_interface)
 
+# "nuttx_target_interface" is a source-less target that hold target information
+# for target debug and dump
+add_custom_target(nuttx_target_interface)
+
 # Macro: nuttx_library
 #
 # Creates a library target with the given name and mode. If MODE is "KERNEL", 
it
@@ -298,3 +302,14 @@ function(nuttx_link_libraries)
     endforeach()
   endif()
 endfunction()
+
+# dump targets information
+add_custom_target(
+  dump_targets
+  COMMAND ${CMAKE_COMMAND} -E remove target_dump
+  COMMAND ${CMAKE_COMMAND} -E echo
+          "'$<TARGET_PROPERTY:nuttx_target_interface,ALL_TARGETS>'"
+  COMMAND
+    ${CMAKE_COMMAND} -E echo
+    "'$<TARGET_PROPERTY:nuttx_target_interface,ALL_TARGETS>'" >> target_dump
+  WORKING_DIRECTORY ${CMAKE_BINARY_DIR})

Reply via email to