Skip to content

Commit

Permalink
Use CMake >=3.1 ExternalProjects for: assimp, octomap, and Eigen (#575)
Browse files Browse the repository at this point in the history
* Remove embedded copy of assimp, and use CMake to download it if needed
* fix EP assimp build (still DLLs are in the wrong output dir) cc: #359
* fix EP assimp link
* correctly removed Eigen3 embedded dir
* EP out-of-source dirs
* done porting eigen & assimp as EP
* Remove embedded version of octomap cc: #574
* Add simpler build instructions to README
* fix build of EP in GNU/Linux
* Debian pkg: update after removing octomap sources
  • Loading branch information
jlblancoc committed Aug 15, 2017
1 parent 61117f8 commit 4d7c9bb
Show file tree
Hide file tree
Showing 770 changed files with 216 additions and 270,557 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ SOURCE_DATE_EPOCH

# Vim-related files
Session.vim
otherlibs/eigen3

# common results directories
graphslam_results/

1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ include(cmakemodules/script_videre_svs.cmake REQUIRED) # Support for Videre Des
include(cmakemodules/script_ftdi.cmake REQUIRED) # Check for the FTDI headers (Linux only, in win32 we use built-in header & dynamic DLL load):
include(cmakemodules/script_inotify.cmake REQUIRED) # Check for the sys/inotify headers (Linux only, in win32 we use the equivalent API for file system monitoring):
include(cmakemodules/script_gl_glut.cmake REQUIRED) # Check for the GL,GLUT libraries
include(cmakemodules/script_octomap.cmake REQUIRED) # Check for the octomap library
include(cmakemodules/script_opencv.cmake REQUIRED) # Check for the OpenCV libraries (via pkg-config, CMake, with different options)
include(cmakemodules/script_openni2.cmake REQUIRED) # Check for the OpenNI2 library
include(cmakemodules/script_ffmpeg.cmake REQUIRED) # Check for ffmpeg C libraries: libavcodec, libavutil, libavformat, libswscale
Expand Down
55 changes: 31 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The MRPT project
The MRPT project
====================================================
[![Travis](https://travis-ci.org/MRPT/mrpt.png?branch=master)](https://travis-ci.org/MRPT/mrpt)
[![Shippable](http://150.214.150.101:50000/projects/5940153f75d24b06002327b7/badge?branch=master)](http://150.214.150.101:50001/github/MRPT/mrpt)
Expand All @@ -10,51 +10,58 @@ The MRPT project
<img align="right" src="https://mrpt.github.io/imgs/mrpt-videos-mix2.gif">

Mobile Robot Programming Toolkit (MRPT) provides C++ libraries aimed at researchers
in mobile robotics and computer vision. Libraries include [SLAM solutions](http://www.mrpt.org/List_of_SLAM_algorithms), [3D(6D) geometry](http://www.mrpt.org/tutorials/programming/maths-and-geometry/2d_3d_geometry/), [SE(2)/SE(3) Lie groups](http://ingmec.ual.es/~jlblanco/papers/jlblanco2010geometry3D_techrep.pdf),
[probability density functions (pdfs)](http://reference.mrpt.org/stable/classmrpt_1_1utils_1_1_c_probability_density_function.html) over points, landmarks, poses and maps,
Bayesian inference ([Kalman filters](http://www.mrpt.org/Kalman_Filters), [particle filters](http://www.mrpt.org/tutorials/programming/statistics-and-bayes-filtering/particle_filters/)), [image processing](http://www.mrpt.org/tutorials/programming/images-image-processing-camera-models/), [obstacle avoidance](http://www.mrpt.org/Obstacle_avoidance), [etc](http://reference.mrpt.org/devel/modules.html).
MRPT also provides GUI apps for [Stereo camera calibration](http://www.mrpt.org/list-of-mrpt-apps/application-kinect-stereo-calib/), [dataset inspection](http://www.mrpt.org/list-of-mrpt-apps/rawlogviewer/),
in mobile robotics and computer vision. Libraries include [SLAM solutions](http://www.mrpt.org/List_of_SLAM_algorithms), [3D(6D) geometry](http://www.mrpt.org/tutorials/programming/maths-and-geometry/2d_3d_geometry/), [SE(2)/SE(3) Lie groups](http://ingmec.ual.es/~jlblanco/papers/jlblanco2010geometry3D_techrep.pdf),
[probability density functions (pdfs)](http://reference.mrpt.org/stable/classmrpt_1_1utils_1_1_c_probability_density_function.html) over points, landmarks, poses and maps,
Bayesian inference ([Kalman filters](http://www.mrpt.org/Kalman_Filters), [particle filters](http://www.mrpt.org/tutorials/programming/statistics-and-bayes-filtering/particle_filters/)), [image processing](http://www.mrpt.org/tutorials/programming/images-image-processing-camera-models/), [obstacle avoidance](http://www.mrpt.org/Obstacle_avoidance), [etc](http://reference.mrpt.org/devel/modules.html).
MRPT also provides GUI apps for [Stereo camera calibration](http://www.mrpt.org/list-of-mrpt-apps/application-kinect-stereo-calib/), [dataset inspection](http://www.mrpt.org/list-of-mrpt-apps/rawlogviewer/),
and [much more](http://www.mrpt.org/list-of-mrpt-apps/).

## 2. Resources
* Download the latest unstable code with: `git clone https://github.com/MRPT/mrpt.git --depth 1`
* Ask questions at: [this Google group](http://www.mrpt.org/forum/) or at [stackoverflow](http://stackoverflow.com/search?q=mrpt) (please, use the tag `mrpt`!)
* [Main project website](http://www.mrpt.org/), including [sources and Windows installer downloads](http://www.mrpt.org/download-mrpt/)
* [C++ API reference](http://reference.mrpt.org/)
* ROS packages: [mrpt_navigation](http://wiki.ros.org/mrpt_navigation), [mrpt_slam](http://wiki.ros.org/mrpt_slam)
* ROS packages: [`mrpt_navigation`](http://wiki.ros.org/mrpt_navigation), [`mrpt_slam`](http://wiki.ros.org/mrpt_slam)
* [Bindings documentation](https://github.com/MRPT/mrpt/wiki) (Python, Matlab)
* Source code for [dozens of examples](http://www.mrpt.org/tutorials/mrpt-examples/)
* Example configuration files for MRPT applications can be found at:
* Example configuration files for MRPT applications can be found at:
[MRPT/share/mrpt/config_files](https://github.com/MRPT/mrpt/tree/master/share/mrpt/config_files)
* Some sample datasets are stored in:
[MRPT/share/mrpt/datasets](https://github.com/MRPT/mrpt/tree/master/share/mrpt/datasets).
* Some sample datasets are stored in:
[MRPT/share/mrpt/datasets](https://github.com/MRPT/mrpt/tree/master/share/mrpt/datasets).
A more complete dataset repository is [available online](http://www.mrpt.org/robotics_datasets).
* [How to contribute](https://github.com/MRPT/mrpt/blob/master/.github/CONTRIBUTING.md) with your code for new feaures, bug fixes, etc.

## 3. Compiling
### 3.1 **FIVE SECONDS INSTRUCTIONS**

1. Invoke `cmake-gui` and select:
* Where source is --> MRPT source root directory
* Where to build binaries --> Pick a new, empty directory.
Minimum compiler requisites:
* Ubuntu 16.04 default gcc/clang versions, or
* Windows: Visual Studio 2015/2017.

If your platform doesn't support cmake-gui, open a console, chdir to a new
empty directory and execute:

$ ccmake <PATH_TO_MRPT_SOURCES>
To build in Debian/Ubuntu follow the steps below. See [full build docs](http://www.mrpt.org/Building_and_Installing_Instructions) online
for Windows instructions or to learn all the details.

2. Within `cmake-gui` (or `ccmake`), set all the build options as
you desire, then press "Configure" and "Generate". To build
the examples, enable `BUILD_SAMPLES`.
* Install minimum recommended dependencies:

3. Build with the IDE / compiler you selected from CMake (Visual Studio, GNU Make,...)
```bash
sudo apt install build-essential pkg-config cmake libwxgtk3.0-dev \
libopencv-dev libeigen3-dev libgtest-dev
```

* Install additional dependencies to enable all MRPT features:

### 3.2. Further details (RECOMMENDED!)
```bash
sudo apt install libftdi-dev freeglut3-dev zlib1g-dev libusb-1.0-0-dev \
libudev-dev libfreenect-dev libdc1394-22-dev libavformat-dev libswscale-dev \
libassimp-dev libjpeg-dev libsuitesparse-dev libpcap-dev liboctomap-dev
```

Read the [compiling instructions](http://www.mrpt.org/Building_and_Installing_Instructions).
* Build with `cmake` as usual:

```bash
mkdir build && cd build
cmake ..
make
```

## 4. License
MRPT is released under the [new BSD license](http://www.mrpt.org/License/).

2 changes: 1 addition & 1 deletion cmakemodules/DeclareMRPTLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ macro(internal_define_mrpt_lib name headers_only is_metalib)

# Special case: embedded eigen3 as dep of "mrpt-base"
IF (EIGEN_USE_EMBEDDED_VERSION AND ${name} STREQUAL "base")
add_dependencies(mrpt-${name} eigen3)
add_dependencies(mrpt-${name} EP_eigen3)
ENDIF()


Expand Down
102 changes: 52 additions & 50 deletions cmakemodules/script_assimp.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Check for system libassimp:
# http://assimp.sourceforge.net/
# ===================================================


SET(CMAKE_MRPT_HAS_ASSIMP 0)
SET(CMAKE_MRPT_HAS_ASSIMP_SYSTEM 0)

Expand All @@ -28,45 +26,33 @@ IF(PKG_CONFIG_FOUND)
ENDIF (ASSIMP_FOUND)
ENDIF(PKG_CONFIG_FOUND)

IF (NOT ASSIMP_FOUND AND EXISTS "${MRPT_SOURCE_DIR}/otherlibs/assimp/")
IF (NOT ASSIMP_FOUND)
SET(BUILD_ASSIMP ON CACHE BOOL "Build an embedded version of Assimp (3D models importer)")
IF (BUILD_ASSIMP)

# Use embedded version:
# --------------------------
# Tune cmake vars for assimp build for mrpt:
SET (ASSIMP_BUILD_ASSIMP_TOOLS OFF CACHE BOOL "If the supplementary tools for Assimp are built in addition to the library." FORCE)
SET (ASSIMP_BUILD_SAMPLES OFF CACHE BOOL "If the official samples are built as well (needs Glut)." FORCE)
SET (ASSIMP_BUILD_STATIC_LIB ON CACHE BOOL "Build Assimp static." FORCE)
SET (ASSIMP_BUILD_TESTS OFF CACHE BOOL "." FORCE)
set(ASSIMP_LIBRARY_SUFFIX "-mrpt" CACHE STRING "Suffix to append to library names" FORCE)

add_subdirectory("${MRPT_SOURCE_DIR}/otherlibs/assimp/")
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(assimp PROPERTIES FOLDER "3rd party")
else(ENABLE_SOLUTION_FOLDERS)
SET_TARGET_PROPERTIES(assimp PROPERTIES PROJECT_LABEL "(3rdparty) assimp")
endif(ENABLE_SOLUTION_FOLDERS)
MARK_AS_ADVANCED(
ASSIMP_BUILD_ASSIMP_TOOLS
ASSIMP_BUILD_SAMPLES
ASSIMP_BUILD_TESTS
AMD64
ASM686
ASSIMP_BIN_INSTALL_DIR
ASSIMP_BUILD_STATIC_LIB
ASSIMP_DEBUG_POSTFIX
ASSIMP_ENABLE_BOOST_WORKAROUND
ASSIMP_NO_EXPORT
ASSIMP_INCLUDE_INSTALL_DIR
ASSIMP_LIB_INSTALL_DIR
ASSIMP_BIN_INSTALL_DIR
ASSIMP_INSTALL_PDB
ASSIMP_OPT_BUILD_PACKAGES
ASSIMP_PACKAGE_VERSION
ASSIMP_LIBRARY_SUFFIX
)

# Include embedded version headers:
include(ExternalProject)
# download from GH
ExternalProject_Add(EP_assimp
URL "https://github.com/assimp/assimp/archive/v4.0.1.tar.gz"
URL_MD5 "23a6301c728a413aafbfa1cca19ba91f"
SOURCE_DIR "${MRPT_BINARY_DIR}/otherlibs/assimp/"
CMAKE_ARGS
-DASSIMP_BUILD_ASSIMP_TOOLS=OFF
-DASSIMP_BUILD_SAMPLES=OFF
-DASSIMP_BUILD_STATIC_LIB=ON
-DASSIMP_BUILD_TESTS=OFF
-DASSIMP_LIBRARY_SUFFIX=-mrpt
-DCMAKE_LIBRARY_OUTPUT_PATH=${MRPT_BINARY_DIR}/lib
-DLIBRARY_OUTPUT_PATH=${MRPT_BINARY_DIR}/lib
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${MRPT_BINARY_DIR}/bin
-DRUNTIME_OUTPUT_DIRECTORY=${MRPT_BINARY_DIR}/bin
-DCMAKE_DEBUG_POSTFIX=d
INSTALL_COMMAND ""
TEST_COMMAND ""
)

# 2nd attempt: via cmake
SET(ASSIMP_DIR "${EMBEDDED_ASSIMP_DIR}" CACHE PATH "Path to ASSIMP CMake config file" FORCE)
Expand All @@ -76,24 +62,41 @@ IF (NOT ASSIMP_FOUND AND EXISTS "${MRPT_SOURCE_DIR}/otherlibs/assimp/")

SET(CMAKE_MRPT_HAS_ASSIMP 1)
SET(CMAKE_MRPT_HAS_ASSIMP_SYSTEM 0)

# Override binary output dir:
SET_TARGET_PROPERTIES(assimp PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
)

ENDIF (BUILD_ASSIMP)
ENDIF()

IF (ASSIMP_FOUND_VIA_CMAKE)
# override wrong target libs in -config.cmake file:
set(ASSIMP_LIBRARIES "")
LIST(APPEND ASSIMP_LIBRARIES optimized "assimp-mrpt" debug "assimp-mrptd")

if(MSVC12)
SET(ASSIMP_MSVC_VERSION "vc120")
elseif(MSVC14)
SET(ASSIMP_MSVC_VERSION "vc140")
ENDIF(MSVC12)

if(MSVC12 OR MSVC14)
SET(ASSIMP_CUSTOM_LIB_NAME "assimp-mrpt-${ASSIMP_MSVC_VERSION}-mt")
else()
SET(ASSIMP_CUSTOM_LIB_NAME "assimp")
SET(ASSIMP_LIBRARY_DIRS "${MRPT_BINARY_DIR}/lib")
endif()

LIST(APPEND ASSIMP_LIBRARIES optimized "${ASSIMP_CUSTOM_LIB_NAME}" debug "${ASSIMP_CUSTOM_LIB_NAME}d")

# override wrong include dirs:
SET(ASSIMP_INCLUDE_DIRS "${MRPT_SOURCE_DIR}/otherlibs/assimp/include/")
SET(ASSIMP_INCLUDE_DIRS
"${MRPT_BINARY_DIR}/otherlibs/assimp/include/"
"${MRPT_BINARY_DIR}/EP_assimp-prefix/src/EP_assimp-build/include/"
)

# Install assimp DLLs (for binary packages)
IF(WIN32)
FILE(GLOB_RECURSE EXTRA_DLLS "${MRPT_BINARY_DIR}/bin/Release/assimp-*.dll" "${MRPT_BINARY_DIR}/bin/Debug/assimp-*.dll")
FOREACH(F ${EXTRA_DLLS})
INSTALL(FILES "${F}" DESTINATION bin)
ENDFOREACH(F)
ENDIF()
ENDIF (ASSIMP_FOUND_VIA_CMAKE)

# ASSIMP_ROOT_DIR - the root directory where the installation can be found
Expand All @@ -103,12 +106,11 @@ ENDIF (ASSIMP_FOUND_VIA_CMAKE)
# ASSIMP_LIBRARY_DIRS - link directories
# ASSIMP_LIBRARIES - libraries to link plugins with
IF (CMAKE_MRPT_HAS_ASSIMP)
MARK_AS_ADVANCED(ASSIMP_DIR)

# Seems to be needed by all mrpt-* projects
IF(NOT ${ASSIMP_LIBRARY_DIRS} STREQUAL "")
if (NOT "${ASSIMP_LIBRARY_DIRS}" STREQUAL "")
LINK_DIRECTORIES("${ASSIMP_LIBRARY_DIRS}")
ENDIF(NOT ${ASSIMP_LIBRARY_DIRS} STREQUAL "")
endif()

MARK_AS_ADVANCED(ASSIMP_DIR)

IF ($ENV{VERBOSE})
MESSAGE(STATUS "Assimp:")
Expand Down
6 changes: 3 additions & 3 deletions cmakemodules/script_eigen.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ IF (EIGEN_USE_EMBEDDED_VERSION)
# Include embedded version headers:
include(ExternalProject)
# download Eigen from bitbucket
ExternalProject_Add(eigen3
ExternalProject_Add(EP_eigen3
URL "https://bitbucket.org/eigen/eigen/get/3.3.4.tar.bz2"
URL_MD5 "a7aab9f758249b86c93221ad417fbe18"
SOURCE_DIR "${MRPT_SOURCE_DIR}/otherlibs/eigen3/"
SOURCE_DIR "${MRPT_BINARY_DIR}/otherlibs/eigen3/"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
TEST_COMMAND ""
)

SET(EIGEN_EMBEDDED_INCLUDE_DIR "${MRPT_SOURCE_DIR}/otherlibs/eigen3/" CACHE PATH "Eigen path for embedded use")
SET(EIGEN_EMBEDDED_INCLUDE_DIR "${MRPT_BINARY_DIR}/otherlibs/eigen3/" CACHE PATH "Eigen path for embedded use" FORCE)
MARK_AS_ADVANCED(EIGEN_EMBEDDED_INCLUDE_DIR)

SET(MRPT_EIGEN_INCLUDE_DIR "${EIGEN_EMBEDDED_INCLUDE_DIR}")
Expand Down
18 changes: 14 additions & 4 deletions cmakemodules/script_install_commands.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ IF(WIN32)
INSTALL(FILES "${F}" DESTINATION bin)
ENDFOREACH(F)
ENDIF (EXISTS "${FFMPEG_WIN32_ROOT_DIR}/bin")

# Extra optional DLLs to be installed in the "bin" folder:
file(TO_CMAKE_PATH "$ENV{MRPT_EXTRA_DLLS_TO_INSTALL}" MRPT_EXTRA_DLLS_TO_INSTALL)
IF (NOT "${MRPT_EXTRA_DLLS_TO_INSTALL}" STREQUAL "")
Expand Down Expand Up @@ -136,7 +136,7 @@ IF (PACKAGE_INCLUDES_SOURCES)
ENDIF(NOT IS_DEBIAN_DBG_PKG)
ENDIF (PACKAGE_INCLUDES_SOURCES)

# If using embedded version, install embedded version as part of mrpt-base's headers:
# Using embedded version of libraries that need public headers?
IF (PACKAGE_INCLUDES_SOURCES)
IF (EIGEN_USE_EMBEDDED_VERSION AND NOT IS_DEBIAN_DBG_PKG)
IF(WIN32)
Expand All @@ -148,10 +148,20 @@ IF (PACKAGE_INCLUDES_SOURCES)
ENDIF(WIN32)

INSTALL(
DIRECTORY "${MRPT_SOURCE_DIR}/otherlibs/eigen3/Eigen"
DIRECTORY "${MRPT_BINARY_DIR}/otherlibs/eigen3/Eigen"
DESTINATION "${MRPT_INSTALL_EIGEN_PREFIX}" )
INSTALL(
DIRECTORY "${MRPT_SOURCE_DIR}/otherlibs/eigen3/unsupported"
DIRECTORY "${MRPT_BINARY_DIR}/otherlibs/eigen3/unsupported"
DESTINATION "${MRPT_INSTALL_EIGEN_PREFIX}" )
ENDIF (EIGEN_USE_EMBEDDED_VERSION AND NOT IS_DEBIAN_DBG_PKG)

IF (CMAKE_MRPT_HAS_OCTOMAP AND NOT CMAKE_MRPT_HAS_OCTOMAP_SYSTEM)
# headers must end up in /Program Files/MRPT-X.Y.Z/libs/maps/...
SET(MRPT_INSTALL_OCTOMAP_PREFIX "libs/maps/include/")

INSTALL(
DIRECTORY "${MRPT_BINARY_DIR}/otherlibs/octomap/octomap/include/"
DESTINATION "${MRPT_INSTALL_OCTOMAP_PREFIX}" )
ENDIF()

ENDIF (PACKAGE_INCLUDES_SOURCES)

0 comments on commit 4d7c9bb

Please sign in to comment.