m4/lx_check_coin.m4
author Akos Ladanyi <ladanyi@tmit.bme.hu>
Fri, 29 May 2009 12:44:37 +0100
changeset 681 9c7639f3a741
parent 560 b53a9068e3e4
child 695 36857046492b
permissions -rw-r--r--
Minor CMake improvements

* Use the empty ELSE(), ENDIF(), ENDMACRO(), etc. syntax since this improves
readability and requires less typing.
* Use FIND_PACKAGE() instead of INCLUDE().
* Use the value of CMAKE_COMMAND variable instead of cmake, since this works
even if cmake is not in the PATH.
ladanyi@560
     1
AC_DEFUN([LX_CHECK_COIN],
ladanyi@560
     2
[
ladanyi@560
     3
  AC_ARG_WITH([coin],
ladanyi@560
     4
AS_HELP_STRING([--with-coin@<:@=PREFIX@:>@], [search for CLP under PREFIX or under the default search paths if PREFIX is not given @<:@default@:>@])
ladanyi@560
     5
AS_HELP_STRING([--without-coin], [disable checking for CLP]),
ladanyi@560
     6
              [], [with_coin=yes])
ladanyi@560
     7
ladanyi@560
     8
  AC_ARG_WITH([coin-includedir],
ladanyi@560
     9
AS_HELP_STRING([--with-coin-includedir=DIR], [search for CLP headers in DIR]),
ladanyi@560
    10
              [], [with_coin_includedir=no])
ladanyi@560
    11
ladanyi@560
    12
  AC_ARG_WITH([coin-libdir],
ladanyi@560
    13
AS_HELP_STRING([--with-coin-libdir=DIR], [search for CLP libraries in DIR]),
ladanyi@560
    14
              [], [with_coin_libdir=no])
ladanyi@560
    15
ladanyi@560
    16
  lx_clp_found=no
ladanyi@560
    17
  if test x"$with_coin" != x"no"; then
ladanyi@560
    18
    AC_MSG_CHECKING([for CLP])
ladanyi@560
    19
ladanyi@560
    20
    if test x"$with_coin_includedir" != x"no"; then
ladanyi@560
    21
      CLP_CXXFLAGS="-I$with_coin_includedir"
ladanyi@560
    22
    elif test x"$with_coin" != x"yes"; then
ladanyi@560
    23
      CLP_CXXFLAGS="-I$with_coin/include"
ladanyi@560
    24
    fi
ladanyi@560
    25
ladanyi@560
    26
    if test x"$with_coin_libdir" != x"no"; then
ladanyi@560
    27
      CLP_LDFLAGS="-L$with_coin_libdir"
ladanyi@560
    28
    elif test x"$with_coin" != x"yes"; then
ladanyi@560
    29
      CLP_LDFLAGS="-L$with_coin/lib"
ladanyi@560
    30
    fi
ladanyi@560
    31
    CLP_LIBS="-lClp -lCoinUtils -lm"
ladanyi@560
    32
ladanyi@560
    33
    lx_save_cxxflags="$CXXFLAGS"
ladanyi@560
    34
    lx_save_ldflags="$LDFLAGS"
ladanyi@560
    35
    lx_save_libs="$LIBS"
ladanyi@560
    36
    CXXFLAGS="$CLP_CXXFLAGS"
ladanyi@560
    37
    LDFLAGS="$CLP_LDFLAGS"
ladanyi@560
    38
    LIBS="$CLP_LIBS"
ladanyi@560
    39
ladanyi@560
    40
    lx_clp_test_prog='
ladanyi@560
    41
      #include <coin/ClpModel.hpp>
ladanyi@560
    42
ladanyi@560
    43
      int main(int argc, char** argv)
ladanyi@560
    44
      {
ladanyi@560
    45
        ClpModel clp;
ladanyi@560
    46
        return 0;
ladanyi@560
    47
      }'
ladanyi@560
    48
ladanyi@560
    49
    AC_LANG_PUSH(C++)
ladanyi@560
    50
    AC_LINK_IFELSE([$lx_clp_test_prog], [lx_clp_found=yes], [lx_clp_found=no])
ladanyi@560
    51
    AC_LANG_POP(C++)
ladanyi@560
    52
ladanyi@560
    53
    CXXFLAGS="$lx_save_cxxflags"
ladanyi@560
    54
    LDFLAGS="$lx_save_ldflags"
ladanyi@560
    55
    LIBS="$lx_save_libs"
ladanyi@560
    56
ladanyi@560
    57
    if test x"$lx_clp_found" = x"yes"; then
ladanyi@622
    58
      AC_DEFINE([LEMON_HAVE_CLP], [1], [Define to 1 if you have CLP.])
ladanyi@560
    59
      lx_lp_found=yes
ladanyi@622
    60
      AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.])
ladanyi@560
    61
      AC_MSG_RESULT([yes])
ladanyi@560
    62
    else
ladanyi@560
    63
      CLP_CXXFLAGS=""
ladanyi@560
    64
      CLP_LDFLAGS=""
ladanyi@560
    65
      CLP_LIBS=""
