Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: updated to build in ros #31

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,24 @@ 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)
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 ()
Expand Down
7 changes: 7 additions & 0 deletions cmake/xmotionConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ 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)

if (DEFINED ENV{ROS_DISTRO})
find_dependency(spdlog REQUIRED)
endif ()

# Add the targets file
include("${CMAKE_CURRENT_LIST_DIR}/xmotionTargets.cmake")
4 changes: 1 addition & 3 deletions src/common/math_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#include <fstream>
#include <sstream>
#include <iostream>
#include <filesystem>

#include <eigen3/Eigen/Core>
#include <boost/filesystem.hpp>

#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h"
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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);
Expand Down