Skip to content

Commit

Permalink
Merge pull request #202 from SPARK/feature/catkin_build
Browse files Browse the repository at this point in the history
feature/CMake cleanup + catkin build
  • Loading branch information
ToniRV authored and GitHub Enterprise committed Sep 18, 2019
2 parents 4e6a847 + 5d786fe commit 4925c4e
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 45 deletions.
23 changes: 3 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ endif()
message(STATUS "===============================================================")
message(STATUS "==================== Dependencies ============================")

### Include the boost directory
### System Dependencies
find_package(Boost REQUIRED COMPONENTS filesystem serialization regex timer date_time thread)
if(NOT TARGET Boost::boost)
add_library(Boost::boost INTERFACE IMPORTED)
Expand All @@ -21,31 +21,13 @@ if(NOT TARGET Boost::boost)
INTERFACE_INCLUDE_DIRECTORIES "${Boost_INCLUDE_DIRS}")
endif()

### Find the GTSAM package
find_package(GTSAM REQUIRED)
if(GTSAM_FOUND)
message(STATUS "FOUND GTSAM! ${OpenCV_INCLUDE_DIRS}")
endif(GTSAM_FOUND)

### Find the OpenGV package
find_package(opengv REQUIRED)
if(opengv_FOUND)
message(STATUS "FOUND OpenGV!")
endif(opengv_FOUND)

### Find opencv
find_package(OpenCV 3.3.1 REQUIRED)
if(OpenCV_FOUND)
message(STATUS "FOUND OpenCV!")
endif(OpenCV_FOUND)

### External Dependencies
include(ExternalProject)

### Include the gflags directory
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/gflags.cmake)

### Include the glog directory
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/glog.cmake)

