This is an automated email from the ASF dual-hosted git repository.

lupyuen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git

commit 9a0c249c79dd81551aa2d71bba846e82f9c48876
Author: Arjav Patel <[email protected]>
AuthorDate: Sat May 23 09:10:51 2026 +0000

    apps/system/microros: add CMake ExternalProject build support.
    
    Mirror the Makefile build pipeline into CMakeLists.txt using
    ExternalProject_Add so that CMake-based NuttX builds (cmake --build)
    can also produce libmicroros.a.  The external project delegates to the
    existing Makefile targets, then exposes the result via an IMPORTED
    STATIC library target with correct INTERFACE_INCLUDE_DIRECTORIES.
    
    Signed-off-by: Arjav Patel <[email protected]>
---
 system/microros/CMakeLists.txt | 24 +++++++++++++++++++++++-
 1 file changed, 23 insertions(+), 1 deletion(-)

diff --git a/system/microros/CMakeLists.txt b/system/microros/CMakeLists.txt
index 9edae8cef..44cd0d25b 100644
--- a/system/microros/CMakeLists.txt
+++ b/system/microros/CMakeLists.txt
@@ -21,5 +21,27 @@
 # 
##############################################################################
 
 if(CONFIG_SYSTEM_MICROROS)
-  nuttx_add_library(microros)
+  set(MICROROS_DIR ${CMAKE_CURRENT_LIST_DIR})
+  set(MICROROS_LIB_DIR ${MICROROS_DIR}/micro_ros_lib)
+  set(MICROROS_DISTRO ${CONFIG_MICROROS_DISTRO})
+
+  include(ExternalProject)
+
+  ExternalProject_Add(
+    microros_build
+    SOURCE_DIR ${MICROROS_LIB_DIR}
+    CONFIGURE_COMMAND ""
+    BUILD_COMMAND
+      ${CMAKE_COMMAND} -E env CC=${CMAKE_C_COMPILER} CXX=${CMAKE_CXX_COMPILER}
+      AR=${CMAKE_AR} CFLAGS=${CMAKE_C_FLAGS} CXXFLAGS=${CMAKE_CXX_FLAGS} make 
-C
+      ${MICROROS_DIR} libmicroros.a
+    INSTALL_COMMAND ""
+    BUILD_IN_SOURCE TRUE
+    BUILD_BYPRODUCTS ${MICROROS_DIR}/libmicroros.a)
+
+  nuttx_add_library(microros STATIC IMPORTED GLOBAL)
+  set_target_properties(
+    microros PROPERTIES IMPORTED_LOCATION ${MICROROS_DIR}/libmicroros.a
+                        INTERFACE_INCLUDE_DIRECTORIES ${MICROROS_DIR}/include)
+  add_dependencies(microros microros_build)
 endif()

Reply via email to