Skip to content

Commit

Permalink
Minimum version number test option for eigen.m4
Browse files Browse the repository at this point in the history
  • Loading branch information
roystgnr committed Mar 21, 2013
1 parent 41471cb commit 7c7e008
Show file tree
Hide file tree
Showing 3 changed files with 182 additions and 30 deletions.
113 changes: 100 additions & 13 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -31429,8 +31429,10 @@ fi
# Eigen -- Optimized linear algebra routines, enabled by default
# -------------------------------------------------------------

# we require Eigen/Sparse support
# we require Eigen/Sparse support if we're going to enable Eigen
enableeigensparse=yes
# we test with Eigen 3.1.2, so if the user has their own Eigen it
# should be at least that new.

# Check whether --enable-eigen was given.
if test "${enable_eigen+set}" = set; then :
Expand All @@ -31444,6 +31446,10 @@ else
fi


# package requirement; if not specified, the default is to assume that
# the package is optional

is_package_required=no

install_internal_eigen=no
if (test x$enableeigen = xyes); then
Expand Down Expand Up @@ -31524,10 +31530,10 @@ $as_echo "<<< external Eigen header files not found, using Eigen from ./contrib
# OK, we have a usable eigen path, make sure the headers we want are good.
if (test x$enableeigen = xyes); then

ac_eigen_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-I${EIGEN_INC} ${CPPFLAGS}"
ac_eigen_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-I${EIGEN_INC} ${CPPFLAGS}"

for ac_header in Eigen/Dense
for ac_header in Eigen/Dense
do :
ac_fn_cxx_check_header_mongrel "$LINENO" "Eigen/Dense" "ac_cv_header_Eigen_Dense" "$ac_includes_default"
if test "x$ac_cv_header_Eigen_Dense" = xyes; then :
Expand All @@ -31542,8 +31548,8 @@ fi
done


if (test x$enableeigensparse = xyes); then
for ac_header in Eigen/Sparse
if (test x$enableeigensparse = xyes); then
for ac_header in Eigen/Sparse
do :
ac_fn_cxx_check_header_mongrel "$LINENO" "Eigen/Sparse" "ac_cv_header_Eigen_Sparse" "$ac_includes_default"
if test "x$ac_cv_header_Eigen_Sparse" = xyes; then :
Expand All @@ -31557,19 +31563,100 @@ fi

done

fi
fi

#-----------------------
# Minimum version check
#----------------------

min_eigen_version=3.1.2

# looking for major.minor.micro (which Eigen calls world.major.minor) style versioning

MAJOR_VER=`echo $min_eigen_version | sed 's/^\([0-9]*\).*/\1/'`
if test "x${MAJOR_VER}" = "x" ; then
MAJOR_VER=0
fi

MINOR_VER=`echo $min_eigen_version | sed 's/^\([0-9]*\)\.\{0,1\}\([0-9]*\).*/\2/'`
if test "x${MINOR_VER}" = "x" ; then
MINOR_VER=0
fi

MICRO_VER=`echo $min_eigen_version | sed 's/^\([0-9]*\)\.\{0,1\}\([0-9]*\)\.\{0,1\}\([0-9]*\).*/\3/'`
if test "x${MICRO_VER}" = "x" ; then
MICRO_VER=0
fi


{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for eigen - version >= $min_eigen_version" >&5
$as_echo_n "checking for eigen - version >= $min_eigen_version... " >&6; }

ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu

cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */

#include "Eigen/Core"

int
main ()
{

#if EIGEN_WORLD_VERSION > $MAJOR_VER
#elif (EIGEN_WORLD_VERSION >= $MAJOR_VER) && (EIGEN_MAJOR_VERSION > $MINOR_VER)
#elif (EIGEN_WORLD_VERSION >= $MAJOR_VER) && (EIGEN_MAJOR_VERSION >= $MINOR_VER) && (EIGEN_MINOR_VERSION >= $MICRO_VER)
#else
# error version is too old
#endif

CPPFLAGS="${ac_eigen_save_CPPFLAGS}"
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :

# if we survived, we really have Eigen
if (test x$enableeigen = xyes); then
HAVE_EIGEN=1
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }

else

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
enableeigen=no

fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu


CPPFLAGS="${ac_eigen_save_CPPFLAGS}"

# if we survived, we really have Eigen
if (test x$enableeigen = xyes); then
HAVE_EIGEN=1

$as_echo "#define HAVE_EIGEN 1" >>confdefs.h

{ $as_echo "$as_me:${as_lineno-$LINENO}: result: <<< Configuring library with Eigen support >>>" >&5
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: <<< Configuring library with Eigen support >>>" >&5
$as_echo "<<< Configuring library with Eigen support >>>" >&6; }
fi
elif test "$is_package_required" = yes; then
as_fn_error $? "

Your EIGEN version ($EIGEN_INC) does not meet the minimum versioning
requirements ($min_eigen_version). Please use --with-eigen-include to
specify the location of an updated installation.

" "$LINENO" 5
fi
fi

