m4/lx_check_cplex.m4
author ladanyi
Tue, 04 Jul 2006 10:06:24 +0000
branchlemon-1.0
changeset 2647 aa4a3a04fb4c
permissions -rw-r--r--
Copied the autotools files from trunk and commented them out so that configure and make succeeds.
ladanyi@2647
     1
AC_DEFUN([LX_CHECK_CPLEX],
ladanyi@2647
     2
[
ladanyi@2647
     3
  AC_ARG_WITH([cplex],
ladanyi@2647
     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@2647
     5
AS_HELP_STRING([--without-cplex], [disable checking for CPLEX]),
ladanyi@2647
     6
              [], [with_cplex=yes])
ladanyi@2647
     7
ladanyi@2647
     8
  AC_ARG_WITH([cplex-includedir],
ladanyi@2647
     9
AS_HELP_STRING([--with-cplex-includedir=DIR], [search for CPLEX headers in DIR]),
ladanyi@2647
    10
              [], [with_cplex_includedir=no])
ladanyi@2647
    11
ladanyi@2647
    12
  AC_ARG_WITH([cplex-libdir],
ladanyi@2647
    13
AS_HELP_STRING([--with-cplex-libdir=DIR], [search for CPLEX libraries in DIR]),
ladanyi@2647
    14
              [], [with_cplex_libdir=no])
ladanyi@2647
    15
ladanyi@2647
    16
  lx_cplex_found=no
ladanyi@2647
    17
  if test x"$with_cplex" != x"no"; then
ladanyi@2647
    18
    AC_MSG_CHECKING([for CPLEX])
ladanyi@2647
    19
ladanyi@2647
    20
    if test x"$with_cplex_includedir" != x"no"; then
ladanyi@2647
    21
      CPLEX_CFLAGS="-I$with_cplex_includedir"
ladanyi@2647
    22
    elif test x"$with_cplex" != x"yes"; then
ladanyi@2647
    23
      CPLEX_CFLAGS="-I$with_cplex/include"
ladanyi@2647
    24
    elif test x"$CPLEX_INCLUDEDIR" != x; then
ladanyi@2647
    25
      CPLEX_CFLAGS="-I$CPLEX_INCLUDEDIR"
ladanyi@2647
    26
    fi
ladanyi@2647
    27
ladanyi@2647
    28
    if test x"$with_cplex_libdir" != x"no"; then
ladanyi@2647
    29
      CPLEX_LDFLAGS="-L$with_cplex_libdir"
ladanyi@2647
    30
    elif test x"$with_cplex" != x"yes"; then
ladanyi@2647
    31
      CPLEX_LDFLAGS="-L$with_cplex/lib"
ladanyi@2647
    32
    elif test x"$CPLEX_LIBDIR" != x; then
ladanyi@2647
    33
      CPLEX_LDFLAGS="-L$CPLEX_LIBDIR"
ladanyi@2647
    34
    fi
ladanyi@2647
    35
    CPLEX_LIBS="-lcplex -lm -lpthread"
ladanyi@2647
    36
ladanyi@2647
    37
    lx_save_cxxflags="$CXXFLAGS"
ladanyi@2647
    38
    lx_save_ldflags="$LDFLAGS"
ladanyi@2647
    39
    lx_save_libs="$LIBS"
ladanyi@2647
    40
    CXXFLAGS="$CPLEX_CFLAGS"
ladanyi@2647
    41
    LDFLAGS="$CPLEX_LDFLAGS"
ladanyi@2647
    42
    LIBS="$CPLEX_LIBS"
ladanyi@2647
    43
ladanyi@2647
    44
    lx_cplex_test_prog='
ladanyi@2647
    45
      extern "C" {
ladanyi@2647
    46
      #include <ilcplex/cplex.h>
ladanyi@2647
    47
      }
ladanyi@2647
    48
ladanyi@2647
    49
      int main(int argc, char* argv[])
ladanyi@2647
    50
      {
ladanyi@2647
    51
        CPXENVptr env = NULL;
ladanyi@2647
    52
        return 0;
ladanyi@2647
    53
      }'
ladanyi@2647
    54
ladanyi@2647
    55
    AC_LANG_PUSH(C++)
ladanyi@2647
    56
    AC_LINK_IFELSE([$lx_cplex_test_prog], [lx_cplex_found=yes], [lx_cplex_found=no])
ladanyi@2647
    57
    AC_LANG_POP(C++)
ladanyi@2647
    58
ladanyi@2647
    59
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@2647
    60
    LDFLAGS="$lx_save_ldflags"
ladanyi@2647
    61
    LIBS="$lx_save_libs"
ladanyi@2647
    62
ladanyi@2647
    63
    if test x"$lx_cplex_found" = x"yes"; then
ladanyi@2647
    64
      AC_DEFINE([HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.])
ladanyi@2647
    65
      AC_MSG_RESULT([yes])
ladanyi@2647
    66
    else
ladanyi@2647
    67
      CPLEX_CFLAGS=""
ladanyi@2647
    68
      CPLEX_LDFLAGS=""
ladanyi@2647
    69
      CPLEX_LIBS=""
ladanyi@2647
    70
      AC_MSG_RESULT([no])
ladanyi@2647
    71
    fi
ladanyi@2647
    72
  fi
ladanyi@2647
    73
  CPLEX_LIBS="$CPLEX_LDFLAGS $CPLEX_LIBS"
ladanyi@2647
    74
  AC_SUBST(CPLEX_CFLAGS)
ladanyi@2647
    75
  AC_SUBST(CPLEX_LIBS)
ladanyi@2647
    76
  AM_CONDITIONAL([HAVE_CPLEX], [test x"$lx_cplex_found" = x"yes"])
ladanyi@2647
    77
])