ladanyi@560
    66
      AC_MSG_RESULT([no])
ladanyi@560
    67
    fi
ladanyi@560
    68
  fi
ladanyi@560
    69
  CLP_LIBS="$CLP_LDFLAGS $CLP_LIBS"
ladanyi@560
    70
  AC_SUBST(CLP_CXXFLAGS)
ladanyi@560
    71
  AC_SUBST(CLP_LIBS)
ladanyi@560
    72
  AM_CONDITIONAL([HAVE_CLP], [test x"$lx_clp_found" = x"yes"])
ladanyi@560
    73
ladanyi@560
    74
ladanyi@560
    75
  lx_cbc_found=no
ladanyi@560
    76
  if test x"$lx_clp_found" = x"yes"; then
ladanyi@560
    77
    if test x"$with_coin" != x"no"; then
ladanyi@560
    78
      AC_MSG_CHECKING([for CBC])
ladanyi@560
    79
ladanyi@560
    80
      if test x"$with_coin_includedir" != x"no"; then
ladanyi@560
    81
        CBC_CXXFLAGS="-I$with_coin_includedir"
ladanyi@560
    82
      elif test x"$with_coin" != x"yes"; then
ladanyi@560
    83
        CBC_CXXFLAGS="-I$with_coin/include"
ladanyi@560
    84
      fi
ladanyi@560
    85
ladanyi@560
    86
      if test x"$with_coin_libdir" != x"no"; then
ladanyi@560
    87
        CBC_LDFLAGS="-L$with_coin_libdir"
ladanyi@560
    88
      elif test x"$with_coin" != x"yes"; then
ladanyi@560
    89
        CBC_LDFLAGS="-L$with_coin/lib"
ladanyi@560
    90
      fi
ladanyi@560
    91
      CBC_LIBS="-lOsi -lCbc -lOsiCbc -lCbcSolver -lClp -lOsiClp -lCoinUtils -lVol -lOsiVol -lCgl -lm -llapack -lblas"
ladanyi@560
    92
ladanyi@560
    93
      lx_save_cxxflags="$CXXFLAGS"
ladanyi@560
    94
      lx_save_ldflags="$LDFLAGS"
ladanyi@560
    95
      lx_save_libs="$LIBS"
ladanyi@560
    96
      CXXFLAGS="$CBC_CXXFLAGS"
ladanyi@560
    97
      LDFLAGS="$CBC_LDFLAGS"
ladanyi@560
    98
      LIBS="$CBC_LIBS"
ladanyi@560
    99
ladanyi@560
   100
      lx_cbc_test_prog='
ladanyi@560
   101
        #include <coin/CbcModel.hpp>
ladanyi@560
   102
ladanyi@560
   103
        int main(int argc, char** argv)
ladanyi@560
   104
        {
ladanyi@560
   105
          CbcModel cbc;
ladanyi@560
   106
          return 0;
ladanyi@560
   107
        }'
ladanyi@560
   108
ladanyi@560
   109
      AC_LANG_PUSH(C++)
ladanyi@560
   110
      AC_LINK_IFELSE([$lx_cbc_test_prog], [lx_cbc_found=yes], [lx_cbc_found=no])
ladanyi@560
   111
      AC_LANG_POP(C++)
ladanyi@560
   112
ladanyi@560
   113
      CXXFLAGS="$lx_save_cxxflags"
ladanyi@560
   114
      LDFLAGS="$lx_save_ldflags"
ladanyi@560
   115
      LIBS="$lx_save_libs"
ladanyi@560
   116
ladanyi@560
   117
      if test x"$lx_cbc_found" = x"yes"; then
ladanyi@622
   118
        AC_DEFINE([LEMON_HAVE_CBC], [1], [Define to 1 if you have CBC.])
ladanyi@560
   119
        lx_lp_found=yes
ladanyi@622
   120
        AC_DEFINE([LEMON_HAVE_LP], [1], [Define to 1 if you have any LP solver.])
ladanyi@560
   121
        lx_mip_found=yes
ladanyi@622
   122
        AC_DEFINE([LEMON_HAVE_MIP], [1], [Define to 1 if you have any MIP solver.])
ladanyi@560
   123
        AC_MSG_RESULT([yes])
ladanyi@560
   124
      else
ladanyi@560
   125
        CBC_CXXFLAGS=""
ladanyi@560
   126
        CBC_LDFLAGS=""
ladanyi@560
   127
        CBC_LIBS=""
ladanyi@560
   128
        AC_MSG_RESULT([no])
ladanyi@560
   129
      fi
ladanyi@560
   130
    fi
ladanyi@560
   131
  fi
ladanyi@560
   132
  CBC_LIBS="$CBC_LDFLAGS $CBC_LIBS"
ladanyi@560
   133
  AC_SUBST(CBC_CXXFLAGS)
ladanyi@560
   134
  AC_SUBST(CBC_LIBS)
ladanyi@560
   135
  AM_CONDITIONAL([HAVE_CBC], [test x"$lx_cbc_found" = x"yes"])
ladanyi@560
   136
])