COIN-OR::LEMON - Graph Library

Ticket #256: 002-cplex-cmake.patch

File 002-cplex-cmake.patch, 3.7 KB (added by Akos Ladanyi, 16 years ago)

c3ce597c11ae

  • CMakeLists.txt

    # HG changeset patch
    # User Akos Ladanyi <ladanyi@tmit.bme.hu>
    # Date 1240468190 -3600
    # Node ID c3ce597c11aecffef8499114b46a4879bd1b6cdd
    # Parent  ec817dfc2cb7833db46c225906d03260901ad83d
    FindCPLEX for CMake (#256)
    
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    a b  
    1414INCLUDE(FindDoxygen)
    1515INCLUDE(FindGhostscript)
    1616FIND_PACKAGE(GLPK 4.33)
     17FIND_PACKAGE(CPLEX)
    1718
    1819ADD_DEFINITIONS(-DHAVE_CONFIG_H)
    1920
  • new file cmake/FindCPLEX.cmake

    diff --git a/cmake/FindCPLEX.cmake b/cmake/FindCPLEX.cmake
    new file mode 100644
    - +  
     1FIND_PATH(CPLEX_INCLUDE_DIR
     2  ilcplex/cplex.h
     3  PATHS "C:/ILOG/CPLEX91/include")
     4
     5FIND_LIBRARY(CPLEX_LIBRARY
     6  NAMES cplex91
     7  PATHS "C:/ILOG/CPLEX91/lib/msvc7/stat_mda")
     8
     9INCLUDE(FindPackageHandleStandardArgs)
     10FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPLEX DEFAULT_MSG CPLEX_LIBRARY CPLEX_INCLUDE_DIR)
     11
     12FIND_PATH(CPLEX_BIN_DIR
     13  cplex91.dll
     14  PATHS "C:/ILOG/CPLEX91/bin/x86_win32")
     15
     16IF(CPLEX_FOUND)
     17  SET(CPLEX_INCLUDE_DIRS ${CPLEX_INCLUDE_DIR})
     18  SET(CPLEX_LIBRARIES ${CPLEX_LIBRARY})
     19ENDIF(CPLEX_FOUND)
     20
     21MARK_AS_ADVANCED(CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_BIN_DIR)
     22
     23IF(CPLEX_FOUND)
     24  SET(HAVE_LP TRUE)
     25  SET(HAVE_MIP TRUE)
     26  SET(HAVE_CPLEX TRUE)
     27ENDIF(CPLEX_FOUND)
  • lemon/CMakeLists.txt

    diff --git a/lemon/CMakeLists.txt b/lemon/CMakeLists.txt
    a b  
    2828  ENDIF(WIN32)
    2929ENDIF(HAVE_GLPK)
    3030
     31IF(HAVE_CPLEX)
     32  SET(LEMON_SOURCES ${LEMON_SOURCES} cplex.cc)
     33  INCLUDE_DIRECTORIES(${CPLEX_INCLUDE_DIRS})
     34ENDIF(HAVE_CPLEX)
     35
    3136ADD_LIBRARY(lemon ${LEMON_SOURCES})
    3237
    3338INSTALL(
  • lemon/config.h.cmake

    diff --git a/lemon/config.h.cmake b/lemon/config.h.cmake
    a b  
    22#cmakedefine HAVE_LP 1
    33#cmakedefine HAVE_MIP 1
    44#cmakedefine HAVE_GLPK 1
     5#cmakedefine HAVE_CPLEX 1
  • test/CMakeLists.txt

    diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
    a b  
    3838
    3939IF(HAVE_LP)
    4040  ADD_EXECUTABLE(lp_test lp_test.cc)
     41  SET(LP_TEST_LIBS lemon)
    4142  IF(HAVE_GLPK)
    42     TARGET_LINK_LIBRARIES(lp_test lemon ${GLPK_LIBRARIES})
     43    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES})
    4344  ENDIF(HAVE_GLPK)
     45  IF(HAVE_CPLEX)
     46    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES})
     47  ENDIF(HAVE_CPLEX)
     48  TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS})
    4449  ADD_TEST(lp_test lp_test)
    4550
    4651  IF(WIN32 AND HAVE_GLPK)
     
    5257      COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
    5358    )
    5459  ENDIF(WIN32 AND HAVE_GLPK)
     60  IF(WIN32 AND HAVE_CPLEX)
     61    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
     62    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     63    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
     64      COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
     65    )
     66  ENDIF(WIN32 AND HAVE_CPLEX)
    5567ENDIF(HAVE_LP)
    5668
    5769IF(HAVE_MIP)
    5870  ADD_EXECUTABLE(mip_test mip_test.cc)
     71  SET(MIP_TEST_LIBS lemon)
    5972  IF(HAVE_GLPK)
    60     TARGET_LINK_LIBRARIES(mip_test lemon ${GLPK_LIBRARIES})
     73    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES})
    6174  ENDIF(HAVE_GLPK)
     75  IF(HAVE_CPLEX)
     76    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES})
     77  ENDIF(HAVE_CPLEX)
     78  TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS})
    6279  ADD_TEST(mip_test mip_test)
    6380
    6481  IF(WIN32 AND HAVE_GLPK)
     
    7087      COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
    7188    )
    7289  ENDIF(WIN32 AND HAVE_GLPK)
     90  IF(WIN32 AND HAVE_CPLEX)
     91    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
     92    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     93    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
     94      COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
     95    )
     96  ENDIF(WIN32 AND HAVE_CPLEX)
    7397ENDIF(HAVE_MIP)
    7498
    7599FOREACH(TEST_NAME ${TESTS})