-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathax_check_eigen.m4
98 lines (89 loc) · 2.29 KB
/
ax_check_eigen.m4
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# SYNOPSIS
#
# AX_EIGEN
#
# DESCRIPTION
#
# Test for the EIGEN libraries of a particular version (or newer)
#
# If no path to the installed eigen library is given the macro searchs
# under /usr, /usr/local, /opt and /opt/local and evaluates the
# $EIGEN_ROOT environment variable.
# Adapted from AX_BOOST_BASE
#
# This macro calls:
#
# AC_SUBST(EIGEN_CPPFLAGS) / AC_SUBST(EIGEN_LDFLAGS)
#
# And sets:
#
# HAVE_EIGEN
#
# LICENSE
#
# Copyright (c) 2010 Cole Trapnell <cole@cs.umd.edu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AC_DEFUN([AX_EIGEN],
[
AC_ARG_WITH([eigen],
AS_HELP_STRING([--with-eigen@<:@=DIR@:>@], [use EIGEN libraries (default is yes) - it is possible to specify the root directory for EIGEN (optional)]),
[
if test "$withval" = "no"; then
want_eigen="no"
elif test "$withval" = "yes"; then
want_eigen="yes"
ac_eigen_path=""
else
want_eigen="yes"
ac_eigen_path="$withval"
fi
],
[want_eigen="yes"])
if test "x$want_eigen" = "xyes"; then
AC_MSG_CHECKING(for eigenlib)
succeeded=no
dnl first we check the system location for eigen libraries
if test "$ac_eigen_path" != ""; then
EIGEN_CPPFLAGS="-I$ac_eigen_path/include"
else
for ac_eigen_path_tmp in /usr /usr/local /opt /opt/local ; do
for ac_eigen_subdir in eigen eigen3 ; do
ac_candidate_path="$ac_eigen_path_tmp/include/$ac_eigen_subdir"
if test -d "$ac_candidate_path" && test -r "$ac_candidate_path"; then
EIGEN_CPPFLAGS="-I$ac_candidate_path"
break;
fi
done
done
fi
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $EIGEN_CPPFLAGS"
export EIGEN_CPPFLAGS
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <Eigen/Dense>
]], [[
]])],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
],[
AC_MSG_ERROR([[We could not detect the Eigen3 library. Try installing libeigen3, or specifying a path with --with-eigen=/some/path]])
])
AC_LANG_POP([C++])
CPPFLAGS="$CPPFLAGS $EIGEN_CPPFLAGS"
export CPPFLAGS
LDFLAGS="$LDFLAGS $EIGEN_LDFLAGS"
export LDFLAGS
export EIGEN_CPPFLAGS
if test "$succeeded" == "yes" ; then
AC_SUBST(EIGEN_CPPFLAGS)
AC_DEFINE(HAVE_EIGEN,,[define if the EIGEN library is available])
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])