Get fast_lio cmake execute the git submodule init

This commit is contained in:
Matt Spencer
2026-07-17 10:42:40 +00:00
parent a9234a90be
commit 6ca2d063d6
2 changed files with 27 additions and 13 deletions
+2 -11
View File
@@ -11,9 +11,6 @@ COPY upstream.jazzy.repos ./upstream.jazzy.repos
# Import all upstream repostories # Import all upstream repostories
RUN vcs import ./src/upstream < ./upstream.jazzy.repos RUN vcs import ./src/upstream < ./upstream.jazzy.repos
RUN cd ./src/upstream/FAST_LIO && \
git submodule update --init
# Apply patches to upstream # Apply patches to upstream
RUN ./patches/apply_patches.sh RUN ./patches/apply_patches.sh
@@ -38,17 +35,11 @@ RUN apt-get update && \
rosdep install --from-paths src --ignore-src -r -y && \ rosdep install --from-paths src --ignore-src -r -y && \
rm -rf /var/lib/apt/lists/* rm -rf /var/lib/apt/lists/*
RUN cd src/upstream/livox_sdk && \
mkdir -p build && \
cd build && rm -rf * && \
cmake .. -DCMAKE_BUILD_TYPE=Release && \
make -j && \
make install
# Build the workspace with symlink install # Build the workspace with symlink install
# livox_sdk is now an ament_cmake package built by colcon (no manual /usr/local install needed).
RUN . /opt/ros/jazzy/setup.sh && \ RUN . /opt/ros/jazzy/setup.sh && \
colcon build --symlink-install \ colcon build --symlink-install \
li --cmake-args -DROS_EDITION=ROS2 -DDISTRO_ROS=jazzy --cmake-args -DROS_EDITION=ROS2 -DDISTRO_ROS=jazzy
# Source the overlay on container startup # Source the overlay on container startup
RUN echo "source /opt/ros/jazzy/setup.bash" >> /root/.bashrc && \ RUN echo "source /opt/ros/jazzy/setup.bash" >> /root/.bashrc && \
+25 -2
View File
@@ -1,14 +1,37 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt
index be3040b..4931c35 100644 index be3040b..3176847 100644
--- a/CMakeLists.txt --- a/CMakeLists.txt
+++ b/CMakeLists.txt +++ b/CMakeLists.txt
@@ -5,17 +5,16 @@ if(NOT CMAKE_BUILD_TYPE) @@ -5,17 +5,39 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) set(CMAKE_BUILD_TYPE Release)
endif() endif()
-ADD_COMPILE_OPTIONS(-std=c++14) -ADD_COMPILE_OPTIONS(-std=c++14)
-ADD_COMPILE_OPTIONS(-std=c++14) -ADD_COMPILE_OPTIONS(-std=c++14)
-set(CMAKE_CXX_FLAGS "-std=c++14 -O3") -set(CMAKE_CXX_FLAGS "-std=c++14 -O3")
+# Ensure the bundled ikd-Tree submodule (include/ikd-Tree/ikd_Tree.cpp) is present.
+# Auto-initialize it when building from a git checkout; otherwise fail with guidance.
+if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/ikd-Tree/ikd_Tree.cpp")
+ find_package(Git QUIET)
+ if(GIT_FOUND AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git")
+ message(STATUS "fast_lio: initializing git submodule include/ikd-Tree")
+ execute_process(
+ COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ RESULT_VARIABLE GIT_SUBMOD_RESULT)
+ if(NOT GIT_SUBMOD_RESULT EQUAL "0")
+ message(FATAL_ERROR
+ "git submodule update --init failed with ${GIT_SUBMOD_RESULT}. "
+ "Run it manually in ${CMAKE_CURRENT_SOURCE_DIR}.")
+ endif()
+ endif()
+ if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/ikd-Tree/ikd_Tree.cpp")
+ message(FATAL_ERROR
+ "include/ikd-Tree/ikd_Tree.cpp is missing and could not be fetched automatically "
+ "(no git checkout available). Run: git submodule update --init --recursive")
+ endif()
+endif()
+
+ADD_COMPILE_OPTIONS(-std=c++17) +ADD_COMPILE_OPTIONS(-std=c++17)
+set(CMAKE_CXX_FLAGS "-std=c++17 -O3") +set(CMAKE_CXX_FLAGS "-std=c++17 -O3")