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