FindCPLEX for CMake (#256)
authorAkos Ladanyi <ladanyi@tmit.bme.hu>
Thu, 23 Apr 2009 07:29:50 +0100
changeset 667c3ce597c11ae
parent 666 ec817dfc2cb7
child 668 b536eaacb39b
FindCPLEX for CMake (#256)
CMakeLists.txt
cmake/FindCPLEX.cmake
lemon/CMakeLists.txt
lemon/config.h.cmake
test/CMakeLists.txt
     1.1 --- a/CMakeLists.txt	Thu Apr 23 07:28:56 2009 +0100
     1.2 +++ b/CMakeLists.txt	Thu Apr 23 07:29:50 2009 +0100
     1.3 @@ -14,6 +14,7 @@
     1.4  INCLUDE(FindDoxygen)
     1.5  INCLUDE(FindGhostscript)
     1.6  FIND_PACKAGE(GLPK 4.33)
     1.7 +FIND_PACKAGE(CPLEX)
     1.8  
     1.9  ADD_DEFINITIONS(-DHAVE_CONFIG_H)
    1.10  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/cmake/FindCPLEX.cmake	Thu Apr 23 07:29:50 2009 +0100
     2.3 @@ -0,0 +1,27 @@
     2.4 +FIND_PATH(CPLEX_INCLUDE_DIR
     2.5 +  ilcplex/cplex.h
     2.6 +  PATHS "C:/ILOG/CPLEX91/include")
     2.7 +
     2.8 +FIND_LIBRARY(CPLEX_LIBRARY
     2.9 +  NAMES cplex91
    2.10 +  PATHS "C:/ILOG/CPLEX91/lib/msvc7/stat_mda")
    2.11 +
    2.12 +INCLUDE(FindPackageHandleStandardArgs)
    2.13 +FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPLEX DEFAULT_MSG CPLEX_LIBRARY CPLEX_INCLUDE_DIR)
    2.14 +
    2.15 +FIND_PATH(CPLEX_BIN_DIR
    2.16 +  cplex91.dll
    2.17 +  PATHS "C:/ILOG/CPLEX91/bin/x86_win32")
    2.18 +
    2.19 +IF(CPLEX_FOUND)
    2.20 +  SET(CPLEX_INCLUDE_DIRS ${CPLEX_INCLUDE_DIR})
    2.21 +  SET(CPLEX_LIBRARIES ${CPLEX_LIBRARY})
    2.22 +ENDIF(CPLEX_FOUND)
    2.23 +
    2.24 +MARK_AS_ADVANCED(CPLEX_LIBRARY CPLEX_INCLUDE_DIR CPLEX_BIN_DIR)
    2.25 +
    2.26 +IF(CPLEX_FOUND)
    2.27 +  SET(HAVE_LP TRUE)
    2.28 +  SET(HAVE_MIP TRUE)
    2.29 +  SET(HAVE_CPLEX TRUE)
    2.30 +ENDIF(CPLEX_FOUND)
     3.1 --- a/lemon/CMakeLists.txt	Thu Apr 23 07:28:56 2009 +0100
     3.2 +++ b/lemon/CMakeLists.txt	Thu Apr 23 07:29:50 2009 +0100
     3.3 @@ -28,6 +28,11 @@
     3.4    ENDIF(WIN32)
     3.5  ENDIF(HAVE_GLPK)
     3.6  
     3.7 +IF(HAVE_CPLEX)
     3.8 +  SET(LEMON_SOURCES ${LEMON_SOURCES} cplex.cc)
     3.9 +  INCLUDE_DIRECTORIES(${CPLEX_INCLUDE_DIRS})
    3.10 +ENDIF(HAVE_CPLEX)
    3.11 +
    3.12  ADD_LIBRARY(lemon ${LEMON_SOURCES})
    3.13  
    3.14  INSTALL(
     4.1 --- a/lemon/config.h.cmake	Thu Apr 23 07:28:56 2009 +0100
     4.2 +++ b/lemon/config.h.cmake	Thu Apr 23 07:29:50 2009 +0100
     4.3 @@ -2,3 +2,4 @@
     4.4  #cmakedefine HAVE_LP 1
     4.5  #cmakedefine HAVE_MIP 1
     4.6  #cmakedefine HAVE_GLPK 1
     4.7 +#cmakedefine HAVE_CPLEX 1
     5.1 --- a/test/CMakeLists.txt	Thu Apr 23 07:28:56 2009 +0100
     5.2 +++ b/test/CMakeLists.txt	Thu Apr 23 07:29:50 2009 +0100
     5.3 @@ -38,9 +38,14 @@
     5.4  
     5.5  IF(HAVE_LP)
     5.6    ADD_EXECUTABLE(lp_test lp_test.cc)
     5.7 +  SET(LP_TEST_LIBS lemon)
     5.8    IF(HAVE_GLPK)
     5.9 -    TARGET_LINK_LIBRARIES(lp_test lemon ${GLPK_LIBRARIES})
    5.10 +    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${GLPK_LIBRARIES})
    5.11    ENDIF(HAVE_GLPK)
    5.12 +  IF(HAVE_CPLEX)
    5.13 +    SET(LP_TEST_LIBS ${LP_TEST_LIBS} ${CPLEX_LIBRARIES})
    5.14 +  ENDIF(HAVE_CPLEX)
    5.15 +  TARGET_LINK_LIBRARIES(lp_test ${LP_TEST_LIBS})
    5.16    ADD_TEST(lp_test lp_test)
    5.17  
    5.18    IF(WIN32 AND HAVE_GLPK)
    5.19 @@ -52,13 +57,25 @@
    5.20        COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
    5.21      )
    5.22    ENDIF(WIN32 AND HAVE_GLPK)
    5.23 +  IF(WIN32 AND HAVE_CPLEX)
    5.24 +    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
    5.25 +    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
    5.26 +    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
    5.27 +      COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
    5.28 +    )
    5.29 +  ENDIF(WIN32 AND HAVE_CPLEX)
    5.30  ENDIF(HAVE_LP)
    5.31  
    5.32  IF(HAVE_MIP)
    5.33    ADD_EXECUTABLE(mip_test mip_test.cc)
    5.34 +  SET(MIP_TEST_LIBS lemon)
    5.35    IF(HAVE_GLPK)
    5.36 -    TARGET_LINK_LIBRARIES(mip_test lemon ${GLPK_LIBRARIES})
    5.37 +    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${GLPK_LIBRARIES})
    5.38    ENDIF(HAVE_GLPK)
    5.39 +  IF(HAVE_CPLEX)
    5.40 +    SET(MIP_TEST_LIBS ${MIP_TEST_LIBS} ${CPLEX_LIBRARIES})
    5.41 +  ENDIF(HAVE_CPLEX)
    5.42 +  TARGET_LINK_LIBRARIES(mip_test ${MIP_TEST_LIBS})
    5.43    ADD_TEST(mip_test mip_test)
    5.44  
    5.45    IF(WIN32 AND HAVE_GLPK)
    5.46 @@ -70,6 +87,13 @@
    5.47        COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
    5.48      )
    5.49    ENDIF(WIN32 AND HAVE_GLPK)
    5.50 +  IF(WIN32 AND HAVE_CPLEX)
    5.51 +    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
    5.52 +    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
    5.53 +    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
    5.54 +      COMMAND cmake -E copy ${CPLEX_BIN_DIR}/cplex91.dll ${TARGET_PATH}
    5.55 +    )
    5.56 +  ENDIF(WIN32 AND HAVE_CPLEX)
    5.57  ENDIF(HAVE_MIP)
    5.58  
    5.59  FOREACH(TEST_NAME ${TESTS})