forked from Archive/PX4-Autopilot
Merge pull request #114 from PX4/fix_linux_build
CMakeLists: use find_package Eigen3
This commit is contained in:
commit
d595596c42
|
@ -7,7 +7,7 @@ before_install:
|
||||||
- sudo apt-get update -qq
|
- sudo apt-get update -qq
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- sudo apt-get install -qq g++-4.8
|
- sudo apt-get install -qq g++-4.8 libeigen3-dev
|
||||||
- export CXX="g++-4.8"
|
- export CXX="g++-4.8"
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
|
|
|
@ -35,14 +35,15 @@ cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
project (ECL CXX)
|
project (ECL CXX)
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
set(CMAKE_CURRENT_SOURCE_DIR ./)
|
|
||||||
set(CMAKE_CXX_FLAGS "-DPOSIX_SHARED")
|
set(CMAKE_CXX_FLAGS "-DPOSIX_SHARED")
|
||||||
set(EIGEN3_INCLUDE_DIR "/usr/local/include/eigen3/")
|
|
||||||
|
|
||||||
IF( NOT EIGEN3_INCLUDE_DIR )
|
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
MESSAGE( FATAL_ERROR "Please point the environment variable EIGEN3_INCLUDE_DIR to the include directory of your Eigen3 installation.")
|
message("looking for FindEigen3.cmake in ${CMAKE_MODULE_PATH}")
|
||||||
ENDIF()
|
find_package(Eigen3 REQUIRED)
|
||||||
INCLUDE_DIRECTORIES ( "${EIGEN3_INCLUDE_DIR}" )
|
|
||||||
|
if( NOT EIGEN3_INCLUDE_DIR )
|
||||||
|
message( FATAL_ERROR "Eigen3 not found.")
|
||||||
|
endif()
|
||||||
|
|
||||||
if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../matrix/.git" )
|
if( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../matrix/.git" )
|
||||||
message( SEND_ERROR "The git submodules are not available. Please run
|
message( SEND_ERROR "The git submodules are not available. Please run
|
||||||
|
@ -54,7 +55,7 @@ include_directories(
|
||||||
./
|
./
|
||||||
../
|
../
|
||||||
../matrix
|
../matrix
|
||||||
EIGEN3_INCLUDE_DIR
|
${EIGEN3_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
set(SRCS
|
set(SRCS
|
||||||
estimator_interface.cpp
|
estimator_interface.cpp
|
||||||
|
@ -70,4 +71,8 @@ set(SRCS
|
||||||
mathlib.cpp
|
mathlib.cpp
|
||||||
)
|
)
|
||||||
add_definitions(-std=c++11 -Wall -Werror)
|
add_definitions(-std=c++11 -Wall -Werror)
|
||||||
|
|
||||||
|
# Eigen throws various warnings
|
||||||
|
add_definitions(-Wno-deprecated-declarations -Wno-enum-compare -Wno-unused-local-typedefs)
|
||||||
|
|
||||||
add_library(ecl SHARED ${SRCS})
|
add_library(ecl SHARED ${SRCS})
|
||||||
|
|
|
@ -0,0 +1,90 @@
|
||||||
|
# - Try to find Eigen3 lib
|
||||||
|
#
|
||||||
|
# This module supports requiring a minimum version, e.g. you can do
|
||||||
|
# find_package(Eigen3 3.1.2)
|
||||||
|
# to require version 3.1.2 or newer of Eigen3.
|
||||||
|
#
|
||||||
|
# Once done this will define
|
||||||
|
#
|
||||||
|
# EIGEN3_FOUND - system has eigen lib with correct version
|
||||||
|
# EIGEN3_INCLUDE_DIR - the eigen include directory
|
||||||
|
# EIGEN3_VERSION - eigen version
|
||||||
|
#
|
||||||
|
# This module reads hints about search locations from
|
||||||
|
# the following enviroment variables:
|
||||||
|
#
|
||||||
|
# EIGEN3_ROOT
|
||||||
|
# EIGEN3_ROOT_DIR
|
||||||
|
|
||||||
|
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
|
||||||
|
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
|
||||||
|
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
|
||||||
|
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
|
||||||
|
|
||||||
|
if(NOT Eigen3_FIND_VERSION)
|
||||||
|
if(NOT Eigen3_FIND_VERSION_MAJOR)
|
||||||
|
set(Eigen3_FIND_VERSION_MAJOR 2)
|
||||||
|
endif(NOT Eigen3_FIND_VERSION_MAJOR)
|
||||||
|
if(NOT Eigen3_FIND_VERSION_MINOR)
|
||||||
|
set(Eigen3_FIND_VERSION_MINOR 91)
|
||||||
|
endif(NOT Eigen3_FIND_VERSION_MINOR)
|
||||||
|
if(NOT Eigen3_FIND_VERSION_PATCH)
|
||||||
|
set(Eigen3_FIND_VERSION_PATCH 0)
|
||||||
|
endif(NOT Eigen3_FIND_VERSION_PATCH)
|
||||||
|
|
||||||
|
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
|
||||||
|
endif(NOT Eigen3_FIND_VERSION)
|
||||||
|
|
||||||
|
macro(_eigen3_check_version)
|
||||||
|
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
|
||||||
|
|
||||||
|
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
|
||||||
|
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
|
||||||
|
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
|
||||||
|
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
|
||||||
|
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
|
||||||
|
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
|
||||||
|
|
||||||
|
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
|
||||||
|
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
|
||||||
|
set(EIGEN3_VERSION_OK FALSE)
|
||||||
|
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
|
||||||
|
set(EIGEN3_VERSION_OK TRUE)
|
||||||
|
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
|
||||||
|
|
||||||
|
if(NOT EIGEN3_VERSION_OK)
|
||||||
|
|
||||||
|
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
|
||||||
|
"but at least version ${Eigen3_FIND_VERSION} is required")
|
||||||
|
endif(NOT EIGEN3_VERSION_OK)
|
||||||
|
endmacro(_eigen3_check_version)
|
||||||
|
|
||||||
|
if (EIGEN3_INCLUDE_DIR)
|
||||||
|
|
||||||
|
# in cache already
|
||||||
|
_eigen3_check_version()
|
||||||
|
set(EIGEN3_FOUND ${EIGEN3_VERSION_OK})
|
||||||
|
|
||||||
|
else (EIGEN3_INCLUDE_DIR)
|
||||||
|
|
||||||
|
find_path(EIGEN3_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
|
||||||
|
HINTS
|
||||||
|
ENV EIGEN3_ROOT
|
||||||
|
ENV EIGEN3_ROOT_DIR
|
||||||
|
PATHS
|
||||||
|
${CMAKE_INSTALL_PREFIX}/include
|
||||||
|
${KDE4_INCLUDE_DIR}
|
||||||
|
PATH_SUFFIXES eigen3 eigen
|
||||||
|
)
|
||||||
|
|
||||||
|
if(EIGEN3_INCLUDE_DIR)
|
||||||
|
_eigen3_check_version()
|
||||||
|
endif(EIGEN3_INCLUDE_DIR)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
|
||||||
|
|
||||||
|
mark_as_advanced(EIGEN3_INCLUDE_DIR)
|
||||||
|
|
||||||
|
endif(EIGEN3_INCLUDE_DIR)
|
||||||
|
|
36
README.md
36
README.md
|
@ -1,6 +1,6 @@
|
||||||
# ECL
|
# ECL
|
||||||
|
|
||||||
#### Very lightweight Estimation & Control Library.
|
**Very lightweight Estimation & Control Library.**
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/PX4/ecl.svg?branch=master)](https://travis-ci.org/PX4/ecl)
|
[![Build Status](https://travis-ci.org/PX4/ecl.svg?branch=master)](https://travis-ci.org/PX4/ecl)
|
||||||
|
|
||||||
|
@ -8,11 +8,35 @@ This library solves the estimation & control problems of a number of robots and
|
||||||
|
|
||||||
The library is currently BSD licensed, but might move to Apache 2.0.
|
The library is currently BSD licensed, but might move to Apache 2.0.
|
||||||
## Building EKF Library
|
## Building EKF Library
|
||||||
Prerequisite:
|
|
||||||
|
### Prerequisites:
|
||||||
|
|
||||||
* Eigen3: http://eigen.tuxfamily.org/index.php installed
|
* Eigen3: http://eigen.tuxfamily.org/index.php installed
|
||||||
|
|
||||||
|
#### Ubuntu:
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo apt-get install libeigen3-dev
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Mac
|
||||||
|
|
||||||
|
```
|
||||||
|
brew install eigen
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
By following the steps mentioned below you can create a shared library which can be included in projects using `-l` flag of gcc:
|
By following the steps mentioned below you can create a shared library which can be included in projects using `-l` flag of gcc:
|
||||||
* mkdir Build/
|
|
||||||
* cd Build/
|
```
|
||||||
* cmake ../EKF
|
mkdir Build/
|
||||||
* make
|
cd Build/
|
||||||
|
cmake ../EKF
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
Alternatively, just run:
|
||||||
|
|
||||||
|
```
|
||||||
|
./build.sh
|
||||||
|
```
|
||||||
|
|
18
build.sh
18
build.sh
|
@ -1,6 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
############################################################################
|
############################################################################
|
||||||
#
|
#
|
||||||
# Copyright (c) 2015 ECL Development Team. All rights reserved.
|
# Copyright (c) 2015-2016 ECL Development Team. All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
# modification, are permitted provided that the following conditions
|
# modification, are permitted provided that the following conditions
|
||||||
|
@ -31,19 +32,12 @@
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
#download, build and install eigen
|
# Exit on any error.
|
||||||
wget -O eigen.tar.bz2 http://bitbucket.org/eigen/eigen/get/3.2.8.tar.bz2
|
set -e
|
||||||
mkdir eigen
|
|
||||||
tar -xvjf eigen.tar.bz2 -C eigen --strip-components=1
|
|
||||||
mkdir eigen-build
|
|
||||||
cd eigen-build
|
|
||||||
cmake ../eigen
|
|
||||||
make
|
|
||||||
sudo make install
|
|
||||||
|
|
||||||
#build EKF shared library
|
# Build EKF shared library.
|
||||||
cd ..
|
|
||||||
mkdir Build
|
mkdir Build
|
||||||
cd Build
|
cd Build
|
||||||
cmake ../EKF
|
cmake ../EKF
|
||||||
make
|
make
|
||||||
|
cd ..
|
||||||
|
|
Loading…
Reference in New Issue