ac_ext=cpp
Expand Down
93 changes: 78 additions & 15 deletions m4/eigen.m4
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
# Eigen files in the --with-eigen-include=xxx argument provided to
# configure, or if those don't exist in the $EIGEN_INC/Eigen directory,
# or in /usr/include.
dnl
#
# If an argument to this macro is specified, it should give the minimum useful
# version number.
#
# If a second argument to this macro is specified as 'yes', then this is a
# required dependency and configure will exit with an error if it is not
# satisfied.
#
# Note: Eigen is installed (by default) at the location
# /path/to/eigen/Eigen, i.e. with path ending in capital 'Eigen'.
# You should specify --with-eigen-include=/path/to/eigen
Expand All @@ -24,6 +31,10 @@ AC_DEFUN([CONFIGURE_EIGEN],
esac],
[enableeigen=$enableoptional])
# package requirement; if not specified, the default is to assume that
# the package is optional
is_package_required=ifelse([$2], ,no, $2 )
install_internal_eigen=no
if (test x$enableeigen = xyes); then
Expand Down Expand Up @@ -82,23 +93,75 @@ AC_DEFUN([CONFIGURE_EIGEN],
# OK, we have a usable eigen path, make sure the headers we want are good.
if (test x$enableeigen = xyes); then
ac_eigen_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-I${EIGEN_INC} ${CPPFLAGS}"
ac_eigen_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="-I${EIGEN_INC} ${CPPFLAGS}"
AC_CHECK_HEADERS([Eigen/Dense],[],[enableeigen=no])
AC_CHECK_HEADERS([Eigen/Dense],[],[enableeigen=no])
if (test x$enableeigensparse = xyes); then
AC_CHECK_HEADERS([Eigen/Sparse],[],[enableeigen=no])
fi
if (test x$enableeigensparse = xyes); then
AC_CHECK_HEADERS([Eigen/Sparse],[],[enableeigen=no])
fi
CPPFLAGS="${ac_eigen_save_CPPFLAGS}"
# if we survived, we really have Eigen
if (test x$enableeigen = xyes); then
HAVE_EIGEN=1
AC_DEFINE(HAVE_EIGEN, 1, [Flag indicating whether the library will be compiled with Eigen support])
AC_MSG_RESULT(<<< Configuring library with Eigen support >>>)
fi
#-----------------------
# Minimum version check
#----------------------
min_eigen_version=ifelse([$1], ,0.0.0, $1)
# looking for major.minor.micro (which Eigen calls world.major.minor) style versioning
MAJOR_VER=`echo $min_eigen_version | sed 's/^\([[0-9]]*\).*/\1/'`
if test "x${MAJOR_VER}" = "x" ; then
MAJOR_VER=0
fi
MINOR_VER=`echo $min_eigen_version | sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\2/'`
if test "x${MINOR_VER}" = "x" ; then
MINOR_VER=0
fi
MICRO_VER=`echo $min_eigen_version | sed 's/^\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\)\.\{0,1\}\([[0-9]]*\).*/\3/'`
if test "x${MICRO_VER}" = "x" ; then
MICRO_VER=0
fi
AC_MSG_CHECKING(for eigen - version >= $min_eigen_version)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include "Eigen/Core"
]], [[
#if EIGEN_WORLD_VERSION > $MAJOR_VER
#elif (EIGEN_WORLD_VERSION >= $MAJOR_VER) && (EIGEN_MAJOR_VERSION > $MINOR_VER)
#elif (EIGEN_WORLD_VERSION >= $MAJOR_VER) && (EIGEN_MAJOR_VERSION >= $MINOR_VER) && (EIGEN_MINOR_VERSION >= $MICRO_VER)
#else
# error version is too old
#endif
]])],[
AC_MSG_RESULT(yes)
],[
AC_MSG_RESULT(no)
enableeigen=no
])
AC_LANG_POP([C++])
CPPFLAGS="${ac_eigen_save_CPPFLAGS}"
# if we survived, we really have Eigen
if (test x$enableeigen = xyes); then
HAVE_EIGEN=1
AC_DEFINE(HAVE_EIGEN, 1, [Flag indicating whether the library will be compiled with Eigen support])
AC_MSG_RESULT(<<< Configuring library with Eigen support >>>)
elif test "$is_package_required" = yes; then
AC_MSG_ERROR([
Your EIGEN version ($EIGEN_INC) does not meet the minimum versioning
requirements ($min_eigen_version). Please use --with-eigen-include to
specify the location of an updated installation.
])
fi
fi
AC_LANG_RESTORE
Expand Down
6 changes: 4 additions & 2 deletions m4/libmesh_optional_packages.m4
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,11 @@ AM_CONDITIONAL(LIBMESH_ENABLE_VTK, test x$enablevtk = xyes)
# Eigen -- Optimized linear algebra routines, enabled by default
# -------------------------------------------------------------
# we require Eigen/Sparse support
# we require Eigen/Sparse support if we're going to enable Eigen
enableeigensparse=yes
CONFIGURE_EIGEN
# we test with Eigen 3.1.2, so if the user has their own Eigen it
# should be at least that new.
CONFIGURE_EIGEN(3.1.2,no)
if (test x$enableeigen = xyes); then
# if we are installing our own Eigen, add it to the contrib search path
# which is not exported during install
Expand Down

0 comments on commit 7c7e008

Please sign in to comment.