COIN-OR::LEMON - Graph Library

Ticket #206: cmake-glpk.patch

File cmake-glpk.patch, 4.6 KB (added by Akos Ladanyi, 16 years ago)

17d918051964

  • CMakeLists.txt

    # HG changeset patch
    # User Akos Ladanyi <ladanyi@tmit.bme.hu>
    # Date 1232454194 0
    # Node ID 17d918051964362329f8a92dea8564eb732b87ae
    # Parent  c46afb3f67a660bc039746a688210033927b1f5a
    Build GLPK dependent parts with CMake too
    
    diff --git a/CMakeLists.txt b/CMakeLists.txt
    a b  
    99
    1010INCLUDE(FindDoxygen)
    1111INCLUDE(FindGhostscript)
     12FIND_PACKAGE(GLPK 4.33)
     13
     14ADD_DEFINITIONS(-DHAVE_CONFIG_H)
     15
     16IF(GLPK_FOUND)
     17  SET(HAVE_LP TRUE)
     18  SET(HAVE_MIP TRUE)
     19  SET(HAVE_GLPK TRUE)
     20ENDIF(GLPK_FOUND)
    1221
    1322ENABLE_TESTING()
    1423
  • new file cmake/FindGLPK.cmake

    diff --git a/cmake/FindGLPK.cmake b/cmake/FindGLPK.cmake
    new file mode 100644
    - +  
     1SET(GLPK_REGKEY "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Glpk;InstallPath]")
     2GET_FILENAME_COMPONENT(GLPK_ROOT_PATH ${GLPK_REGKEY} ABSOLUTE)
     3
     4FIND_PATH(GLPK_INCLUDE_DIR
     5  glpk.h
     6  PATHS ${GLPK_REGKEY}/include)
     7
     8FIND_LIBRARY(GLPK_LIBRARY
     9  NAMES glpk
     10  PATHS ${GLPK_REGKEY}/lib)
     11
     12INCLUDE(FindPackageHandleStandardArgs)
     13FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR)
     14
     15IF(GLPK_FOUND)
     16  SET(GLPK_LIBRARIES ${GLPK_LIBRARY})
     17  SET(GLPK_BIN_DIR ${GLPK_ROOT_PATH}/bin)
     18ENDIF(GLPK_FOUND)
     19
     20MARK_AS_ADVANCED(GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_BIN_DIR)
  • demo/CMakeLists.txt

    diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt
    a b  
    1 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
     1INCLUDE_DIRECTORIES(
     2  ${CMAKE_SOURCE_DIR}
     3  ${CMAKE_BINARY_DIR}
     4  ${GLPK_INCLUDE_DIR}
     5)
    26
    37LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
    48
  • lemon/CMakeLists.txt

    diff --git a/lemon/CMakeLists.txt b/lemon/CMakeLists.txt
    a b  
    1 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
     1INCLUDE_DIRECTORIES(
     2  ${CMAKE_SOURCE_DIR}
     3  ${CMAKE_BINARY_DIR}
     4  ${GLPK_INCLUDE_DIR}
     5)
    26
    3 ADD_LIBRARY(lemon
     7CONFIGURE_FILE(
     8  ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
     9  ${CMAKE_CURRENT_BINARY_DIR}/config.h
     10)
     11
     12SET(LEMON_SOURCES
    413  arg_parser.cc
    514  base.cc
    615  color.cc
     16  lp_base.cc
     17  lp_skeleton.cc
    718  random.cc)
     19
     20IF(HAVE_GLPK)
     21  SET(LEMON_SOURCES ${LEMON_SOURCES} glpk.cc)
     22ENDIF(HAVE_GLPK)
     23
     24ADD_LIBRARY(lemon ${LEMON_SOURCES})
    825
    926INSTALL(
    1027  TARGETS lemon
     
    1633  DESTINATION include/lemon
    1734  COMPONENT headers
    1835  FILES_MATCHING PATTERN "*.h")
     36
     37IF(WIN32)
     38  INSTALL(FILES ${GLPK_BIN_DIR}/glpk.dll DESTINATION bin)
     39  INSTALL(FILES ${GLPK_BIN_DIR}/libltdl3.dll DESTINATION bin)
     40  INSTALL(FILES ${GLPK_BIN_DIR}/zlib1.dll DESTINATION bin)
     41ENDIF(WIN32)
  • new file lemon/config.h.cmake

    diff --git a/lemon/config.h.cmake b/lemon/config.h.cmake
    new file mode 100644
    - +  
     1#cmakedefine HAVE_LP 1
     2#cmakedefine HAVE_MIP 1
     3#cmakedefine HAVE_GLPK 1
  • test/CMakeLists.txt

    diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
    a b  
    1 INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
     1INCLUDE_DIRECTORIES(
     2  ${CMAKE_SOURCE_DIR}
     3  ${CMAKE_BINARY_DIR}
     4  ${GLPK_INCLUDE_DIR}
     5)
    26
    37LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
    48
     
    1115  digraph_test
    1216  dijkstra_test
    1317  dim_test
     18  edge_set_test
    1419  error_test
    15   edge_set_test
    1620  graph_copy_test
    1721  graph_test
    1822  graph_utils_test
    1923  hao_orlin_test
    2024  heap_test
    2125  kruskal_test
    22   lp_test
    23   mip_test
    2426  maps_test
    2527  max_matching_test
    26   radix_sort_test
    2728  path_test
    2829  preflow_test
     30  radix_sort_test
    2931  random_test
    3032  suurballe_test
    3133  time_measure_test
    3234  unionfind_test)
     35
     36IF(HAVE_LP)
     37  ADD_EXECUTABLE(lp_test lp_test.cc)
     38  TARGET_LINK_LIBRARIES(lp_test lemon ${GLPK_LIBRARIES})
     39  ADD_TEST(lp_test lp_test)
     40
     41  IF(WIN32)
     42    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
     43    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     44    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
     45      COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
     46      COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
     47      COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
     48    )
     49  ENDIF(WIN32)
     50ENDIF(HAVE_LP)
     51
     52IF(HAVE_MIP)
     53  ADD_EXECUTABLE(mip_test mip_test.cc)
     54  TARGET_LINK_LIBRARIES(mip_test lemon ${GLPK_LIBRARIES})
     55  ADD_TEST(mip_test mip_test)
     56
     57  IF(WIN32)
     58    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
     59    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
     60    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
     61      COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
     62      COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
     63      COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
     64    )
     65  ENDIF(WIN32)
     66ENDIF(HAVE_MIP)
    3367
    3468FOREACH(TEST_NAME ${TESTS})
    3569  ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)