m4/lx_check_cbc.m4
changeset 614 3314f58e7b25
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/m4/lx_check_cbc.m4	Wed Apr 01 22:58:58 2009 +0200
     1.3 @@ -0,0 +1,73 @@
     1.4 +AC_DEFUN([LX_CHECK_CBC],
     1.5 +[
     1.6 +  AC_ARG_WITH([cbc],
     1.7 +AS_HELP_STRING([--with-cbc@<:@=PREFIX@:>@], [search for CBC under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
     1.8 +AS_HELP_STRING([--without-cbc], [disable checking for CBC]),
     1.9 +              [], [with_cbc=yes])
    1.10 +
    1.11 +  AC_ARG_WITH([cbc-includedir],
    1.12 +AS_HELP_STRING([--with-cbc-includedir=DIR], [search for CBC headers in DIR]),
    1.13 +              [], [with_cbc_includedir=no])
    1.14 +
    1.15 +  AC_ARG_WITH([cbc-libdir],
    1.16 +AS_HELP_STRING([--with-cbc-libdir=DIR], [search for CBC libraries in DIR]),
    1.17 +              [], [with_cbc_libdir=no])
    1.18 +
    1.19 +  lx_cbc_found=no
    1.20 +  if test x"$with_cbc" != x"no"; then
    1.21 +    AC_MSG_CHECKING([for CBC])
    1.22 +
    1.23 +    if test x"$with_cbc_includedir" != x"no"; then
    1.24 +      CBC_CXXFLAGS="-I$with_cbc_includedir"
    1.25 +    elif test x"$with_cbc" != x"yes"; then
    1.26 +      CBC_CXXFLAGS="-I$with_cbc/include"
    1.27 +    fi
    1.28 +
    1.29 +    if test x"$with_cbc_libdir" != x"no"; then
    1.30 +      CBC_LDFLAGS="-L$with_cbc_libdir"
    1.31 +    elif test x"$with_cbc" != x"yes"; then
    1.32 +      CBC_LDFLAGS="-L$with_cbc/lib"
    1.33 +    fi
    1.34 +    CBC_LIBS="-lOsi -lCbc -lOsiCbc -lCbcSolver -lClp -lOsiClp -lCoinUtils -lVol -lOsiVol -lCgl -lm -llapack -lblas"
    1.35 +
    1.36 +    lx_save_cxxflags="$CXXFLAGS"
    1.37 +    lx_save_ldflags="$LDFLAGS"
    1.38 +    lx_save_libs="$LIBS"
    1.39 +    CXXFLAGS="$CBC_CXXFLAGS"
    1.40 +    LDFLAGS="$CBC_LDFLAGS"
    1.41 +    LIBS="$CBC_LIBS"
    1.42 +
    1.43 +    lx_cbc_test_prog='
    1.44 +      #include <coin/CbcModel.hpp>
    1.45 +
    1.46 +      int main(int argc, char** argv)
    1.47 +      {
    1.48 +        CbcModel cbc;
    1.49 +        return 0;
    1.50 +      }'
    1.51 +
    1.52 +    AC_LANG_PUSH(C++)
    1.53 +    AC_LINK_IFELSE([$lx_cbc_test_prog], [lx_cbc_found=yes], [lx_cbc_found=no])
    1.54 +    AC_LANG_POP(C++)
    1.55 +
    1.56 +    CXXFLAGS="$lx_save_cxxflags"
    1.57 +    LDFLAGS="$lx_save_ldflags"
    1.58 +    LIBS="$lx_save_libs"
    1.59 +
    1.60 +    if test x"$lx_cbc_found" = x"yes"; then
    1.61 +      AC_DEFINE([HAVE_CBC], [1], [Define to 1 if you have CBC.])
    1.62 +      lx_lp_found=yes
    1.63 +      AC_DEFINE([HAVE_LP], [1], [Define to 1 if you have any LP solver.])
    1.64 +      AC_MSG_RESULT([yes])
    1.65 +    else
    1.66 +      CBC_CXXFLAGS=""
    1.67 +      CBC_LDFLAGS=""
    1.68 +      CBC_LIBS=""
    1.69 +      AC_MSG_RESULT([no])
    1.70 +    fi
    1.71 +  fi
    1.72 +  CBC_LIBS="$CBC_LDFLAGS $CBC_LIBS"
    1.73 +  AC_SUBST(CBC_CXXFLAGS)
    1.74 +  AC_SUBST(CBC_LIBS)
    1.75 +  AM_CONDITIONAL([HAVE_CBC], [test x"$lx_cbc_found" = x"yes"])
    1.76 +])