cmake/FindGLPK.cmake
changeset 784 1a7fe3bef514
parent 637 4faa0c763906
child 1062 caf16813b1e8
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/cmake/FindGLPK.cmake	Thu Nov 05 15:50:01 2009 +0100
     1.3 @@ -0,0 +1,61 @@
     1.4 +SET(GLPK_ROOT_DIR "" CACHE PATH "GLPK root directory")
     1.5 +
     1.6 +SET(GLPK_REGKEY "[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Glpk;InstallPath]")
     1.7 +GET_FILENAME_COMPONENT(GLPK_ROOT_PATH ${GLPK_REGKEY} ABSOLUTE)
     1.8 +
     1.9 +FIND_PATH(GLPK_INCLUDE_DIR
    1.10 +  glpk.h
    1.11 +  PATHS ${GLPK_REGKEY}/include
    1.12 +  HINTS ${GLPK_ROOT_DIR}/include
    1.13 +)
    1.14 +FIND_LIBRARY(GLPK_LIBRARY
    1.15 +  glpk
    1.16 +  PATHS ${GLPK_REGKEY}/lib
    1.17 +  HINTS ${GLPK_ROOT_DIR}/lib
    1.18 +)
    1.19 +
    1.20 +IF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
    1.21 +  FILE(READ ${GLPK_INCLUDE_DIR}/glpk.h GLPK_GLPK_H)
    1.22 +
    1.23 +  STRING(REGEX MATCH "define[ ]+GLP_MAJOR_VERSION[ ]+[0-9]+" GLPK_MAJOR_VERSION_LINE "${GLPK_GLPK_H}")
    1.24 +  STRING(REGEX REPLACE "define[ ]+GLP_MAJOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MAJOR "${GLPK_MAJOR_VERSION_LINE}")
    1.25 +
    1.26 +  STRING(REGEX MATCH "define[ ]+GLP_MINOR_VERSION[ ]+[0-9]+" GLPK_MINOR_VERSION_LINE "${GLPK_GLPK_H}")
    1.27 +  STRING(REGEX REPLACE "define[ ]+GLP_MINOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MINOR "${GLPK_MINOR_VERSION_LINE}")
    1.28 +
    1.29 +  SET(GLPK_VERSION_STRING "${GLPK_VERSION_MAJOR}.${GLPK_VERSION_MINOR}")
    1.30 +
    1.31 +  IF(GLPK_FIND_VERSION)
    1.32 +    IF(GLPK_FIND_VERSION_COUNT GREATER 2)
    1.33 +      MESSAGE(SEND_ERROR "unexpected version string")
    1.34 +    ENDIF(GLPK_FIND_VERSION_COUNT GREATER 2)
    1.35 +
    1.36 +    MATH(EXPR GLPK_REQUESTED_VERSION "${GLPK_FIND_VERSION_MAJOR}*100 + ${GLPK_FIND_VERSION_MINOR}")
    1.37 +    MATH(EXPR GLPK_FOUND_VERSION "${GLPK_VERSION_MAJOR}*100 + ${GLPK_VERSION_MINOR}")
    1.38 +
    1.39 +    IF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
    1.40 +      SET(GLPK_PROPER_VERSION_FOUND FALSE)
    1.41 +    ELSE(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
    1.42 +      SET(GLPK_PROPER_VERSION_FOUND TRUE)
    1.43 +    ENDIF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
    1.44 +  ELSE(GLPK_FIND_VERSION)
    1.45 +    SET(GLPK_PROPER_VERSION_FOUND TRUE)
    1.46 +  ENDIF(GLPK_FIND_VERSION)
    1.47 +ENDIF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
    1.48 +
    1.49 +INCLUDE(FindPackageHandleStandardArgs)
    1.50 +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND)
    1.51 +
    1.52 +IF(GLPK_FOUND)
    1.53 +  SET(GLPK_INCLUDE_DIRS ${GLPK_INCLUDE_DIR})
    1.54 +  SET(GLPK_LIBRARIES ${GLPK_LIBRARY})
    1.55 +  SET(GLPK_BIN_DIR ${GLPK_ROOT_PATH}/bin)
    1.56 +ENDIF(GLPK_FOUND)
    1.57 +
    1.58 +MARK_AS_ADVANCED(GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_BIN_DIR)
    1.59 +
    1.60 +IF(GLPK_FOUND)
    1.61 +  SET(LEMON_HAVE_LP TRUE)
    1.62 +  SET(LEMON_HAVE_MIP TRUE)
    1.63 +  SET(LEMON_HAVE_GLPK TRUE)
    1.64 +ENDIF(GLPK_FOUND)