Linux build : fix undefined pragma
[scilab.git] / scilab / m4 / eigen.m4
1 dnl
2 dnl Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 dnl Copyright (C) INRIA - 2008 - Sylvestre Ledru
4 dnl
5 dnl Copyright (C) 2012 - 2016 - Scilab Enterprises
6 dnl
7 dnl This file is hereby licensed under the terms of the GNU GPL v2.0,
8 dnl pursuant to article 5.3.4 of the CeCILL v.2.1.
9 dnl This file was originally licensed under the terms of the CeCILL v2.1,
10 dnl and continues to be available under such terms.
11 dnl For more information, see the COPYING file which you should have received
12 dnl along with this program.
13 dnl
14 dnl AC_EIGEN
15 dnl ------------------------------------------------------
16 dnl Check if EIGEN is usable and working
17 dnl
18 AC_DEFUN([AC_EIGEN], [
19 AC_LANG_PUSH([C++])
20
21 AC_ARG_WITH(eigen_include,
22         AC_HELP_STRING([--with-eigen-include=DIR],[Set the path to the EIGEN headers]),
23         [with_eigen_include=$withval],
24         [with_eigen_include='yes']
25         )
26
27
28 save_CPPFLAGS="$CPPFLAGS"
29
30 if test "x$with_eigen_include" != "xyes"; then
31     CPPFLAGS="-I$with_eigen_include"
32     AC_CHECK_HEADER([Eigen/Sparse],
33         [EIGEN_CPPFLAGS="$CPPFLAGS"],
34         [AC_MSG_ERROR([Cannot find headers (Eigen/Sparse) of the library EIGEN in $with_eigen_include. Please install the dev package (Debian : libeigen3-dev)])]
35     )
36     PATH_TO_EIGEN=$with_eigen_include
37 else
38     if $WITH_DEVTOOLS; then # Scilab thirparties
39         CPPFLAGS="-I$DEVTOOLS_INCDIR"
40         AC_CHECK_HEADER([Eigen/Sparse],
41             [EIGEN_CPPFLAGS="$CPPFLAGS"],
42             [AC_MSG_ERROR([Cannot find headers (Eigen/Sparse) of the library EIGEN in $with_eigen_include. Please install the dev package (Debian : libeigen3-dev)])]
43         )
44         PATH_TO_EIGEN=$DEVTOOLS_INCDIR
45     else
46         AC_CHECK_HEADER([Eigen/Sparse],
47             [EIGEN_CPPFLAGS=""],
48             [       $as_unset ac_cv_header_Eigen_Sparse
49                     CPPFLAGS="-I/usr/include/eigen3/"
50                     AC_CHECK_HEADER([Eigen/Sparse],
51                                     [EIGEN_CPPFLAGS=$CPPFLAGS],
52                                     AC_MSG_ERROR([Cannot find headers (Eigen/Sparse) of the library eigen. Please install the dev package (Debian : libeigen3-dev)])
53                     )
54              ])
55         PATH_TO_EIGEN="/usr/include/eigen3/"
56     fi
57 fi
58 CPPFLAGS="$save_CPPFLAGS"
59
60 CHK_EIGEN_WORLD=3
61 CHK_EIGEN_MAJOR=1
62 CHK_EIGEN_MINOR=0
63
64 AC_MSG_CHECKING([if Eigen is version $CHK_EIGEN_WORLD.$CHK_EIGEN_MAJOR.$CHK_EIGEN_MINOR or later])
65 AC_GREP_CPP(EIGEN_VERSION_OK,
66 [
67 #include "$PATH_TO_EIGEN/Eigen/Sparse"
68 #if EIGEN_VERSION_AT_LEAST(3,1,0)
69 EIGEN_VERSION_OK
70 #endif
71 ],\
72 EIGEN_VERSION_OK=1,\
73 EIGEN_VERSION_OK=0 )
74 if test $EIGEN_VERSION_OK = 0; then
75    AC_MSG_ERROR([Version $CHK_EIGEN_WORLD.$CHK_EIGEN_MAJOR.$CHK_EIGEN_MINOR of Eigen expected (at least)])
76 else
77    AC_MSG_RESULT([yes])
78 fi
79 AC_SUBST(EIGEN_CPPFLAGS)
80
81 AC_DEFINE([WITH_EIGEN], [], [With the EIGEN library])
82 AC_LANG_POP([C++])
83 ])