From 146d580f020798e3b31e034176b86d19e43ca442 Mon Sep 17 00:00:00 2001 From: Ruixiang Du Date: Wed, 12 Feb 2025 22:09:03 +0800 Subject: [PATCH 1/3] cmake: updated to build in ros --- CMakeLists.txt | 12 ++++++++---- src/common/math_utils/CMakeLists.txt | 4 +--- .../include/math_utils/details/eigen_io_impl.hpp | 14 +++++++------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46e38451..a114ffb7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ if (CCACHE_PROGRAM) endif () ## Project Options -option(BUILD_TESTING "Build tests" ON) +option(BUILD_TESTING "Build tests" OFF) option(STATIC_CHECK "Enable static check" OFF) option(ENABLE_LOGGING "Enable logging" ON) @@ -26,12 +26,16 @@ option(ENABLE_VISUALIZATION "Enable visualization targets" ON) option(USE_SYS_SPDLOG "Use system spdlog" OFF) option(XMOTION_DEV_MODE "Development mode forces building tests" OFF) -if (DEFINED ENV{ROS_DISTRO} AND "$ENV{ROS_DISTRO}" STREQUAL "humble") - message(STATUS "ROS_DISTRO is $ENV{ROS_DISTRO}, use system spdlog") +if (DEFINED ENV{ROS_DISTRO}) + set(BUILD_WITH_ROS ON) +endif () + +if (BUILD_WITH_ROS) + message(STATUS "Use spdlog from the system installation") set(USE_SYS_SPDLOG ON) endif () -if (BUILD_AS_MODULE OR (NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64"))) +if (BUILD_WITH_ROS OR BUILD_AS_MODULE OR (NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64"))) message(STATUS "Visualization targets are not build on non-x86_64 or when built as module") set(ENABLE_VISUALIZATION OFF) else () diff --git a/src/common/math_utils/CMakeLists.txt b/src/common/math_utils/CMakeLists.txt index 8aca3414..219035ad 100644 --- a/src/common/math_utils/CMakeLists.txt +++ b/src/common/math_utils/CMakeLists.txt @@ -1,7 +1,5 @@ -find_package(Boost REQUIRED filesystem) - add_library(math_utils STATIC src/matrix.cpp) -target_link_libraries(math_utils PUBLIC logging stb Boost::filesystem) +target_link_libraries(math_utils PUBLIC logging stb) target_include_directories(math_utils PUBLIC $ $) diff --git a/src/common/math_utils/include/math_utils/details/eigen_io_impl.hpp b/src/common/math_utils/include/math_utils/details/eigen_io_impl.hpp index b05aaae8..535510df 100644 --- a/src/common/math_utils/include/math_utils/details/eigen_io_impl.hpp +++ b/src/common/math_utils/include/math_utils/details/eigen_io_impl.hpp @@ -18,9 +18,9 @@ #include #include #include +#include #include -#include #define STB_IMAGE_IMPLEMENTATION #include "stb_image.h" @@ -79,8 +79,8 @@ bool EigenIO::WriteToFile( bool overwrite) { // check directory existence: create the directory if non-existent if (directory.empty()) return false; - if (!boost::filesystem::exists(directory)) { - if (!boost::filesystem::create_directories(directory)) { + if (!std::filesystem::exists(directory)) { + if (!std::filesystem::create_directories(directory)) { XLOG_ERROR("directory is not found and failed to be created - {}", directory); return false; @@ -89,7 +89,7 @@ bool EigenIO::WriteToFile( // get full file name and check file existence filename = directory + "/" + filename; - if (boost::filesystem::exists(filename)) { + if (std::filesystem::exists(filename)) { if (!overwrite) { // File exists, but overwriting is not allowed. Abort. XLOG_ERROR("file already exists - {}", filename); @@ -167,8 +167,8 @@ bool EigenIO::WriteToImage( bool overwrite) { // check directory existence: create the directory if non-existent if (directory.empty()) return false; - if (!boost::filesystem::exists(directory)) { - if (!boost::filesystem::create_directories(directory)) { + if (!std::filesystem::exists(directory)) { + if (!std::filesystem::create_directories(directory)) { XLOG_ERROR("directory is not found and failed to be created - {}", directory); return false; @@ -177,7 +177,7 @@ bool EigenIO::WriteToImage( // get full file name and check file existence filename = directory + "/" + filename; - if (boost::filesystem::exists(filename)) { + if (std::filesystem::exists(filename)) { if (!overwrite) { // File exists, but overwriting is not allowed. Abort. XLOG_ERROR("file already exists - {}", filename); From cd7727df47acefaacfe2dfd08e23290e073cc6a1 Mon Sep 17 00:00:00 2001 From: Ruixiang Du Date: Wed, 12 Feb 2025 22:32:17 +0800 Subject: [PATCH 2/3] cmake: updated dependencies to find for xmotion --- cmake/xmotionConfig.cmake.in | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cmake/xmotionConfig.cmake.in b/cmake/xmotionConfig.cmake.in index f8b6a70b..bb7219d5 100644 --- a/cmake/xmotionConfig.cmake.in +++ b/cmake/xmotionConfig.cmake.in @@ -7,6 +7,14 @@ include(CMakeFindDependencyMacro) find_dependency(Threads REQUIRED) # Any extra setup +find_package(PkgConfig REQUIRED) +pkg_check_modules(Libevent REQUIRED IMPORTED_TARGET libevent) +find_dependency(graph REQUIRED) +find_dependency(yoga REQUIRED) + +if (DEFINED ENV{ROS_DISTRO}) + find_dependency(spdlog REQUIRED) +endif () # Add the targets file include("${CMAKE_CURRENT_LIST_DIR}/xmotionTargets.cmake") \ No newline at end of file From 2e7b738182f04ff8df143e42f21a6bbfae6b5abc Mon Sep 17 00:00:00 2001 From: Ruixiang Du Date: Wed, 12 Feb 2025 22:40:50 +0800 Subject: [PATCH 3/3] cmake: removed finding yoga as quickviz should not be built with ros --- cmake/xmotionConfig.cmake.in | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/xmotionConfig.cmake.in b/cmake/xmotionConfig.cmake.in index bb7219d5..af0b3ff5 100644 --- a/cmake/xmotionConfig.cmake.in +++ b/cmake/xmotionConfig.cmake.in @@ -10,7 +10,6 @@ find_dependency(Threads REQUIRED) find_package(PkgConfig REQUIRED) pkg_check_modules(Libevent REQUIRED IMPORTED_TARGET libevent) find_dependency(graph REQUIRED) -find_dependency(yoga REQUIRED) if (DEFINED ENV{ROS_DISTRO}) find_dependency(spdlog REQUIRED)