Build GLPK dependent parts with CMake too
authorAkos Ladanyi <ladanyi@tmit.bme.hu>
Tue, 20 Jan 2009 12:23:14 +0000
changeset 47317d918051964
parent 472 c46afb3f67a6
child 474 f59df77f5c8d
Build GLPK dependent parts with CMake too
CMakeLists.txt
cmake/FindGLPK.cmake
demo/CMakeLists.txt
lemon/CMakeLists.txt
lemon/config.h.cmake
test/CMakeLists.txt
     1.1 --- a/CMakeLists.txt	Mon Jan 19 11:42:15 2009 +0000
     1.2 +++ b/CMakeLists.txt	Tue Jan 20 12:23:14 2009 +0000
     1.3 @@ -9,6 +9,15 @@
     1.4  
     1.5  INCLUDE(FindDoxygen)
     1.6  INCLUDE(FindGhostscript)
     1.7 +FIND_PACKAGE(GLPK 4.33)
     1.8 +
     1.9 +ADD_DEFINITIONS(-DHAVE_CONFIG_H)
    1.10 +
    1.11 +IF(GLPK_FOUND)
    1.12 +  SET(HAVE_LP TRUE)
    1.13 +  SET(HAVE_MIP TRUE)
    1.14 +  SET(HAVE_GLPK TRUE)
    1.15 +ENDIF(GLPK_FOUND)
    1.16  
    1.17  ENABLE_TESTING()
    1.18  
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/cmake/FindGLPK.cmake	Tue Jan 20 12:23:14 2009 +0000
     2.3 @@ -0,0 +1,20 @@
     2.4 +SET(GLPK_REGKEY "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Glpk;InstallPath]")
     2.5 +GET_FILENAME_COMPONENT(GLPK_ROOT_PATH ${GLPK_REGKEY} ABSOLUTE)
     2.6 +
     2.7 +FIND_PATH(GLPK_INCLUDE_DIR
     2.8 +  glpk.h
     2.9 +  PATHS ${GLPK_REGKEY}/include)
    2.10 +
    2.11 +FIND_LIBRARY(GLPK_LIBRARY
    2.12 +  NAMES glpk
    2.13 +  PATHS ${GLPK_REGKEY}/lib)
    2.14 +
    2.15 +INCLUDE(FindPackageHandleStandardArgs)
    2.16 +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR)
    2.17 +
    2.18 +IF(GLPK_FOUND)
    2.19 +  SET(GLPK_LIBRARIES ${GLPK_LIBRARY})
    2.20 +  SET(GLPK_BIN_DIR ${GLPK_ROOT_PATH}/bin)
    2.21 +ENDIF(GLPK_FOUND)
    2.22 +
    2.23 +MARK_AS_ADVANCED(GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_BIN_DIR)
     3.1 --- a/demo/CMakeLists.txt	Mon Jan 19 11:42:15 2009 +0000
     3.2 +++ b/demo/CMakeLists.txt	Tue Jan 20 12:23:14 2009 +0000
     3.3 @@ -1,4 +1,8 @@
     3.4 -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
     3.5 +INCLUDE_DIRECTORIES(
     3.6 +  ${CMAKE_SOURCE_DIR}
     3.7 +  ${CMAKE_BINARY_DIR}
     3.8 +  ${GLPK_INCLUDE_DIR}
     3.9 +)
    3.10  
    3.11  LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
    3.12  
     4.1 --- a/lemon/CMakeLists.txt	Mon Jan 19 11:42:15 2009 +0000
     4.2 +++ b/lemon/CMakeLists.txt	Tue Jan 20 12:23:14 2009 +0000
     4.3 @@ -1,11 +1,28 @@
     4.4 -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
     4.5 +INCLUDE_DIRECTORIES(
     4.6 +  ${CMAKE_SOURCE_DIR}
     4.7 +  ${CMAKE_BINARY_DIR}
     4.8 +  ${GLPK_INCLUDE_DIR}
     4.9 +)
    4.10  
    4.11 -ADD_LIBRARY(lemon
    4.12 +CONFIGURE_FILE(
    4.13 +  ${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake
    4.14 +  ${CMAKE_CURRENT_BINARY_DIR}/config.h
    4.15 +)
    4.16 +
    4.17 +SET(LEMON_SOURCES
    4.18    arg_parser.cc
    4.19    base.cc
    4.20    color.cc
    4.21 +  lp_base.cc
    4.22 +  lp_skeleton.cc
    4.23    random.cc)
    4.24  
    4.25 +IF(HAVE_GLPK)
    4.26 +  SET(LEMON_SOURCES ${LEMON_SOURCES} glpk.cc)
    4.27 +ENDIF(HAVE_GLPK)
    4.28 +
    4.29 +ADD_LIBRARY(lemon ${LEMON_SOURCES})
    4.30 +
    4.31  INSTALL(
    4.32    TARGETS lemon
    4.33    ARCHIVE DESTINATION lib
    4.34 @@ -16,3 +33,9 @@
    4.35    DESTINATION include/lemon
    4.36    COMPONENT headers
    4.37    FILES_MATCHING PATTERN "*.h")
    4.38 +
    4.39 +IF(WIN32)
    4.40 +  INSTALL(FILES ${GLPK_BIN_DIR}/glpk.dll DESTINATION bin)
    4.41 +  INSTALL(FILES ${GLPK_BIN_DIR}/libltdl3.dll DESTINATION bin)
    4.42 +  INSTALL(FILES ${GLPK_BIN_DIR}/zlib1.dll DESTINATION bin)
    4.43 +ENDIF(WIN32)
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/lemon/config.h.cmake	Tue Jan 20 12:23:14 2009 +0000
     5.3 @@ -0,0 +1,3 @@
     5.4 +#cmakedefine HAVE_LP 1
     5.5 +#cmakedefine HAVE_MIP 1
     5.6 +#cmakedefine HAVE_GLPK 1
     6.1 --- a/test/CMakeLists.txt	Mon Jan 19 11:42:15 2009 +0000
     6.2 +++ b/test/CMakeLists.txt	Tue Jan 20 12:23:14 2009 +0000
     6.3 @@ -1,4 +1,8 @@
     6.4 -INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})
     6.5 +INCLUDE_DIRECTORIES(
     6.6 +  ${CMAKE_SOURCE_DIR}
     6.7 +  ${CMAKE_BINARY_DIR}
     6.8 +  ${GLPK_INCLUDE_DIR}
     6.9 +)
    6.10  
    6.11  LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/lemon)
    6.12  
    6.13 @@ -11,26 +15,56 @@
    6.14    digraph_test
    6.15    dijkstra_test
    6.16    dim_test
    6.17 +  edge_set_test
    6.18    error_test
    6.19 -  edge_set_test
    6.20    graph_copy_test
    6.21    graph_test
    6.22    graph_utils_test
    6.23    hao_orlin_test
    6.24    heap_test
    6.25    kruskal_test
    6.26 -  lp_test
    6.27 -  mip_test
    6.28    maps_test
    6.29    max_matching_test
    6.30 -  radix_sort_test
    6.31    path_test
    6.32    preflow_test
    6.33 +  radix_sort_test
    6.34    random_test
    6.35    suurballe_test
    6.36    time_measure_test
    6.37    unionfind_test)
    6.38  
    6.39 +IF(HAVE_LP)
    6.40 +  ADD_EXECUTABLE(lp_test lp_test.cc)
    6.41 +  TARGET_LINK_LIBRARIES(lp_test lemon ${GLPK_LIBRARIES})
    6.42 +  ADD_TEST(lp_test lp_test)
    6.43 +
    6.44 +  IF(WIN32)
    6.45 +    GET_TARGET_PROPERTY(TARGET_LOC lp_test LOCATION)
    6.46 +    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
    6.47 +    ADD_CUSTOM_COMMAND(TARGET lp_test POST_BUILD
    6.48 +      COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
    6.49 +      COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
    6.50 +      COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
    6.51 +    )
    6.52 +  ENDIF(WIN32)
    6.53 +ENDIF(HAVE_LP)
    6.54 +
    6.55 +IF(HAVE_MIP)
    6.56 +  ADD_EXECUTABLE(mip_test mip_test.cc)
    6.57 +  TARGET_LINK_LIBRARIES(mip_test lemon ${GLPK_LIBRARIES})
    6.58 +  ADD_TEST(mip_test mip_test)
    6.59 +
    6.60 +  IF(WIN32)
    6.61 +    GET_TARGET_PROPERTY(TARGET_LOC mip_test LOCATION)
    6.62 +    GET_FILENAME_COMPONENT(TARGET_PATH ${TARGET_LOC} PATH)
    6.63 +    ADD_CUSTOM_COMMAND(TARGET mip_test POST_BUILD
    6.64 +      COMMAND cmake -E copy ${GLPK_BIN_DIR}/glpk.dll ${TARGET_PATH}
    6.65 +      COMMAND cmake -E copy ${GLPK_BIN_DIR}/libltdl3.dll ${TARGET_PATH}
    6.66 +      COMMAND cmake -E copy ${GLPK_BIN_DIR}/zlib1.dll ${TARGET_PATH}
    6.67 +    )
    6.68 +  ENDIF(WIN32)
    6.69 +ENDIF(HAVE_MIP)
    6.70 +
    6.71  FOREACH(TEST_NAME ${TESTS})
    6.72    ADD_EXECUTABLE(${TEST_NAME} ${TEST_NAME}.cc)
    6.73    TARGET_LINK_LIBRARIES(${TEST_NAME} lemon)