From 440af503dbadcaf2d029e6703bca5dc1a9a14eed Mon Sep 17 00:00:00 2001 From: Henry Moore Date: Fri, 31 May 2024 16:35:33 -0600 Subject: [PATCH 1/2] enable building without ROS even if you have ROS --- ov_msckf/CMakeLists.txt | 9 ++++++--- ov_msckf/cmake/ROS1.cmake | 1 - 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ov_msckf/CMakeLists.txt b/ov_msckf/CMakeLists.txt index d62570fe0..8bfceca72 100644 --- a/ov_msckf/CMakeLists.txt +++ b/ov_msckf/CMakeLists.txt @@ -33,19 +33,22 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fsee -fomit-frame-pointer -fno-sign # Enable debug flags (use if you want to debug in gdb) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -Wuninitialized -fno-omit-frame-pointer") + +option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) + # Find our ROS version! # NOTE: Default to using the ROS1 package if both are in our enviroment # NOTE: https://github.com/romainreignier/share_ros1_ros2_lib_demo find_package(catkin QUIET COMPONENTS roscpp) find_package(ament_cmake QUIET) -if (catkin_FOUND) +if (catkin_FOUND AND ENABLE_ROS) message(STATUS "ROS *1* version found, building ROS1.cmake") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake) -elseif (ament_cmake_FOUND) +elseif (ament_cmake_FOUND AND ENABLE_ROS) message(STATUS "ROS *2* version found, building ROS2.cmake") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS2.cmake) else () - message(STATUS "No ROS versions found, building ROS1.cmake") + message(STATUS "No ROS versions found or building with ROS disabled, building ROS1.cmake without ROS") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake) endif () diff --git a/ov_msckf/cmake/ROS1.cmake b/ov_msckf/cmake/ROS1.cmake index 5f3a9a494..2ea4292cf 100644 --- a/ov_msckf/cmake/ROS1.cmake +++ b/ov_msckf/cmake/ROS1.cmake @@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.3) find_package(catkin QUIET COMPONENTS roscpp rosbag tf std_msgs geometry_msgs sensor_msgs nav_msgs visualization_msgs image_transport cv_bridge ov_core ov_init) # Describe ROS project -option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) if (catkin_FOUND AND ENABLE_ROS) add_definitions(-DROS_AVAILABLE=1) catkin_package( From a949b8d44c82287e1bdf715cb2c44697b71a270a Mon Sep 17 00:00:00 2001 From: Patrick Geneva Date: Sat, 14 Dec 2024 22:28:30 -0800 Subject: [PATCH 2/2] extend to all other packages --- ov_core/CMakeLists.txt | 9 ++++++--- ov_core/cmake/ROS1.cmake | 1 - ov_eval/CMakeLists.txt | 9 ++++++--- ov_eval/cmake/ROS1.cmake | 1 - ov_init/CMakeLists.txt | 9 ++++++--- ov_init/cmake/ROS1.cmake | 1 - ov_msckf/CMakeLists.txt | 6 +++--- 7 files changed, 21 insertions(+), 15 deletions(-) diff --git a/ov_core/CMakeLists.txt b/ov_core/CMakeLists.txt index a4a1bc23d..ecc1cc82b 100644 --- a/ov_core/CMakeLists.txt +++ b/ov_core/CMakeLists.txt @@ -11,6 +11,9 @@ endif () find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time) message(STATUS "OPENCV: " ${OpenCV_VERSION} " | BOOST: " ${Boost_VERSION}) +# By default we build with ROS, but you can disable this and just build as a library +option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) + # If we will compile with aruco support option(ENABLE_ARUCO_TAGS "Enable or disable aruco tag (disable if no contrib modules)" ON) if (NOT ENABLE_ARUCO_TAGS) @@ -51,14 +54,14 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -Wuninitialized -Wmaybe-uninit # NOTE: https://github.com/romainreignier/share_ros1_ros2_lib_demo find_package(catkin QUIET COMPONENTS roscpp) find_package(ament_cmake QUIET) -if (catkin_FOUND) +if (catkin_FOUND AND ENABLE_ROS) message(STATUS "ROS *1* version found, building ROS1.cmake") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake) -elseif (ament_cmake_FOUND) +elseif (ament_cmake_FOUND AND ENABLE_ROS) message(STATUS "ROS *2* version found, building ROS2.cmake") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS2.cmake) else () - message(STATUS "No ROS versions found, building ROS1.cmake") + message(STATUS "No ROS versions found or building with ROS disabled, building ROS1.cmake without ROS") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake) endif () diff --git a/ov_core/cmake/ROS1.cmake b/ov_core/cmake/ROS1.cmake index 6db18fbeb..93d016424 100644 --- a/ov_core/cmake/ROS1.cmake +++ b/ov_core/cmake/ROS1.cmake @@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.3) find_package(catkin QUIET COMPONENTS roscpp rosbag sensor_msgs cv_bridge) # Describe ROS project -option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) if (catkin_FOUND AND ENABLE_ROS) add_definitions(-DROS_AVAILABLE=1) catkin_package( diff --git a/ov_eval/CMakeLists.txt b/ov_eval/CMakeLists.txt index 27abb8920..f60c1959e 100644 --- a/ov_eval/CMakeLists.txt +++ b/ov_eval/CMakeLists.txt @@ -5,6 +5,9 @@ project(ov_eval) find_package(Eigen3 REQUIRED) find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time) +# By default we build with ROS, but you can disable this and just build as a library +option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) + # check if we have our python libs files (will search for python3 then python2 installs) # sudo apt-get install python-matplotlib python-numpy python-dev # https://cmake.org/cmake/help/v3.10/module/FindPythonLibs.html @@ -36,14 +39,14 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -Wuninitialized -Wmaybe-uninit # NOTE: https://github.com/romainreignier/share_ros1_ros2_lib_demo find_package(catkin QUIET COMPONENTS roscpp) find_package(ament_cmake QUIET) -if (catkin_FOUND) +if (catkin_FOUND AND ENABLE_ROS) message(STATUS "ROS *1* version found, building ROS1.cmake") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake) -elseif (ament_cmake_FOUND) +elseif (ament_cmake_FOUND AND ENABLE_ROS) message(STATUS "ROS *2* version found, building ROS2.cmake") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS2.cmake) else () - message(STATUS "No ROS versions found, building ROS1.cmake") + message(STATUS "No ROS versions found or building with ROS disabled, building ROS1.cmake without ROS") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake) endif () diff --git a/ov_eval/cmake/ROS1.cmake b/ov_eval/cmake/ROS1.cmake index 12ed33bf9..9d10e6f57 100644 --- a/ov_eval/cmake/ROS1.cmake +++ b/ov_eval/cmake/ROS1.cmake @@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.3) find_package(catkin QUIET COMPONENTS roscpp rospy geometry_msgs nav_msgs sensor_msgs ov_core) # Describe ROS project -option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) if (catkin_FOUND AND ENABLE_ROS) add_definitions(-DROS_AVAILABLE=1) catkin_package( diff --git a/ov_init/CMakeLists.txt b/ov_init/CMakeLists.txt index 7df06547a..0e7c58ade 100644 --- a/ov_init/CMakeLists.txt +++ b/ov_init/CMakeLists.txt @@ -13,6 +13,9 @@ find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time) find_package(Ceres REQUIRED) message(STATUS "OPENCV: " ${OpenCV_VERSION} " | BOOST: " ${Boost_VERSION} " | CERES: " ${Ceres_VERSION}) +# By default we build with ROS, but you can disable this and just build as a library +option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) + # check if we have our python libs files (will search for python3 then python2 installs) # sudo apt-get install python-matplotlib python-numpy python-dev # https://cmake.org/cmake/help/v3.10/module/FindPythonLibs.html @@ -44,14 +47,14 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -Wuninitialized -Wmaybe-uninit # NOTE: https://github.com/romainreignier/share_ros1_ros2_lib_demo find_package(catkin QUIET COMPONENTS roscpp) find_package(ament_cmake QUIET) -if (catkin_FOUND) +if (catkin_FOUND AND ENABLE_ROS) message(STATUS "ROS *1* version found, building ROS1.cmake") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake) -elseif (ament_cmake_FOUND) +elseif (ament_cmake_FOUND AND ENABLE_ROS) message(STATUS "ROS *2* version found, building ROS2.cmake") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS2.cmake) else () - message(STATUS "No ROS versions found, building ROS1.cmake") + message(STATUS "No ROS versions found or building with ROS disabled, building ROS1.cmake without ROS") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/ROS1.cmake) endif () diff --git a/ov_init/cmake/ROS1.cmake b/ov_init/cmake/ROS1.cmake index f058e5ef6..c83be64c3 100644 --- a/ov_init/cmake/ROS1.cmake +++ b/ov_init/cmake/ROS1.cmake @@ -4,7 +4,6 @@ cmake_minimum_required(VERSION 3.3) find_package(catkin QUIET COMPONENTS roscpp ov_core) # Describe ROS project -option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) if (catkin_FOUND AND ENABLE_ROS) add_definitions(-DROS_AVAILABLE=1) catkin_package( diff --git a/ov_msckf/CMakeLists.txt b/ov_msckf/CMakeLists.txt index 8bfceca72..5f8a2eb63 100644 --- a/ov_msckf/CMakeLists.txt +++ b/ov_msckf/CMakeLists.txt @@ -12,6 +12,9 @@ find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time) find_package(Ceres REQUIRED) message(STATUS "OPENCV: " ${OpenCV_VERSION} " | BOOST: " ${Boost_VERSION} " | CERES: " ${Ceres_VERSION}) +# By default we build with ROS, but you can disable this and just build as a library +option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) + # If we will compile with aruco support option(ENABLE_ARUCO_TAGS "Enable or disable aruco tag (disable if no contrib modules)" ON) if (NOT ENABLE_ARUCO_TAGS) @@ -33,9 +36,6 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fsee -fomit-frame-pointer -fno-sign # Enable debug flags (use if you want to debug in gdb) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -Wuninitialized -fno-omit-frame-pointer") - -option(ENABLE_ROS "Enable or disable building with ROS (if it is found)" ON) - # Find our ROS version! # NOTE: Default to using the ROS1 package if both are in our enviroment # NOTE: https://github.com/romainreignier/share_ros1_ros2_lib_demo