added flag to build without ROS as plain cmake project
This commit is contained in:
+32
-17
@@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
SET(TRACE TRUE)
|
SET(TRACE TRUE)
|
||||||
SET(HAVE_G2O TRUE)
|
SET(HAVE_G2O TRUE)
|
||||||
|
SET(USE_ROS FALSE) # Set False if you want to build this package without Catkin
|
||||||
|
SET(DEBUG_OUTPUT FALSE) # Only relevant if build without ROS
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
@@ -20,7 +22,12 @@ ENDIF()
|
|||||||
IF(HAVE_G2O)
|
IF(HAVE_G2O)
|
||||||
ADD_DEFINITIONS(-DUSE_BUNDLE_ADJUSTMENT)
|
ADD_DEFINITIONS(-DUSE_BUNDLE_ADJUSTMENT)
|
||||||
ENDIF()
|
ENDIF()
|
||||||
ADD_DEFINITIONS(-DSVO_USE_ROS)
|
IF(USE_ROS)
|
||||||
|
ADD_DEFINITIONS(-DSVO_USE_ROS)
|
||||||
|
ENDIF()
|
||||||
|
IF(DEBUG_OUTPUT)
|
||||||
|
ADD_DEFINITIONS(-DSVO_DEBUG_OUTPUT)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# Set build flags, set ARM_ARCHITECTURE environment variable on Odroid
|
# Set build flags, set ARM_ARCHITECTURE environment variable on Odroid
|
||||||
SET(CMAKE_CXX_FLAGS "-Wall -Werror -D_LINUX -D_REENTRANT -march=native -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas")
|
SET(CMAKE_CXX_FLAGS "-Wall -Werror -D_LINUX -D_REENTRANT -march=native -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unknown-pragmas")
|
||||||
@@ -35,9 +42,6 @@ ELSE()
|
|||||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
ENDIF()
|
ENDIF()
|
||||||
|
|
||||||
# Add catkin and required ROS packages
|
|
||||||
FIND_PACKAGE(catkin REQUIRED COMPONENTS roscpp roslib cmake_modules vikit_common vikit_ros)
|
|
||||||
|
|
||||||
# Add plain cmake packages
|
# Add plain cmake packages
|
||||||
FIND_PACKAGE(OpenCV REQUIRED)
|
FIND_PACKAGE(OpenCV REQUIRED)
|
||||||
FIND_PACKAGE(Eigen REQUIRED)
|
FIND_PACKAGE(Eigen REQUIRED)
|
||||||
@@ -45,13 +49,19 @@ FIND_PACKAGE(Sophus REQUIRED)
|
|||||||
FIND_PACKAGE(fast REQUIRED)
|
FIND_PACKAGE(fast REQUIRED)
|
||||||
FIND_PACKAGE(Boost REQUIRED COMPONENTS thread)
|
FIND_PACKAGE(Boost REQUIRED COMPONENTS thread)
|
||||||
|
|
||||||
# Describe catkin Project
|
IF(USE_ROS)
|
||||||
catkin_package(
|
FIND_PACKAGE(catkin REQUIRED COMPONENTS roscpp roslib cmake_modules vikit_common vikit_ros)
|
||||||
DEPENDS Eigen OpenCV Sophus Boost fast
|
catkin_package(
|
||||||
CATKIN_DEPENDS roscpp roslib vikit_common vikit_ros
|
DEPENDS Eigen OpenCV Sophus Boost fast
|
||||||
INCLUDE_DIRS include
|
CATKIN_DEPENDS roscpp roslib vikit_common vikit_ros
|
||||||
LIBRARIES svo
|
INCLUDE_DIRS include
|
||||||
)
|
LIBRARIES svo
|
||||||
|
)
|
||||||
|
ELSE()
|
||||||
|
FIND_PACKAGE(vikit_common REQUIRED)
|
||||||
|
SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
|
||||||
|
SET(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# Include dirs
|
# Include dirs
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
@@ -60,7 +70,6 @@ INCLUDE_DIRECTORIES(
|
|||||||
${OpenCV_INCLUDE_DIRS}
|
${OpenCV_INCLUDE_DIRS}
|
||||||
${Sophus_INCLUDE_DIRS}
|
${Sophus_INCLUDE_DIRS}
|
||||||
${Boost_INCLUDE_DIRS}
|
${Boost_INCLUDE_DIRS}
|
||||||
${catkin_INCLUDE_DIRS}
|
|
||||||
${fast_INCLUDE_DIRS}
|
${fast_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -69,10 +78,17 @@ LIST(APPEND LINK_LIBS
|
|||||||
${OpenCV_LIBRARIES}
|
${OpenCV_LIBRARIES}
|
||||||
${Sophus_LIBRARIES}
|
${Sophus_LIBRARIES}
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
${catkin_LIBRARIES}
|
|
||||||
${fast_LIBRARIES}
|
${fast_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
IF(USE_ROS)
|
||||||
|
INCLUDE_DIRECTORIES(${catkin_INCLUDE_DIRS})
|
||||||
|
LIST(APPEND LINK_LIBS ${catkin_LIBRARIES})
|
||||||
|
ELSE()
|
||||||
|
INCLUDE_DIRECTORIES(${vikit_common_INCLUDE_DIRS})
|
||||||
|
LIST(APPEND LINK_LIBS ${vikit_common_LIBRARIES})
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
# Set sourcefiles
|
# Set sourcefiles
|
||||||
LIST(APPEND SOURCEFILES
|
LIST(APPEND SOURCEFILES
|
||||||
src/frame_handler_mono.cpp
|
src/frame_handler_mono.cpp
|
||||||
@@ -94,12 +110,12 @@ LIST(APPEND SOURCEFILES
|
|||||||
IF(HAVE_G2O)
|
IF(HAVE_G2O)
|
||||||
FIND_PACKAGE(G2O REQUIRED)
|
FIND_PACKAGE(G2O REQUIRED)
|
||||||
INCLUDE_DIRECTORIES(
|
INCLUDE_DIRECTORIES(
|
||||||
${G2O_ROOT}/include
|
${G2O_INCLUDE_DIR}
|
||||||
/usr/include/suitesparse # for cholmod
|
/usr/include/suitesparse # for cholmod
|
||||||
)
|
)
|
||||||
LIST(APPEND LINK_LIBS
|
LIST(APPEND LINK_LIBS
|
||||||
g2o_core g2o_stuff g2o_solver_cholmod g2o_solver_csparse g2o_solver_dense
|
${G2O_CORE_LIBRARY} ${G2O_STUFF_LIBRARY} ${G2O_SOLVER_CHOLMOD} ${G2O_SOLVER_CSPARSE} ${G2O_SOLVER_DENSE}
|
||||||
g2o_solver_pcg g2o_types_sba cholmod cxsparse
|
${G2O_SOLVER_PCG} ${G2O_TYPES_SBA} cholmod cxsparse
|
||||||
)
|
)
|
||||||
LIST(APPEND SOURCEFILES src/bundle_adjustment.cpp)
|
LIST(APPEND SOURCEFILES src/bundle_adjustment.cpp)
|
||||||
ENDIF(HAVE_G2O)
|
ENDIF(HAVE_G2O)
|
||||||
@@ -108,7 +124,6 @@ ENDIF(HAVE_G2O)
|
|||||||
ADD_LIBRARY(svo SHARED ${SOURCEFILES})
|
ADD_LIBRARY(svo SHARED ${SOURCEFILES})
|
||||||
TARGET_LINK_LIBRARIES(svo ${LINK_LIBS})
|
TARGET_LINK_LIBRARIES(svo ${LINK_LIBS})
|
||||||
|
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# TESTS
|
# TESTS
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
###############################################################################
|
||||||
|
#
|
||||||
|
# CMake script for finding the Eigen library.
|
||||||
|
#
|
||||||
|
# http://eigen.tuxfamily.org/index.php?title=Main_Page
|
||||||
|
#
|
||||||
|
# Copyright (c) 2006, 2007 Montel Laurent, <[email protected]>
|
||||||
|
# Copyright (c) 2008, 2009 Gael Guennebaud, <[email protected]>
|
||||||
|
# Copyright (c) 2009 Benoit Jacob <[email protected]>
|
||||||
|
# Redistribution and use is allowed according to the terms of the 2-clause BSD
|
||||||
|
# license.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Input variables:
|
||||||
|
#
|
||||||
|
# - Eigen_ROOT_DIR (optional): When specified, header files and libraries
|
||||||
|
# will be searched for in `${Eigen_ROOT_DIR}/include` and
|
||||||
|
# `${Eigen_ROOT_DIR}/libs` respectively, and the default CMake search order
|
||||||
|
# will be ignored. When unspecified, the default CMake search order is used.
|
||||||
|
# This variable can be specified either as a CMake or environment variable.
|
||||||
|
# If both are set, preference is given to the CMake variable.
|
||||||
|
# Use this variable for finding packages installed in a nonstandard location,
|
||||||
|
# or for enforcing that one of multiple package installations is picked up.
|
||||||
|
#
|
||||||
|
# Cache variables (not intended to be used in CMakeLists.txt files)
|
||||||
|
#
|
||||||
|
# - Eigen_INCLUDE_DIR: Absolute path to package headers.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Output variables:
|
||||||
|
#
|
||||||
|
# - Eigen_FOUND: Boolean that indicates if the package was found
|
||||||
|
# - Eigen_INCLUDE_DIRS: Paths to the necessary header files
|
||||||
|
# - Eigen_VERSION: Version of Eigen library found
|
||||||
|
# - Eigen_DEFINITIONS: Definitions to be passed on behalf of eigen
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Example usage:
|
||||||
|
#
|
||||||
|
# # Passing the version means Eigen_FOUND will only be TRUE if a
|
||||||
|
# # version >= the provided version is found.
|
||||||
|
# find_package(Eigen 3.1.2)
|
||||||
|
# if(NOT Eigen_FOUND)
|
||||||
|
# # Error handling
|
||||||
|
# endif()
|
||||||
|
# ...
|
||||||
|
# add_definitions(${Eigen_DEFINITIONS})
|
||||||
|
# ...
|
||||||
|
# include_directories(${Eigen_INCLUDE_DIRS} ...)
|
||||||
|
#
|
||||||
|
###############################################################################
|
||||||
|
|
||||||
|
find_package(PkgConfig)
|
||||||
|
pkg_check_modules(PC_EIGEN eigen3)
|
||||||
|
set(EIGEN_DEFINITIONS ${PC_EIGEN_CFLAGS_OTHER})
|
||||||
|
|
||||||
|
|
||||||
|
find_path(EIGEN_INCLUDE_DIR Eigen/Core
|
||||||
|
HINTS ${PC_EIGEN_INCLUDEDIR} ${PC_EIGEN_INCLUDE_DIRS}
|
||||||
|
"${Eigen_ROOT_DIR}" "$ENV{EIGEN_ROOT_DIR}"
|
||||||
|
"${EIGEN_ROOT}" "$ENV{EIGEN_ROOT}" # Backwards Compatibility
|
||||||
|
PATHS "$ENV{PROGRAMFILES}/Eigen" "$ENV{PROGRAMW6432}/Eigen"
|
||||||
|
"$ENV{PROGRAMFILES}/Eigen 3.0.0" "$ENV{PROGRAMW6432}/Eigen 3.0.0"
|
||||||
|
PATH_SUFFIXES eigen3 include/eigen3 include)
|
||||||
|
|
||||||
|
set(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR})
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Eigen DEFAULT_MSG EIGEN_INCLUDE_DIR)
|
||||||
|
|
||||||
|
mark_as_advanced(EIGEN_INCLUDE_DIR)
|
||||||
|
|
||||||
|
if(EIGEN_FOUND)
|
||||||
|
message(STATUS "Eigen found (include: ${EIGEN_INCLUDE_DIRS})")
|
||||||
|
endif(EIGEN_FOUND)
|
||||||
|
|
||||||
|
|
||||||
|
set(Eigen_INCLUDE_DIRS ${EIGEN_INCLUDE_DIRS})
|
||||||
|
set(Eigen_FOUND ${EIGEN_FOUND})
|
||||||
|
set(Eigen_VERSION ${EIGEN_VERSION})
|
||||||
|
set(Eigen_DEFINITIONS ${EIGEN_DEFINITIONS})
|
||||||
Reference in New Issue
Block a user