forked from jrl-umi3218/jrl-cmakemodules
-
Notifications
You must be signed in to change notification settings - Fork 0
/
eigen.cmake
52 lines (48 loc) · 2.05 KB
/
eigen.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Copyright (C) 2008-2014 LAAS-CNRS, JRL AIST-CNRS.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# SEARCH_FOR_EIGEN
# -----------------
#
# This macro gets eigen include path from pkg-config file, and adds it include directories.
# If there is no pkg-config for Eigen, we fall back to a manual search.
#
# If no version requirement argument is passed to the macro, it looks for the
# variable Eigen_REQUIRED. If this variable is not defined before calling
# the method SEARCH_FOR_EIGEN, the minimum version requirement is 3.0.0 by default.
MACRO(SEARCH_FOR_EIGEN)
SET(_Eigen_FOUND 0)
IF(${ARGC} GREATER 0)
SET(Eigen_REQUIRED ${ARGV0})
ELSEIF(NOT Eigen_REQUIRED)
SET(Eigen_REQUIRED "eigen3 >= 3.0.0")
ENDIF()
# looking for .pc
PKG_CHECK_MODULES(_Eigen ${Eigen_REQUIRED})
IF(${_Eigen_FOUND})
SET(${PROJECT_NAME}_CXX_FLAGS "${${PROJECT_NAME}_CXX_FLAGS} ${_Eigen_CFLAGS_OTHER}")
SET(${PROJECT_NAME}_LINK_FLAGS "${${PROJECT_NAME}_LINK_FLAGS} ${_Eigen_LDFLAGS_OTHER}")
INCLUDE_DIRECTORIES(SYSTEM ${_Eigen_INCLUDE_DIRS} )
_ADD_TO_LIST(_PKG_CONFIG_REQUIRES "${Eigen_REQUIRED}" ",")
ELSE()
# fallback: search for the signature_of_eigen3_matrix_library file
FIND_PATH(Eigen_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
PATHS
${CMAKE_INSTALL_PREFIX}/include
PATH_SUFFIXES eigen3 eigen
)
INCLUDE_DIRECTORIES(SYSTEM ${Eigen_INCLUDE_DIR})
PKG_CONFIG_APPEND_CFLAGS(-I"${Eigen_INCLUDE_DIR}")
ENDIF()
ENDMACRO(SEARCH_FOR_EIGEN)