Commit 95c0d9f0 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix autoconf detection of CGAL 5

This fixes issue #625
parent 57793779
Pipeline #560 failed with stage
in 392 minutes and 38 seconds
......@@ -35,16 +35,16 @@
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 4.1 (locally modified for graph-tool)
#serial 4.2 (locally modified for graph-tool)
AC_DEFUN([AX_LIB_CGAL_CORE],[
dnl guess from env, or use given value
AC_ARG_WITH([cgal],
AS_HELP_STRING([--with-cgal@<:@=DIR@:>@],
[location of cgal installation, default $CGAL_HOME]),
[ac_cgal_dirs="$withval"],
[ac_cgal_dirs="$CGAL_HOME"' /usr /usr/local /opt /opt/local']
AS_HELP_STRING([--with-cgal@<:@=DIR@:>@],
[location of cgal installation, default $CGAL_HOME]),
[ac_cgal_dirs="$withval"],
[ac_cgal_dirs="$CGAL_HOME"' /usr /usr/local /opt /opt/local']
)
AC_LANG_PUSH([C++])
......@@ -53,60 +53,70 @@ AC_CHECK_LIB(gmp, __gmpz_init, ,
[AC_MSG_ERROR([GNU MP not found (a CGAL dependency), see https://gmplib.org/])])
for ac_cgal_iterate in $ac_cgal_dirs ; do
CPPFLAGS_SAVED="$CPPFLAGS"
CGAL_CPPFLAGS="-I$ac_cgal_iterate/include"
CPPFLAGS="$CPPFLAGS $CGAL_CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
CPPFLAGS_SAVED="$CPPFLAGS"
CGAL_CPPFLAGS="-I$ac_cgal_iterate/include"
CPPFLAGS="$CPPFLAGS $CGAL_CPPFLAGS $BOOST_CPPFLAGS"
export CPPFLAGS
CGAL_LDFLAGS="-L$ac_cgal_iterate/lib -lCGAL -lCGAL_Core -lgmp ${BOOST_THREAD_LIB}"
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $CGAL_LDFLAGS"
export LDFLAGS
for include_only in yes no; do
if test $include_only = yes ; then
CGAL_LDFLAGS=""
else
CGAL_LDFLAGS="-L$ac_cgal_iterate/lib -lCGAL -lCGAL_Core -lgmp ${BOOST_THREAD_LIB}"
fi
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $CGAL_LDFLAGS"
export LDFLAGS
AC_MSG_CHECKING([whether CGAL is available in $ac_cgal_iterate])
dnl This test program is taken from:
dnl http://www.cgal.org/Manual/latest/examples/Convex_hull_2/vector_convex_hull_2.cpp
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[
[@%:@include <vector>]
[@%:@include <CGAL/Exact_predicates_inexact_constructions_kernel.h>]
[@%:@include <CGAL/convex_hull_2.h>]
[typedef CGAL::Exact_predicates_inexact_constructions_kernel K;]
[typedef K::Point_2 Point_2;]
[typedef std::vector<Point_2> Points;]
],
[
[Points points, result;
points.push_back(Point_2(0,0));
points.push_back(Point_2(10,0));
points.push_back(Point_2(10,10));
points.push_back(Point_2(6,5));
points.push_back(Point_2(4,1));
CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result));
//std::cout << result.size() << " points on the convex hull" << std::endl;]
])]
,[ac_cgal=yes],[ac_cgal=no])
AC_MSG_CHECKING([whether CGAL is available in $ac_cgal_iterate])
dnl This test program is taken from:
dnl http://www.cgal.org/Manual/latest/examples/Convex_hull_2/vector_convex_hull_2.cpp
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[
[@%:@include <vector>]
[@%:@include <CGAL/Exact_predicates_inexact_constructions_kernel.h>]
[@%:@include <CGAL/convex_hull_2.h>]
[typedef CGAL::Exact_predicates_inexact_constructions_kernel K;]
[typedef K::Point_2 Point_2;]
[typedef std::vector<Point_2> Points;]
],
[
[Points points, result;
points.push_back(Point_2(0,0));
points.push_back(Point_2(10,0));
points.push_back(Point_2(10,10));
points.push_back(Point_2(6,5));
points.push_back(Point_2(4,1));
CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result));
//std::cout << result.size() << " points on the convex hull" << std::endl;]
])]
,[ac_cgal=yes],[ac_cgal=no])
LDFLAGS="$LDFLAGS_SAVED"
export LDFLAGS
CPPFLAGS="$CPPFLAGS_SAVED"
export CPPFLAGS
LDFLAGS="$LDFLAGS_SAVED"
export LDFLAGS
if test $ac_cgal = yes ; then
break
fi
done
CPPFLAGS="$CPPFLAGS_SAVED"
export CPPFLAGS
if test $ac_cgal = yes ; then
AC_MSG_RESULT([yes])
break
else
AC_MSG_RESULT([no])
fi
if test $ac_cgal = yes ; then
AC_MSG_RESULT([yes])
break
else
AC_MSG_RESULT([no])
fi
done
AC_LANG_POP([C++])
if test $ac_cgal = yes ; then
AC_DEFINE(HAVE_CGAL,[1],[Indicates presence of CGAL library])
AC_SUBST(CGAL_CPPFLAGS)
AC_SUBST(CGAL_LDFLAGS)
AC_DEFINE(HAVE_CGAL,[1],[Indicates presence of CGAL library])
AC_SUBST(CGAL_CPPFLAGS)
AC_SUBST(CGAL_LDFLAGS)
# execute ACTION-IF-FOUND
ifelse([$1], , :, [$1])
else
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment