COIN-OR::LEMON - Graph Library

source: lemon-main/cmake/FindGLPK.cmake @ 1086:97f1760dcd13

Last change on this file since 1086:97f1760dcd13 was 1064:fc3854d936f7, checked in by Alpar Juttner <alpar@…>, 12 years ago

Enable/disable options for LP/MIP backends (#465)

File size: 2.1 KB
RevLine 
[637]1SET(GLPK_ROOT_DIR "" CACHE PATH "GLPK root directory")
2
[473]3SET(GLPK_REGKEY "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Glpk;InstallPath]")
4GET_FILENAME_COMPONENT(GLPK_ROOT_PATH ${GLPK_REGKEY} ABSOLUTE)
5
6FIND_PATH(GLPK_INCLUDE_DIR
7  glpk.h
[637]8  PATHS ${GLPK_REGKEY}/include
9  HINTS ${GLPK_ROOT_DIR}/include
10)
[473]11FIND_LIBRARY(GLPK_LIBRARY
[637]12  glpk
13  PATHS ${GLPK_REGKEY}/lib
14  HINTS ${GLPK_ROOT_DIR}/lib
15)
[473]16
[638]17IF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
18  FILE(READ ${GLPK_INCLUDE_DIR}/glpk.h GLPK_GLPK_H)
19
20  STRING(REGEX MATCH "define[ ]+GLP_MAJOR_VERSION[ ]+[0-9]+" GLPK_MAJOR_VERSION_LINE "${GLPK_GLPK_H}")
21  STRING(REGEX REPLACE "define[ ]+GLP_MAJOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MAJOR "${GLPK_MAJOR_VERSION_LINE}")
22
23  STRING(REGEX MATCH "define[ ]+GLP_MINOR_VERSION[ ]+[0-9]+" GLPK_MINOR_VERSION_LINE "${GLPK_GLPK_H}")
24  STRING(REGEX REPLACE "define[ ]+GLP_MINOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MINOR "${GLPK_MINOR_VERSION_LINE}")
25
26  SET(GLPK_VERSION_STRING "${GLPK_VERSION_MAJOR}.${GLPK_VERSION_MINOR}")
27
28  IF(GLPK_FIND_VERSION)
29    IF(GLPK_FIND_VERSION_COUNT GREATER 2)
30      MESSAGE(SEND_ERROR "unexpected version string")
31    ENDIF(GLPK_FIND_VERSION_COUNT GREATER 2)
32
33    MATH(EXPR GLPK_REQUESTED_VERSION "${GLPK_FIND_VERSION_MAJOR}*100 + ${GLPK_FIND_VERSION_MINOR}")
34    MATH(EXPR GLPK_FOUND_VERSION "${GLPK_VERSION_MAJOR}*100 + ${GLPK_VERSION_MINOR}")
35
36    IF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
37      SET(GLPK_PROPER_VERSION_FOUND FALSE)
38    ELSE(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
39      SET(GLPK_PROPER_VERSION_FOUND TRUE)
40    ENDIF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
41  ELSE(GLPK_FIND_VERSION)
42    SET(GLPK_PROPER_VERSION_FOUND TRUE)
43  ENDIF(GLPK_FIND_VERSION)
44ENDIF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
45
[473]46INCLUDE(FindPackageHandleStandardArgs)
[638]47FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND)
[473]48
49IF(GLPK_FOUND)
[619]50  SET(GLPK_INCLUDE_DIRS ${GLPK_INCLUDE_DIR})
[473]51  SET(GLPK_LIBRARIES ${GLPK_LIBRARY})
52  SET(GLPK_BIN_DIR ${GLPK_ROOT_PATH}/bin)
53ENDIF(GLPK_FOUND)
54
55MARK_AS_ADVANCED(GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_BIN_DIR)
Note: See TracBrowser for help on using the repository browser.