AC_DEFUN([LX_CHECK_CPLEX],
AS_HELP_STRING([--with-cplex@<:@=PREFIX@:>@], [search for CPLEX under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
AS_HELP_STRING([--without-cplex], [disable checking for CPLEX]),
AC_ARG_WITH([cplex-includedir],
AS_HELP_STRING([--with-cplex-includedir=DIR], [search for CPLEX headers in DIR]),
[], [with_cplex_includedir=no])
AC_ARG_WITH([cplex-libdir],
AS_HELP_STRING([--with-cplex-libdir=DIR], [search for CPLEX libraries in DIR]),
[], [with_cplex_libdir=no])
if test x"$with_cplex" != x"no"; then
AC_MSG_CHECKING([for CPLEX])
if test x"$with_cplex_includedir" != x"no"; then
CPLEX_CFLAGS="-I$with_cplex_includedir"
elif test x"$with_cplex" != x"yes"; then
CPLEX_CFLAGS="-I$with_cplex/include"
elif test x"$CPLEX_INCLUDEDIR" != x; then
CPLEX_CFLAGS="-I$CPLEX_INCLUDEDIR"
if test x"$with_cplex_libdir" != x"no"; then
CPLEX_LDFLAGS="-L$with_cplex_libdir"
elif test x"$with_cplex" != x"yes"; then
CPLEX_LDFLAGS="-L$with_cplex/lib"
elif test x"$CPLEX_LIBDIR" != x; then
CPLEX_LDFLAGS="-L$CPLEX_LIBDIR"
CPLEX_LIBS="-lcplex -lm -lpthread"
lx_save_cxxflags="$CXXFLAGS"
lx_save_ldflags="$LDFLAGS"
#include <ilcplex/cplex.h>
int main(int argc, char** argv)
AC_LINK_IFELSE([$lx_cplex_test_prog], [lx_cplex_found=yes], [lx_cplex_found=no])
CXXFLAGS="$lx_save_cxxflags"
LDFLAGS="$lx_save_ldflags"
if test x"$lx_cplex_found" = x"yes"; then
AC_DEFINE([LEMON_HAVE_CPLEX], [1], [Define to 1 if you have CPLEX.])
AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.])
AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.])
CPLEX_LIBS="$CPLEX_LDFLAGS $CPLEX_LIBS"
AM_CONDITIONAL([HAVE_CPLEX], [test x"$lx_cplex_found" = x"yes"])