config/lx_check_cplex.m4
author alpar
Thu, 17 Nov 2005 10:16:29 +0000
changeset 1812 a6f019fa6e7a
parent 1489 f7e9cc3bc2da
permissions -rw-r--r--
split(Edge) member function added.
ladanyi@1489
     1
AC_DEFUN([LX_CHECK_CPLEX],
ladanyi@1489
     2
[
ladanyi@1489
     3
  AC_ARG_WITH([cplex],
ladanyi@1489
     4
AS_HELP_STRING([--with-cplex@<:@=PREFIX@:>@], [search for CPLEX under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
ladanyi@1489
     5
AS_HELP_STRING([--without-cplex], [disable checking for CPLEX]),
ladanyi@1489
     6
              [], [with_cplex=yes])
ladanyi@1489
     7
ladanyi@1489
     8
  AC_ARG_WITH([cplex-includedir],
ladanyi@1489
     9
AS_HELP_STRING([--with-cplex-includedir=DIR], [search for CPLEX headers in DIR]),
ladanyi@1489
    10
              [], [with_cplex_includedir=no])
ladanyi@1489
    11
ladanyi@1489
    12
  AC_ARG_WITH([cplex-libdir],
ladanyi@1489
    13
AS_HELP_STRING([--with-cplex-libdir=DIR], [search for CPLEX libraries in DIR]),
ladanyi@1489
    14
              [], [with_cplex_libdir=no])
ladanyi@1489
    15
ladanyi@1489
    16
  lx_cplex_found=no
ladanyi@1489
    17
  if test x"$with_cplex" != x"no"; then
ladanyi@1489
    18
    AC_MSG_CHECKING([for CPLEX])
ladanyi@1489
    19
ladanyi@1489
    20
    if test x"$with_cplex_includedir" != x"no"; then
ladanyi@1489
    21
      CPLEX_CFLAGS="-I$with_cplex_includedir"
ladanyi@1489
    22
    elif test x"$with_cplex" != x"yes"; then
ladanyi@1489
    23
      CPLEX_CFLAGS="-I$with_cplex/include"
klao@1507
    24
    elif test x"$CPLEX_INCLUDEDIR" != x; then
klao@1507
    25
      CPLEX_CFLAGS="-I$CPLEX_INCLUDEDIR"
ladanyi@1489
    26
    fi
ladanyi@1489
    27
ladanyi@1489
    28
    if test x"$with_cplex_libdir" != x"no"; then
ladanyi@1489
    29
      CPLEX_LDFLAGS="-L$with_cplex_libdir"
ladanyi@1489
    30
    elif test x"$with_cplex" != x"yes"; then
ladanyi@1489
    31
      CPLEX_LDFLAGS="-L$with_cplex/lib"
klao@1507
    32
    elif test x"$CPLEX_LIBDIR" != x; then
klao@1507
    33
      CPLEX_LDFLAGS="-L$CPLEX_LIBDIR"
ladanyi@1489
    34
    fi
ladanyi@1489
    35
    CPLEX_LIBS="-lcplex -lm -lpthread"
ladanyi@1489
    36
ladanyi@1489
    37
    lx_save_cxxflags="$CXXFLAGS"
ladanyi@1489
    38
    lx_save_ldflags="$LDFLAGS"
ladanyi@1489
    39
    lx_save_libs="$LIBS"
ladanyi@1489
    40
    CXXFLAGS="$CPLEX_CFLAGS"
ladanyi@1489
    41
    LDFLAGS="$CPLEX_LDFLAGS"
ladanyi@1489
    42
    LIBS="$CPLEX_LIBS"
ladanyi@1489
    43
ladanyi@1489
    44
    lx_cplex_test_prog='
ladanyi@1489
    45
      extern "C" {
ladanyi@1489
    46
      #include <ilcplex/cplex.h>
ladanyi@1489
    47
      }
ladanyi@1489
    48
ladanyi@1489
    49
      int main(int argc, char* argv[])
ladanyi@1489
    50
      {
ladanyi@1489
    51
        CPXENVptr env = NULL;
ladanyi@1489
    52
        return 0;
ladanyi@1489
    53
      }'
ladanyi@1489
    54
ladanyi@1489
    55
    AC_LANG_PUSH(C++)
ladanyi@1489
    56
    AC_LINK_IFELSE([$lx_cplex_test_prog], [lx_cplex_found=yes], [lx_cplex_found=no])
ladanyi@1489
    57
    AC_LANG_POP(C++)
ladanyi@1489
    58
ladanyi@1489
    59
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@1489
    60
    LDFLAGS="$lx_save_ldflags"
ladanyi@1489
    61
    LIBS="$lx_save_libs"
ladanyi@1489
    62
ladanyi@1489
    63
    if test x"$lx_cplex_found" = x"yes"; then
ladanyi@1489
    64
      AC_DEFINE([HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.])
ladanyi@1489
    65
      AC_MSG_RESULT([yes])
ladanyi@1489
    66
    else
ladanyi@1489
    67
      CPLEX_CFLAGS=""
ladanyi@1489
    68
      CPLEX_LDFLAGS=""
ladanyi@1489
    69
      CPLEX_LIBS=""
ladanyi@1489
    70
      AC_MSG_RESULT([no])
ladanyi@1489
    71
    fi
ladanyi@1489
    72
  fi
ladanyi@1489
    73
  CPLEX_LIBS="$CPLEX_LDFLAGS $CPLEX_LIBS"
ladanyi@1489
    74
  AC_SUBST(CPLEX_CFLAGS)
ladanyi@1489
    75
  AC_SUBST(CPLEX_LIBS)
ladanyi@1489
    76
  AM_CONDITIONAL([HAVE_CPLEX], [test x"$lx_cplex_found" = x"yes"])
ladanyi@1489
    77
])