### Compile the code
Expand Down Expand Up @@ -95,14 +77,15 @@ target_link_libraries(SparkVio
opengv
PUBLIC
Boost::boost
${OpenCV_LIBS}
${OpenCV_LIBRARIES} # TODO: modernize
gflags::gflags
glog::glog
gtsam
gtsam_unstable
)
target_include_directories(SparkVio
PUBLIC
${OpenCV_INCLUDE_DIRS}
${GTSAM_INCLUDE_DIR}
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:src>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ cd SparkVIO

We provide a ROS wrapper of SparkVIO that you can find at: https://github.mit.edu/SPARK/spark_vio_ros.

Alternatively, you may be interested in using SparkVIO as a library by depending on it via catkin: https://github.mit.edu/SPARK/spark_vio_catkin
This library can be cloned into a catkin workspace and built alongside the ROS wrapper.

# 3. Parameters
SparkVIO accepts two sources of parameters:
Expand Down
14 changes: 4 additions & 10 deletions cmake/gflags.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
if (NOT __GFLAGS_INCLUDED) # guard against multiple includes
set(__GFLAGS_INCLUDED TRUE)

# use the system-wide gflags if present
set(GFLAGS_PREFER_EXPORTED_GFLAGS_CMAKE_CONFIGURATION TRUE)
#find_package(Gflags QUIET)
# Try the system-wide gflags first.
# Note: System-wide gflags causes linker issues on current Ubuntu LTS
#find_package(gflags QUIET)
if (gflags_FOUND)
message(STATUS "FOUND gflags!")
#message(STATUS "GFLAGS libs: ${GFLAGS_LIBRARIES}")
#message(STATUS "GFLAGS includes: ${GFLAGS_INCLUDE_DIR}")
else()
message(STATUS "NOT FOUND gflags! Will be downloaded from github.")

Expand All @@ -26,12 +24,11 @@ if (NOT __GFLAGS_INCLUDED) # guard against multiple includes
endif()

set(GFLAGS_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GFLAGS_EXTRA_COMPILER_FLAGS}")
set(GFLAGS_C_FLAGS "${CMAKE_C_FLAGS} ${GFLAGS_EXTRA_COMPILER_FLAGS}")

ExternalProject_Add(gflags
PREFIX ${gflags_PREFIX}
GIT_REPOSITORY "https://github.com/gflags/gflags.git"
GIT_TAG "v2.1.2"
GIT_TAG "v2.2.2"
UPDATE_COMMAND ""
INSTALL_DIR ${gflags_INSTALL}
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
Expand All @@ -40,10 +37,7 @@ if (NOT __GFLAGS_INCLUDED) # guard against multiple includes
-DGFLAGS_NAMESPACE=google
-DBUILD_PACKAGING=OFF
-DBUILD_TESTING=OFF
-DBUILD_NC_TESTS=OFF
-DBUILD_CONFIG_TESTS=OFF
-DINSTALL_HEADERS=ON
-DCMAKE_C_FLAGS=${GFLAGS_C_FLAGS}
-DCMAKE_CXX_FLAGS=${GFLAGS_CXX_FLAGS}
LOG_DOWNLOAD 1
LOG_INSTALL 1
Expand Down
18 changes: 10 additions & 8 deletions cmake/glog.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ include("cmake/gflags.cmake")
if (NOT __GLOG_INCLUDED)
set(__GLOG_INCLUDED TRUE)

# try the system-wide glog first
# Try the system-wide glog first.
# Note: Glog < 0.3.5 doesn't include CMake support, and system-wide glog causes linker issues on current Ubuntu LTS
#find_package(glog QUIET)
if (GLOG_FOUND)
if (glog_FOUND)
message(STATUS "FOUND glog!")
message(STATUS "GLOG libs: ${GLOG_LIBRARIES}")
message(STATUS "GLOG includes: ${GLOG_INCLUDE_DIR}")
else()
# Fetch and build glog from github
message(STATUS "NOT FOUND glog! Will be downloaded from github.")
Expand Down Expand Up @@ -37,13 +36,16 @@ if (NOT __GLOG_INCLUDED)
DEPENDS ${GLOG_DEPENDS}
PREFIX ${GLOG_PREFIX}
GIT_REPOSITORY "https://github.com/google/glog"
GIT_TAG "v0.3.4"
GIT_TAG "v0.4.0"
UPDATE_COMMAND ""
INSTALL_DIR ${GLOG_INSTALL}
PATCH_COMMAND autoreconf -i ${GLOG_PREFIX}/src/glog
CONFIGURE_COMMAND env "CFLAGS=${GLOG_C_FLAGS}" "CXXFLAGS=${GLOG_CXX_FLAGS}" ${GLOG_PREFIX}/src/glog/configure --prefix=${GLOG_INSTALL} --enable-shared=no --enable-static=yes --with-gflags=${gflags_INSTALL}
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${GLOG_INSTALL}
-DBUILD_SHARED_LIBS=OFF
-DBUILD_TESTING=OFF
-DCMAKE_C_FLAGS=${GLOG_C_FLAGS}
-DCMAKE_CXX_FLAGS=${GLOG_CXX_FLAGS}
LOG_DOWNLOAD 1
LOG_CONFIGURE 1
LOG_INSTALL 1
)

Expand Down
16 changes: 16 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<package format="2">
<name>SparkVio</name>
<version>0.0.1</version>
<description>SparkVio</description>

<maintainer email="[email protected]"></maintainer>
<license>BSD</license>

<buildtool_depend>cmake</buildtool_depend>
<export>
<!-- Specify that this is not really a catkin package-->
<build_type>cmake</build_type>
</export>
</package>

5 changes: 0 additions & 5 deletions src/UtilsOpenCV.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
#include <gtsam/geometry/Pose3.h>
#include <gtsam/navigation/ImuBias.h>

#include <opencv2/features2d/features2d.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/opencv.hpp>

namespace VIO {

/* -------------------------------------------------------------------------- */
Expand Down
2 changes: 1 addition & 1 deletion src/UtilsOpenCV.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include <Eigen/Core>

#include <opencv2/core/core.hpp>
#include <opencv2/opencv.hpp>

#include <gtsam/inference/Symbol.h>
#include <gtsam/geometry/Unit3.h>
Expand Down

0 comments on commit 4925c4e

Please sign in to comment.