File: ax_lib_cgal_core.m4

package info (click to toggle)
graph-tool 2.45%2Bds-10
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 27,640 kB
  • sloc: cpp: 72,219; python: 26,938; makefile: 802; xml: 101; sh: 29
file content (127 lines) | stat: -rw-r--r-- 4,230 bytes parent folder | download | duplicates (2)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# ===========================================================================
#     https://www.gnu.org/software/autoconf-archive/ax_lib_cgal_core.html
# ===========================================================================
#
# SYNOPSIS
#
#   AX_LIB_CGAL_CORE([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# DESCRIPTION
#
#   Test for the CGAL_Core library.
#
#   By using the "--with-cgal=" option, define a special installation
#   directory. If CGAL is not found there, the script will fail immediately.
#   Otherwise, $CGAL_HOME is searched, then standard system locations.
#
#   NOTE: This script depends on BOOST_CPPFLAGS, so be sure to run
#   AX_BOOST_BASE in advance.
#
#   This macro calls:
#
#     AC_SUBST(CGAL_CPPFLAGS)
#     AC_SUBST(CGAL_LDFLAGS)
#
#   And sets:
#
#     HAVE_CGAL
#
# LICENSE
#
#   Copyright (c) 2010 Sebastian Hegler <sebastian.hegler@tu-dresden.de>
#
#   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. This file is offered as-is, without any
#   warranty.

#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']
)

AC_LANG_PUSH([C++])

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

        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 $BOOST_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])

           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
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)
        # execute ACTION-IF-FOUND
        ifelse([$1], , :, [$1])
else
        # execute ACTION-IF-NOT-FOUND
        ifelse([$2], , :, [$2])
fi

])