cmake/FindGLPK.cmake
author Alpar Juttner <alpar@cs.elte.hu>
Sat, 10 Aug 2013 13:57:30 +0200
branch1.1
changeset 812 54b71c7f146d
parent 632 4faa0c763906
permissions -rw-r--r--
Remove -Werror form AM_INIT_AUTOMAKE
ladanyi@632
     1
SET(GLPK_ROOT_DIR "" CACHE PATH "GLPK root directory")
ladanyi@632
     2
ladanyi@473
     3
SET(GLPK_REGKEY "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Glpk;InstallPath]")
ladanyi@473
     4
GET_FILENAME_COMPONENT(GLPK_ROOT_PATH ${GLPK_REGKEY} ABSOLUTE)
ladanyi@473
     5
ladanyi@473
     6
FIND_PATH(GLPK_INCLUDE_DIR
ladanyi@473
     7
  glpk.h
ladanyi@632
     8
  PATHS ${GLPK_REGKEY}/include
ladanyi@632
     9
  HINTS ${GLPK_ROOT_DIR}/include
ladanyi@632
    10
)
ladanyi@473
    11
FIND_LIBRARY(GLPK_LIBRARY
ladanyi@632
    12
  glpk
ladanyi@632
    13
  PATHS ${GLPK_REGKEY}/lib
ladanyi@632
    14
  HINTS ${GLPK_ROOT_DIR}/lib
ladanyi@632
    15
)
ladanyi@473
    16
ladanyi@633
    17
IF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
ladanyi@633
    18
  FILE(READ ${GLPK_INCLUDE_DIR}/glpk.h GLPK_GLPK_H)
ladanyi@633
    19
ladanyi@633
    20
  STRING(REGEX MATCH "define[ ]+GLP_MAJOR_VERSION[ ]+[0-9]+" GLPK_MAJOR_VERSION_LINE "${GLPK_GLPK_H}")
ladanyi@633
    21
  STRING(REGEX REPLACE "define[ ]+GLP_MAJOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MAJOR "${GLPK_MAJOR_VERSION_LINE}")
ladanyi@633
    22
ladanyi@633
    23
  STRING(REGEX MATCH "define[ ]+GLP_MINOR_VERSION[ ]+[0-9]+" GLPK_MINOR_VERSION_LINE "${GLPK_GLPK_H}")
ladanyi@633
    24
  STRING(REGEX REPLACE "define[ ]+GLP_MINOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MINOR "${GLPK_MINOR_VERSION_LINE}")
ladanyi@633
    25
ladanyi@633
    26
  SET(GLPK_VERSION_STRING "${GLPK_VERSION_MAJOR}.${GLPK_VERSION_MINOR}")
ladanyi@633
    27
ladanyi@633
    28
  IF(GLPK_FIND_VERSION)
ladanyi@633
    29
    IF(GLPK_FIND_VERSION_COUNT GREATER 2)
ladanyi@633
    30
      MESSAGE(SEND_ERROR "unexpected version string")
ladanyi@633
    31
    ENDIF(GLPK_FIND_VERSION_COUNT GREATER 2)
ladanyi@633
    32
ladanyi@633
    33
    MATH(EXPR GLPK_REQUESTED_VERSION "${GLPK_FIND_VERSION_MAJOR}*100 + ${GLPK_FIND_VERSION_MINOR}")
ladanyi@633
    34
    MATH(EXPR GLPK_FOUND_VERSION "${GLPK_VERSION_MAJOR}*100 + ${GLPK_VERSION_MINOR}")
ladanyi@633
    35
ladanyi@633
    36
    IF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
ladanyi@633
    37
      SET(GLPK_PROPER_VERSION_FOUND FALSE)
ladanyi@633
    38
    ELSE(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
ladanyi@633
    39
      SET(GLPK_PROPER_VERSION_FOUND TRUE)
ladanyi@633
    40
    ENDIF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
ladanyi@633
    41
  ELSE(GLPK_FIND_VERSION)
ladanyi@633
    42
    SET(GLPK_PROPER_VERSION_FOUND TRUE)
ladanyi@633
    43
  ENDIF(GLPK_FIND_VERSION)
ladanyi@633
    44
ENDIF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
ladanyi@633
    45
ladanyi@473
    46
INCLUDE(FindPackageHandleStandardArgs)
ladanyi@633
    47
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND)
ladanyi@473
    48
ladanyi@473
    49
IF(GLPK_FOUND)
ladanyi@611
    50
  SET(GLPK_INCLUDE_DIRS ${GLPK_INCLUDE_DIR})
ladanyi@473
    51
  SET(GLPK_LIBRARIES ${GLPK_LIBRARY})
ladanyi@473
    52
  SET(GLPK_BIN_DIR ${GLPK_ROOT_PATH}/bin)
ladanyi@473
    53
ENDIF(GLPK_FOUND)
ladanyi@473
    54
ladanyi@473
    55
MARK_AS_ADVANCED(GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_BIN_DIR)
ladanyi@611
    56
ladanyi@611
    57
IF(GLPK_FOUND)
ladanyi@622
    58
  SET(LEMON_HAVE_LP TRUE)
ladanyi@622
    59
  SET(LEMON_HAVE_MIP TRUE)
ladanyi@622
    60
  SET(LEMON_HAVE_GLPK TRUE)
ladanyi@611
    61
ENDIF(GLPK_FOUND)