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 e764594d2607b0a4cb680935240ea1655a8db889
Author: Arjav Patel <[email protected]>
AuthorDate: Sat May 23 06:23:38 2026 +0000

    apps/system/microros: add CMake cross-compile toolchain template.
    
    Add toolchain.cmake.in and include_override/assert.h for the colcon
    cross-build.  Key differences from the old robertobucher port:
      - Drop -DCLOCK_MONOTONIC=0: NuttX defines CLOCK_MONOTONIC=1 and
        the override broke nanosleep() on newer kernels.
      - CMAKE_SYSTEM_PROCESSOR is a placeholder substituted per-arch.
      - include_override/assert.h works around the rosidl NDEBUG issue
        (https://github.com/ros2/rosidl/pull/739).
    
    Signed-off-by: Arjav Patel <[email protected]>
---
 .../micro_ros_lib/include_override/assert.h        | 41 ++++++++++++++++++++++
 system/microros/micro_ros_lib/toolchain.cmake.in   | 29 +++++++++++++++
 2 files changed, 70 insertions(+)

diff --git a/system/microros/micro_ros_lib/include_override/assert.h 
b/system/microros/micro_ros_lib/include_override/assert.h
new file mode 100644
index 000000000..1874aa304
--- /dev/null
+++ b/system/microros/micro_ros_lib/include_override/assert.h
@@ -0,0 +1,41 @@
+/****************************************************************************
+ * apps/system/microros/micro_ros_lib/include_override/assert.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __MICROROS_INCLUDE_OVERRIDE_ASSERT_H
+#define __MICROROS_INCLUDE_OVERRIDE_ASSERT_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+/* Pull the system assert.h, then redefine assert to a no-op when NDEBUG is
+ * set.  Avoids an assert redefinition conflict in rosidl typesupport.
+ */
+
+#include_next <assert.h>
+
+#ifdef NDEBUG
+#  undef assert
+#  define assert(x) ((void)(0))
+#endif
+
+#endif /* __MICROROS_INCLUDE_OVERRIDE_ASSERT_H */
diff --git a/system/microros/micro_ros_lib/toolchain.cmake.in 
b/system/microros/micro_ros_lib/toolchain.cmake.in
new file mode 100644
index 000000000..dbdc290e2
--- /dev/null
+++ b/system/microros/micro_ros_lib/toolchain.cmake.in
@@ -0,0 +1,29 @@
+include(CMakeForceCompiler)
+
+set(CMAKE_SYSTEM_NAME Generic)
+set(CMAKE_SYSTEM_PROCESSOR @CMAKE_SYSTEM_PROCESSOR@)
+set(CMAKE_CROSSCOMPILING 1)
+set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
+set(PLATFORM_NAME "nuttx")
+
+set(CMAKE_C_COMPILER @CMAKE_C_COMPILER@)
+set(CMAKE_CXX_COMPILER @CMAKE_CXX_COMPILER@)
+
+set(CMAKE_C_FLAGS_INIT "-std=c11 @ARCH_C_FLAGS@ -D'__attribute__(x)='" CACHE 
STRING "" FORCE)
+set(CMAKE_CXX_FLAGS_INIT "-std=c++14 @ARCH_CPP_FLAGS@ -fno-rtti 
-D'__attribute__(x)='" CACHE STRING "" FORCE)
+
+set(NUTTX_TOPDIR @NUTTX_TOPDIR@)
+set(NUTTX_APPDIR @NUTTX_APPDIR@)
+set(INCLUDE_OVR_DIR @INCLUDE_OVR_DIR@)
+
+include_directories(SYSTEM
+       ${NUTTX_TOPDIR}/include
+       ${NUTTX_TOPDIR}/include/cxx
+       ${NUTTX_APPDIR}/include
+)
+
+include_directories(AFTER SYSTEM
+       ${INCLUDE_OVR_DIR}/include_override
+)
+
+set(__BIG_ENDIAN__ 0)

Reply via email to