From 8348d3e8a043ffa6924f759d7c297e1b96c4ed85 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 18:37:45 -0500 Subject: [PATCH 01/12] First cut at cmake build --- CMakeLists.txt | 207 +++++++++++++++++++----------------- cmake/BuildNonROS.cmake | 121 +++++++++++++++++++++ cmake/FindOculusSDK.cmake | 22 ---- cmake/IncludeProject.cmake | 78 ++++++++++++++ cmake/oculusConfig.cmake.in | 10 ++ 5 files changed, 316 insertions(+), 122 deletions(-) create mode 100644 cmake/BuildNonROS.cmake delete mode 100644 cmake/FindOculusSDK.cmake create mode 100644 cmake/IncludeProject.cmake create mode 100644 cmake/oculusConfig.cmake.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 845895d..99762da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,9 @@ -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.8) project(liboculus) # == Code common to all builds ======================================= list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) -# ROS build, determine which version... -find_package(ros_environment REQUIRED) -set(ROS_VERSION $ENV{ROS_VERSION}) - set(oculus_SRCS lib/DataRx.cpp lib/SonarConfiguration.cpp @@ -19,106 +15,117 @@ set(oculus_SRCS lib/IoServiceThread.cpp ) -if(${ROS_VERSION} EQUAL 2) - # == ament/ROS2 section ================================= - - find_package(ament_cmake REQUIRED) - find_package(Boost REQUIRED COMPONENTS system) - find_package(g3log_ros REQUIRED) - - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - add_compile_options(-std=c++17) - - add_library(oculus SHARED ${oculus_SRCS}) - - target_include_directories( - oculus - PUBLIC - "$" - "$" - "$" - "$" - ) - - target_link_libraries(oculus PUBLIC Boost::system g3log_ros::g3log_ros) - - install( - TARGETS oculus - EXPORT export_${PROJECT_NAME} - ARCHIVE DESTINATION lib - LIBRARY DESTINATION lib - RUNTIME DESTINATION bin - ) - - install( - DIRECTORY include/${PROJECT_NAME} thirdparty - DESTINATION include - FILES_MATCHING - PATTERN "*.hpp" - PATTERN "*.h" - PATTERN ".git" EXCLUDE - ) - - ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET) - ament_export_libraries(oculus) - - ament_package() -elseif(${ROS_VERSION} EQUAL 1) - # Catkin/ROS1 section ===== - find_package(catkin REQUIRED COMPONENTS g3log_ros) - find_package(Boost REQUIRED COMPONENTS system) - - catkin_package( - CATKIN_DEPENDS g3log_ros - INCLUDE_DIRS include thirdparty - LIBRARIES liboculus - ) - - add_compile_options(-std=c++14) - - add_library(liboculus ${oculus_SRCS}) - - include_directories(liboculus include thirdparty ${catkin_INCLUDE_DIRS}) - - target_link_libraries(liboculus ${catkin_LIBRARIES}) - - install( - TARGETS liboculus - ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} - RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} - ) - - ## Install headers - install( - DIRECTORY include/${PROJECT_NAME}/ thirdparty/ - DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} - FILES_MATCHING - PATTERN "*.hpp" - PATTERN "*.h" - PATTERN ".git" EXCLUDE - ) - - if(CATKIN_ENABLE_TESTING) - add_definitions( - -DTEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/test/data" +# ROS build, determine which version... +# QUIET will squelch the warning if the package isn't found +find_package(ros_environment QUIET) + +if(${ros_environment_FOUND}) + set(ROS_VERSION $ENV{ROS_VERSION}) + + if(${ROS_VERSION} EQUAL 2) + # == ament/ROS2 section ================================= + + find_package(ament_cmake REQUIRED) + find_package(Boost REQUIRED COMPONENTS system) + find_package(g3log_ros REQUIRED) + + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + add_compile_options(-std=c++17) + + add_library(oculus SHARED ${oculus_SRCS}) + + target_include_directories( + oculus + PUBLIC + "$" + "$" + "$" + "$" + ) + + target_link_libraries(oculus PUBLIC Boost::system g3log_ros::g3log_ros) + + install( + TARGETS oculus + EXPORT export_${PROJECT_NAME} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin ) - include_directories(test/data/) - file(GLOB oculus_test_SRCS test/unit/*cpp) + install( + DIRECTORY include/${PROJECT_NAME} thirdparty + DESTINATION include + FILES_MATCHING + PATTERN "*.hpp" + PATTERN "*.h" + PATTERN ".git" EXCLUDE + ) + + ament_export_targets(export_${PROJECT_NAME} HAS_LIBRARY_TARGET) + ament_export_libraries(oculus) + + ament_package() + elseif(${ROS_VERSION} EQUAL 1) + # Catkin/ROS1 section ===== + find_package(catkin REQUIRED COMPONENTS g3log_ros) + find_package(Boost REQUIRED COMPONENTS system) + + catkin_package( + CATKIN_DEPENDS g3log_ros + INCLUDE_DIRS include thirdparty + LIBRARIES liboculus + ) + + add_compile_options(-std=c++14) - catkin_add_gtest(oculus_test ${oculus_test_SRCS}) + add_library(liboculus ${oculus_SRCS}) + + include_directories(liboculus include thirdparty ${catkin_INCLUDE_DIRS}) + + target_link_libraries(liboculus ${catkin_LIBRARIES}) + + install( + TARGETS liboculus + ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION} + RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION} + ) + + ## Install headers + install( + DIRECTORY include/${PROJECT_NAME}/ thirdparty/ + DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION} + FILES_MATCHING + PATTERN "*.hpp" + PATTERN "*.h" + PATTERN ".git" EXCLUDE + ) - target_link_libraries( - oculus_test - ${catkin_LIBRARIES} - liboculus - Boost::system + if(CATKIN_ENABLE_TESTING) + add_definitions( + -DTEST_DATA_PATH="${CMAKE_CURRENT_SOURCE_DIR}/test/data" + ) + include_directories(test/data/) + + file(GLOB oculus_test_SRCS test/unit/*cpp) + + catkin_add_gtest(oculus_test ${oculus_test_SRCS}) + + target_link_libraries( + oculus_test + ${catkin_LIBRARIES} + liboculus + Boost::system + ) + endif() + else() + message( + "Unsure what sort of build to do. Not in a ROS1 or ROS2 environment" ) endif() else() - message( - "Unsure what sort of build to do. Not in a ROS1 or ROS2 environment" - ) + message(NOTICE "!! Performing non-ROS build !!") + include(cmake/BuildNonROS.cmake) endif() diff --git a/cmake/BuildNonROS.cmake b/cmake/BuildNonROS.cmake new file mode 100644 index 0000000..93ca322 --- /dev/null +++ b/cmake/BuildNonROS.cmake @@ -0,0 +1,121 @@ +# Specify the minimum version for CMake +cmake_minimum_required(VERSION 3.8) + +# Project's name +project(liboculus) + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -march=native -Wl,--no-as-needed") + +# Set the output folder where your program will be created +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib) + +# ########################################### +# The following folders will be included # +# ########################################### +include_directories( + "${PROJECT_SOURCE_DIR}/include/" + "${PROJECT_SOURCE_DIR}/thirdparty/" +) + +# Threading +find_package(Threads) + +# Boost +find_package(Boost 1.57 REQUIRED COMPONENTS system) +include_directories(${Boost_INCLUDE_DIR}) +message("Boost_INCLUDE_DIR: " ${Boost_INCLUDE_DIR}) + +# Install g3log as an external package +include(cmake/IncludeProject.cmake) + +if(NOT GIT_TAG) + set(GIT_TAG "2.6") +endif() + +include(ExternalProject) +ExternalProject_Add( + g3log + GIT_REPOSITORY https://github.com/KjellKod/g3log + GIT_TAG ${GIT_TAG} + INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/install/g3log" + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= +) + +ExternalProject_Get_Property(g3log install_dir) +include_directories(${install_dir}/include/) + +# ##################### +# Add Execuatables # +# ##################### +link_directories(${Boost_LIBRARY_DIRS}) + +# Create Library +add_library(oculus SHARED ${oculus_SRCS}) +set_target_properties(oculus PROPERTIES LIBRARY_OUTPUT_NAME oculus) + +# ============================================= +# to allow find_package() +# ============================================= +# +# The following is borrowed heavily from: +# https://github.com/RossHartley/invariant-ekf +# I am responsible for all mistakes +# +# the following case be used in an external project requiring oculus: +# ... +# find_package(oculus) +# include_directories(${oculus_INCLUDE_DIRS}) +# ... + +# NOTE: the following will support find_package for 1) local build (make) and 2) for installed files (make install) + +# 1- local build + +# Register the local build in case one doesn't use "make install" +export(PACKAGE oculus) + +# Create variable for the local build tree +# set_target_properties(oculus PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) +get_property( + oculus_include_dirs + DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + PROPERTY INCLUDE_DIRECTORIES +) +get_property( + oculus_library_dirs + TARGET oculus + PROPERTY LIBRARY_OUTPUT_DIRECTORY +) +get_property(oculus_libraries TARGET oculus PROPERTY LIBRARY_OUTPUT_NAME) + +message("oculus_include_dirs: " ${oculus_include_dirs}) +message("oculus_library_dirs: " ${oculus_library_dirs}) +message("oculus_libraries: " ${oculus_libraries}) + +# Configure config file for local build tree +configure_file( + cmake/oculusConfig.cmake.in + "${PROJECT_BINARY_DIR}/oculusConfig.cmake" + @ONLY +) + +message("PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR}) + +# # 2- installation build # + +# Change the include location for the case of an install location +set(oculus_include_dirs ${CMAKE_INSTALL_PREFIX}/include ${EIGEN_INCLUDE_DIR}) + +# We put the generated file for installation in a different repository (i.e., ./CMakeFiles/) +configure_file( + cmake/oculusConfig.cmake.in + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/oculusConfig.cmake" + @ONLY +) + +install( + FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/oculusConfig.cmake" + DESTINATION share/oculus/cmake + COMPONENT dev +) diff --git a/cmake/FindOculusSDK.cmake b/cmake/FindOculusSDK.cmake deleted file mode 100644 index c05372e..0000000 --- a/cmake/FindOculusSDK.cmake +++ /dev/null @@ -1,22 +0,0 @@ -# Copyright Olivier Parcollet 2010, Andrey Antipov 2013. -# -# This module looks for Blueprint Oculus SDK -# -# OCULUS_DIR can be provided as a hint. -# -# It sets up : OCULUS_SDK_ROOT -# -# - -find_package(PkgConfig) - -set(TRIAL_PATHS $ENV{OCULUS_DIR} ${OCULUS_DIR}) - -find_path( - OCULUS_SDK_ROOT - Oculus/Oculus.h - HINTS ${TRIAL_PATHS} - DOC "Location OCULUS SDK" -) - -find_package_handle_standard_args(OCULUS_SDK DEFAULT_MSG OCULUS_SDK_ROOT) diff --git a/cmake/IncludeProject.cmake b/cmake/IncludeProject.cmake new file mode 100644 index 0000000..66d13d2 --- /dev/null +++ b/cmake/IncludeProject.cmake @@ -0,0 +1,78 @@ +# This function is used to force a build on a dependant project at cmake +# configuration phase. + +# FOLLOWING ARGUMENTS are the CMAKE_ARGS of ExternalProject_Add +function(build_external_project target repository tag) + set(trigger_build_dir + ${CATKIN_DEVEL_PREFIX}/lib/${PROJECT_NAME}/force_${target} + ) + + # mktemp dir in build tree + file(MAKE_DIRECTORY ${trigger_build_dir} ${trigger_build_dir}/build) + + # generate false dependency project + set(CMAKE_LIST_CONTENT + " + cmake_minimum_required(VERSION 2.8) + + include(ExternalProject) + ExternalProject_add(${target} + PREFIX ${CATKIN_DEVEL_PREFIX}/lib/${PROJECT_NAME} + GIT_REPOSITORY ${repository} + GIT_TAG ${tag} + CMAKE_ARGS ${ARGN} + INSTALL_COMMAND \"\" + TIMEOUT 20) + add_custom_target(trigger_${target}) + add_dependencies(trigger_${target} ${target})" + ) + + file(WRITE ${trigger_build_dir}/CMakeLists.txt "${CMAKE_LIST_CONTENT}") + + execute_process( + COMMAND ${CMAKE_COMMAND} -DCMAKE_VERBOSE_MAKEFILE=ON .. + WORKING_DIRECTORY ${trigger_build_dir}/build + ) + execute_process( + COMMAND ${CMAKE_COMMAND} --build . + WORKING_DIRECTORY ${trigger_build_dir}/build + ) +endfunction() + +function(build_external_project_nobuild target repository tag) + set(trigger_build_dir + ${CATKIN_DEVEL_PREFIX}/lib/${PROJECT_NAME}/force_${target} + ) + + # mktemp dir in build tree + file(MAKE_DIRECTORY ${trigger_build_dir} ${trigger_build_dir}/build) + + # generate false dependency project + set(CMAKE_LIST_CONTENT + " + cmake_minimum_required(VERSION 2.8) + + include(ExternalProject) + ExternalProject_add(${target} + PREFIX ${CATKIN_DEVEL_PREFIX}/lib/${PROJECT_NAME} + GIT_REPOSITORY ${repository} + GIT_TAG ${tag} + CMAKE_ARGS ${ARGN} + BUILD_COMMAND \"\" + INSTALL_COMMAND \"\" + TIMEOUT 20) + add_custom_target(trigger_${target}) + add_dependencies(trigger_${target} ${target})" + ) + + file(WRITE ${trigger_build_dir}/CMakeLists.txt "${CMAKE_LIST_CONTENT}") + + execute_process( + COMMAND ${CMAKE_COMMAND} -DCMAKE_VERBOSE_MAKEFILE=ON .. + WORKING_DIRECTORY ${trigger_build_dir}/build + ) + execute_process( + COMMAND ${CMAKE_COMMAND} --build . + WORKING_DIRECTORY ${trigger_build_dir}/build + ) +endfunction() diff --git a/cmake/oculusConfig.cmake.in b/cmake/oculusConfig.cmake.in new file mode 100644 index 0000000..487afe9 --- /dev/null +++ b/cmake/oculusConfig.cmake.in @@ -0,0 +1,10 @@ +# - Config file for the oculus package +# It defines the following variables +# oculus_INCLUDE_DIRS - include directories for oculus +# oculus_LIBRARY_DIRS - directories for oculus library + +# Compute paths +get_filename_component(oculus_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) +set(oculus_INCLUDE_DIRS "@oculus_include_dirs@") +set(oculus_LIBRARY_DIRS "@oculus_library_dirs@") +set(oculus_LIBRARIES "@oculus_libraries@") From 64d6b22eb291fa06d36035c7a2c70a47883c7292 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 18:40:09 -0500 Subject: [PATCH 02/12] Added a cmake CI step --- .github/workflows/ci.yaml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 840f6b9..b295138 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -27,3 +27,19 @@ jobs: environment: CI_ROS_DISTRO: ${{ matrix.ros_distro }} UPSTREAM_WORKSPACE: liboculus.repos + + cmake: + name: Build with CMake + runs-on: ubuntu-24.04 + + strategy: + fail-fast: false + + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + submodules: recursive + + - name: Build Project + uses: threeal/cmake-action@v2.1.0 From a7bd9cc74f67ef6480aa1e23fe0cb1e84ceb36a6 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 18:46:01 -0500 Subject: [PATCH 03/12] Add "runs-on" for indusrtial_ci --- .github/workflows/ci.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b295138..db1a83d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,7 +10,7 @@ on: jobs: industrial-ci: name: Run Industrial CI - + runs-on: ubuntu-latest strategy: fail-fast: false matrix: @@ -32,9 +32,6 @@ jobs: name: Build with CMake runs-on: ubuntu-24.04 - strategy: - fail-fast: false - steps: - name: Checkout repository uses: actions/checkout@v5 From 45558e19f5ff2b6893910bd22c8f51ef2694ba37 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 18:47:37 -0500 Subject: [PATCH 04/12] Should be "env"? --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index db1a83d..f76ce07 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -24,7 +24,7 @@ jobs: - name: Run ROS Industrial CI uses: ros-industrial/industrial_ci@master - environment: + env: CI_ROS_DISTRO: ${{ matrix.ros_distro }} UPSTREAM_WORKSPACE: liboculus.repos From 6b426dfd05d95f022542cddf57c519f5adfcb674 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 18:53:41 -0500 Subject: [PATCH 05/12] Add step to apt-install dependencies --- .github/workflows/ci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f76ce07..4cae329 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,6 +33,12 @@ jobs: runs-on: ubuntu-24.04 steps: + - name: Install dependencesi with awalsh128/cache-apt-pkgs-action + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libboost-all-dev + version: 1.0 + - name: Checkout repository uses: actions/checkout@v5 with: From b187818bd4a5825a833388ee9088909213f4019c Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 18:57:38 -0500 Subject: [PATCH 06/12] Restructure matrix of ROS distros --- .github/workflows/ci.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4cae329..61a077f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,7 +14,10 @@ jobs: strategy: fail-fast: false matrix: - ros_distro: ["noetic", "kilted", "rolling"] + env: + - {UPSTREAM_WORKSPACE: liboculus.repos, ROS_DISTRO: noetic} + - {UPSTREAM_WORKSPACE: liboculus.repos, ROS_DISTRO: kilted} + - {UPSTREAM_WORKSPACE: liboculus.repos, ROS_DISTRO: rolling} steps: - name: Checkout repository @@ -24,9 +27,7 @@ jobs: - name: Run ROS Industrial CI uses: ros-industrial/industrial_ci@master - env: - CI_ROS_DISTRO: ${{ matrix.ros_distro }} - UPSTREAM_WORKSPACE: liboculus.repos + env: ${{matrix.env}} cmake: name: Build with CMake From a977296353a1419742f8957acada612b77063227 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 19:00:45 -0500 Subject: [PATCH 07/12] updated g3log_ros dep to dev/ros1_ros2_hybrid --- .github/workflows/ci.yaml | 19 ------------------- .github/workflows/ci_cmake.yaml | 28 ++++++++++++++++++++++++++++ liboculus.repos | 2 +- 3 files changed, 29 insertions(+), 20 deletions(-) create mode 100644 .github/workflows/ci_cmake.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 61a077f..af5d3c9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,22 +28,3 @@ jobs: - name: Run ROS Industrial CI uses: ros-industrial/industrial_ci@master env: ${{matrix.env}} - - cmake: - name: Build with CMake - runs-on: ubuntu-24.04 - - steps: - - name: Install dependencesi with awalsh128/cache-apt-pkgs-action - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libboost-all-dev - version: 1.0 - - - name: Checkout repository - uses: actions/checkout@v5 - with: - submodules: recursive - - - name: Build Project - uses: threeal/cmake-action@v2.1.0 diff --git a/.github/workflows/ci_cmake.yaml b/.github/workflows/ci_cmake.yaml new file mode 100644 index 0000000..f41f9c8 --- /dev/null +++ b/.github/workflows/ci_cmake.yaml @@ -0,0 +1,28 @@ +name: ROS Industrial CI + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + cmake: + name: Build with CMake + runs-on: ubuntu-24.04 + + steps: + - name: Install dependencesi with awalsh128/cache-apt-pkgs-action + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libboost-all-dev + version: 1.0 + + - name: Checkout repository + uses: actions/checkout@v5 + with: + submodules: recursive + + - name: Build Project + uses: threeal/cmake-action@v2.1.0 diff --git a/liboculus.repos b/liboculus.repos index 5e9bf27..1f6f19b 100644 --- a/liboculus.repos +++ b/liboculus.repos @@ -2,4 +2,4 @@ repositories: g3log_ros: type: git url: https://gitlab.com/apl-ocean-engineering/g3log_ros.git - version: main + version: dev/ros1_ros2_hybrid From 04fbe48be51dd9635399e2931e30ebca88d25145 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 19:00:45 -0500 Subject: [PATCH 08/12] updated g3log_ros dep --- .github/workflows/ci.yaml | 19 ------------------- .github/workflows/ci_cmake.yaml | 28 ++++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 .github/workflows/ci_cmake.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 61a077f..af5d3c9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -28,22 +28,3 @@ jobs: - name: Run ROS Industrial CI uses: ros-industrial/industrial_ci@master env: ${{matrix.env}} - - cmake: - name: Build with CMake - runs-on: ubuntu-24.04 - - steps: - - name: Install dependencesi with awalsh128/cache-apt-pkgs-action - uses: awalsh128/cache-apt-pkgs-action@latest - with: - packages: libboost-all-dev - version: 1.0 - - - name: Checkout repository - uses: actions/checkout@v5 - with: - submodules: recursive - - - name: Build Project - uses: threeal/cmake-action@v2.1.0 diff --git a/.github/workflows/ci_cmake.yaml b/.github/workflows/ci_cmake.yaml new file mode 100644 index 0000000..f41f9c8 --- /dev/null +++ b/.github/workflows/ci_cmake.yaml @@ -0,0 +1,28 @@ +name: ROS Industrial CI + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + cmake: + name: Build with CMake + runs-on: ubuntu-24.04 + + steps: + - name: Install dependencesi with awalsh128/cache-apt-pkgs-action + uses: awalsh128/cache-apt-pkgs-action@latest + with: + packages: libboost-all-dev + version: 1.0 + + - name: Checkout repository + uses: actions/checkout@v5 + with: + submodules: recursive + + - name: Build Project + uses: threeal/cmake-action@v2.1.0 From 32e9e559ac55e242a1a70248652e2189e35a21eb Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 19:02:57 -0500 Subject: [PATCH 09/12] Correct g3log_ros branch in .repos --- liboculus.repos | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/liboculus.repos b/liboculus.repos index 1f6f19b..5e9bf27 100644 --- a/liboculus.repos +++ b/liboculus.repos @@ -2,4 +2,4 @@ repositories: g3log_ros: type: git url: https://gitlab.com/apl-ocean-engineering/g3log_ros.git - version: dev/ros1_ros2_hybrid + version: main From a2b5f1c95ed9088b2688cefd472da6d7d4d60156 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 19:22:59 -0500 Subject: [PATCH 10/12] Basic README documentations on cmake builds --- README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c91287f..a1f86b4 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,9 @@ This library contains code for: - Raw streams of binary packets. - **Note:** This repo includes scaffold code for reading `.oculus` files saved from the Blueprint GUI, but that format is proprietary and undocumented. **We cannot parse `.oculus` files!!** -This package is designed to build in both ROS1 (catkin) and ROS2 (colcon) environments, however it contains no ROS-specific code and could be integrated into other non-ROS environments with some work. +This package is designed to build in both ROS1 (catkin) and ROS2 (colcon) environments, however it contains no ROS-specific code and could be integrated into other non-ROS environments with some work. + +It also contains the options to build a "bare" library with `cmake`. The library contains no special provisions for *saving* sonar data, but it's straightforward to write packets as a raw binary stream @@ -48,6 +50,18 @@ binary `oc_client` requires [CLI11](https://github.com/CLIUtils/CLI11). Internally, the ethernet interface uses [Boost::asio](https://www.boost.org/doc/libs/1_66_0/doc/html/boost_asio.html). +## Build with cmake + +This package can be built with the standard cmake process: + +``` +mkdir build && cd build +cmake .. +make +``` + +Note the `CMakelists.txt` attempts to auto-detect ROS. Cmake build should be done in a session where ROS has not been loaded. + --- ## oc_client binary From 473eacb446a591d00ecd0e0f40a921436c99e868 Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 19:43:00 -0500 Subject: [PATCH 11/12] Correct botched merge in CMakeLists.txt --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c2dc785..2fbb0c1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,7 @@ if(${ros_environment_FOUND}) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_compile_options(-std=c++17) + add_library(oculus SHARED ${oculus_SRCS}) target_link_libraries(oculus PUBLIC Boost::system g3log_ros::g3log) target_include_directories( @@ -44,8 +45,6 @@ if(${ros_environment_FOUND}) "$" ) - target_link_libraries(oculus PUBLIC Boost::system g3log_ros::g3log_ros) - install( TARGETS oculus EXPORT export_${PROJECT_NAME} From 2d0653b157b78c5c1e66063562ad4bbbfa9072fb Mon Sep 17 00:00:00 2001 From: Aaron Marburg Date: Thu, 2 Oct 2025 19:59:36 -0500 Subject: [PATCH 12/12] c++17 for both ROS1 and ROS2 --- CMakeLists.txt | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fbb0c1..a5809b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.8) project(liboculus) +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +add_compile_options(-std=c++17) + # == Code common to all builds ======================================= list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) @@ -29,10 +33,6 @@ if(${ros_environment_FOUND}) find_package(Boost REQUIRED COMPONENTS system) find_package(g3log_ros REQUIRED) - set(CMAKE_CXX_STANDARD 17) - set(CMAKE_CXX_STANDARD_REQUIRED ON) - add_compile_options(-std=c++17) - add_library(oculus SHARED ${oculus_SRCS}) target_link_libraries(oculus PUBLIC Boost::system g3log_ros::g3log) @@ -77,8 +77,6 @@ if(${ros_environment_FOUND}) LIBRARIES liboculus ) - add_compile_options(-std=c++14) - add_library(liboculus ${oculus_SRCS}) include_directories(liboculus include thirdparty ${catkin_INCLUDE_DIRS})