config/lx_check_cplex.m4
changeset 1489 f7e9cc3bc2da
child 1507 14ca1624e8e8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/config/lx_check_cplex.m4	Tue Jun 14 20:01:41 2005 +0000
     1.3 @@ -0,0 +1,73 @@
     1.4 +AC_DEFUN([LX_CHECK_CPLEX],
     1.5 +[
     1.6 +  AC_ARG_WITH([cplex],
     1.7 +AS_HELP_STRING([--with-cplex@<:@=PREFIX@:>@], [search for CPLEX under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
     1.8 +AS_HELP_STRING([--without-cplex], [disable checking for CPLEX]),
     1.9 +              [], [with_cplex=yes])
    1.10 +
    1.11 +  AC_ARG_WITH([cplex-includedir],
    1.12 +AS_HELP_STRING([--with-cplex-includedir=DIR], [search for CPLEX headers in DIR]),
    1.13 +              [], [with_cplex_includedir=no])
    1.14 +
    1.15 +  AC_ARG_WITH([cplex-libdir],
    1.16 +AS_HELP_STRING([--with-cplex-libdir=DIR], [search for CPLEX libraries in DIR]),
    1.17 +              [], [with_cplex_libdir=no])
    1.18 +
    1.19 +  lx_cplex_found=no
    1.20 +  if test x"$with_cplex" != x"no"; then
    1.21 +    AC_MSG_CHECKING([for CPLEX])
    1.22 +
    1.23 +    if test x"$with_cplex_includedir" != x"no"; then
    1.24 +      CPLEX_CFLAGS="-I$with_cplex_includedir"
    1.25 +    elif test x"$with_cplex" != x"yes"; then
    1.26 +      CPLEX_CFLAGS="-I$with_cplex/include"
    1.27 +    fi
    1.28 +
    1.29 +    if test x"$with_cplex_libdir" != x"no"; then
    1.30 +      CPLEX_LDFLAGS="-L$with_cplex_libdir"
    1.31 +    elif test x"$with_cplex" != x"yes"; then
    1.32 +      CPLEX_LDFLAGS="-L$with_cplex/lib"
    1.33 +    fi
    1.34 +    CPLEX_LIBS="-lcplex -lm -lpthread"
    1.35 +
    1.36 +    lx_save_cxxflags="$CXXFLAGS"
    1.37 +    lx_save_ldflags="$LDFLAGS"
    1.38 +    lx_save_libs="$LIBS"
    1.39 +    CXXFLAGS="$CPLEX_CFLAGS"
    1.40 +    LDFLAGS="$CPLEX_LDFLAGS"
    1.41 +    LIBS="$CPLEX_LIBS"
    1.42 +
    1.43 +    lx_cplex_test_prog='
    1.44 +      extern "C" {
    1.45 +      #include <ilcplex/cplex.h>
    1.46 +      }
    1.47 +
    1.48 +      int main(int argc, char* argv[])
    1.49 +      {
    1.50 +        CPXENVptr env = NULL;
    1.51 +        return 0;
    1.52 +      }'
    1.53 +
    1.54 +    AC_LANG_PUSH(C++)
    1.55 +    AC_LINK_IFELSE([$lx_cplex_test_prog], [lx_cplex_found=yes], [lx_cplex_found=no])
    1.56 +    AC_LANG_POP(C++)
    1.57 +
    1.58 +    CXXFLAGS="$lx_save_cxxflags"
    1.59 +    LDFLAGS="$lx_save_ldflags"
    1.60 +    LIBS="$lx_save_libs"
    1.61 +
    1.62 +    if test x"$lx_cplex_found" = x"yes"; then
    1.63 +      AC_DEFINE([HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.])
    1.64 +      AC_MSG_RESULT([yes])
    1.65 +    else
    1.66 +      CPLEX_CFLAGS=""
    1.67 +      CPLEX_LDFLAGS=""
    1.68 +      CPLEX_LIBS=""
    1.69 +      AC_MSG_RESULT([no])
    1.70 +    fi
    1.71 +  fi
    1.72 +  CPLEX_LIBS="$CPLEX_LDFLAGS $CPLEX_LIBS"
    1.73 +  AC_SUBST(CPLEX_CFLAGS)
    1.74 +  AC_SUBST(CPLEX_LIBS)
    1.75 +  AM_CONDITIONAL([HAVE_CPLEX], [test x"$lx_cplex_found" = x"yes"])
    1.76 +])