# HG changeset patch # User Akos Ladanyi # Date 2009-04-23 08:29:50 # Node ID c3ce597c11aecffef8499114b46a4879bd1b6cdd # Parent ec817dfc2cb7833db46c225906d03260901ad83d FindCPLEX for CMake (#256) diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ INCLUDE(FindDoxygen) INCLUDE(FindGhostscript) FIND_PACKAGE(GLPK 4.33) +FIND_PACKAGE(CPLEX) ADD_DEFINITIONS(-DHAVE_CONFIG_H) diff --git a/cmake/FindCPLEX.cmake b/cmake/FindCPLEX.cmake new file mode 100644 --- /dev/null +++ b/cmake/FindCPLEX.cmake @@ -0,0 +1,27 @@ +FIND_PATH(CPLEX_INCLUDE_DIR + ilcplex/cplex.h + PATHS "C:/ILOG/CPLEX91/include") + +FIND_LIBRARY(CPLEX_LIBRARY + NAMES cplex91 + PATHS "C:/ILOG/CPLEX91/lib/msvc7/stat_mda") + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPLEX DEFAULT_MSG CPLEX_LIBRARY CPLEX_INCLUDE_DIR) + +FIND_PATH(CPLEX_BIN_DIR + cplex91.dll + PATHS "C:/ILOG/CPLEX91/bin/x86_win32") + +IF(CPLEX_FOUND) + SET(CPLEX_INCLUDE_DIRS ${CPLEX_INCLUDE_DIR}) + SET(CPLEX_LIBRARIES ${CPLEX_LIBRARY}) +ENDIF(CPLEX_FOUND) + +MARK_AS_ADVANCED(CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_BIN_DIR) + +IF(CPLEX_FOUND) + SET(HAVE_LP TRUE) + SET(HAVE_MIP TRUE) + SET(HAVE_CPLEX TRUE) +ENDIF(CPLEX_FOUND) diff --git a/lemon/CMakeLists.txt b/lemon/CMakeLists.txt --- a/lemon/CMakeLists.txt +++ b/lemon/CMakeLists.txt @@ -28,6 +28,11 @@ ENDIF(WIN32) ENDIF(HAVE_GLPK) +IF(HAVE_CPLEX) + SET(LEMON_SOURCES ${LEMON_SOURCES} cplex.cc) + INCLUDE_DIRECTORIES(${CPLEX_INCLUDE_DIRS}) +ENDIF(HAVE_CPLEX) + ADD_LIBRARY(lemon ${LEMON_SOURCES}) INSTALL( diff --git a/lemon/config.h.cmake b/lemon/config.h.cmake --- a/lemon/config.h.cmake +++ b/lemon/config.h.cmake @@ -2,3 +2,4 @@ #cmakedefine HAVE_LP 1 #cmakedefine HAVE_MIP 1 #cmakedefine HAVE_GLPK 1 +#cmakedefine HAVE_CPLEX 1 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -38,9 +38,14 @@ IF(HAVE_LP) ADD_EXECUTABLE(lp_test lp_test.cc) + SET(LP_TEST_LIBS lemon) IF(HAVE_GLPK) - TARGET_LINK_LIBRARIES(lp_test lemon ${GLPK_LIBRARIES}) + SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES}) ENDIF(HAVE_GLPK) + IF(HAVE_CPLEX) + SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES}) + ENDIF(HAVE_CPLEX) + TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS}) ADD_TEST(lp_test lp_test) IF(WIN32 AND HAVE_GLPK) @@ -52,13 +57,25 @@ COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} ) ENDIF(WIN32 AND HAVE_GLPK) + IF(WIN32 AND HAVE_CPLEX) + GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION) + GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) + ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD + COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH} + ) + ENDIF(WIN32 AND HAVE_CPLEX) ENDIF(HAVE_LP) IF(HAVE_MIP) ADD_EXECUTABLE(mip_test mip_test.cc) + SET(MIP_TEST_LIBS lemon) IF(HAVE_GLPK) - TARGET_LINK_LIBRARIES(mip_test lemon ${GLPK_LIBRARIES}) + SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES}) ENDIF(HAVE_GLPK) + IF(HAVE_CPLEX) + SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES}) + ENDIF(HAVE_CPLEX) + TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS}) ADD_TEST(mip_test mip_test) IF(WIN32 AND HAVE_GLPK) @@ -70,6 +87,13 @@ COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH} ) ENDIF(WIN32 AND HAVE_GLPK) + IF(WIN32 AND HAVE_CPLEX) + GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION) + GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH) + ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD + COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH} + ) + ENDIF(WIN32 AND HAVE_CPLEX) ENDIF(HAVE_MIP) FOREACH(TEST_NAME ${TESTS})