config/lx_check_cplex.m4
author ladanyi
Tue, 14 Jun 2005 22:51:22 +0000
changeset 1490 fa2b73784343
child 1507 14ca1624e8e8
permissions -rw-r--r--
Added support for building deb packages.
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"
ladanyi@1489
    24
    fi
ladanyi@1489
    25
ladanyi@1489
    26
    if test x"$with_cplex_libdir" != x"no"; then
ladanyi@1489
    27
      CPLEX_LDFLAGS="-L$with_cplex_libdir"
ladanyi@1489
    28
    elif test x"$with_cplex" != x"yes"; then
ladanyi@1489
    29
      CPLEX_LDFLAGS="-L$with_cplex/lib"
ladanyi@1489
    30
    fi
ladanyi@1489
    31
    CPLEX_LIBS="-lcplex -lm -lpthread"
ladanyi@1489
    32
ladanyi@1489
    33
    lx_save_cxxflags="$CXXFLAGS"
ladanyi@1489
    34
    lx_save_ldflags="$LDFLAGS"
ladanyi@1489
    35
    lx_save_libs="$LIBS"
ladanyi@1489
    36
    CXXFLAGS="$CPLEX_CFLAGS"
ladanyi@1489
    37
    LDFLAGS="$CPLEX_LDFLAGS"
ladanyi@1489
    38
    LIBS="$CPLEX_LIBS"
ladanyi@1489
    39
ladanyi@1489
    40
    lx_cplex_test_prog='
ladanyi@1489
    41
      extern "C" {
ladanyi@1489
    42
      #include <ilcplex/cplex.h>
ladanyi@1489
    43
      }
ladanyi@1489
    44
ladanyi@1489
    45
      int main(int argc, char* argv[])
ladanyi@1489
    46
      {
ladanyi@1489
    47
        CPXENVptr env = NULL;
ladanyi@1489
    48
        return 0;
ladanyi@1489
    49
      }'
ladanyi@1489
    50
ladanyi@1489
    51
    AC_LANG_PUSH(C++)
ladanyi@1489
    52
    AC_LINK_IFELSE([$lx_cplex_test_prog], [lx_cplex_found=yes], [lx_cplex_found=no])
ladanyi@1489
    53
    AC_LANG_POP(C++)
ladanyi@1489
    54
ladanyi@1489
    55
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@1489
    56
    LDFLAGS="$lx_save_ldflags"
ladanyi@1489
    57
    LIBS="$lx_save_libs"
ladanyi@1489
    58
ladanyi@1489
    59
    if test x"$lx_cplex_found" = x"yes"; then
ladanyi@1489
    60
      AC_DEFINE([HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.])
ladanyi@1489
    61
      AC_MSG_RESULT([yes])
ladanyi@1489
    62
    else
ladanyi@1489
    63
      CPLEX_CFLAGS=""
ladanyi@1489
    64
      CPLEX_LDFLAGS=""
ladanyi@1489
    65
      CPLEX_LIBS=""
ladanyi@1489
    66
      AC_MSG_RESULT([no])
ladanyi@1489
    67
    fi
ladanyi@1489
    68
  fi
ladanyi@1489
    69
  CPLEX_LIBS="$CPLEX_LDFLAGS $CPLEX_LIBS"
ladanyi@1489
    70
  AC_SUBST(CPLEX_CFLAGS)
ladanyi@1489
    71
  AC_SUBST(CPLEX_LIBS)
ladanyi@1489
    72
  AM_CONDITIONAL([HAVE_CPLEX], [test x"$lx_cplex_found" = x"yes"])
ladanyi@1489
    73
])