1.1 --- a/cmake/FindGLPK.cmake Wed Apr 29 16:15:29 2009 +0100
1.2 +++ b/cmake/FindGLPK.cmake Wed Apr 29 19:22:14 2009 +0100
1.3 @@ -1,16 +1,50 @@
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 + PATHS ${GLPK_REGKEY}/include
1.13 + HINTS ${GLPK_ROOT_DIR}/include
1.14 +)
1.15 +FIND_LIBRARY(GLPK_LIBRARY
1.16 + glpk
1.17 + PATHS ${GLPK_REGKEY}/lib
1.18 + HINTS ${GLPK_ROOT_DIR}/lib
1.19 +)
1.20
1.21 -FIND_LIBRARY(GLPK_LIBRARY
1.22 - NAMES glpk
1.23 - PATHS ${GLPK_REGKEY}/lib)
1.24 +IF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
1.25 + FILE(READ ${GLPK_INCLUDE_DIR}/glpk.h GLPK_GLPK_H)
1.26 +
1.27 + STRING(REGEX MATCH "define[ ]+GLP_MAJOR_VERSION[ ]+[0-9]+" GLPK_MAJOR_VERSION_LINE "${GLPK_GLPK_H}")
1.28 + STRING(REGEX REPLACE "define[ ]+GLP_MAJOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MAJOR "${GLPK_MAJOR_VERSION_LINE}")
1.29 +
1.30 + STRING(REGEX MATCH "define[ ]+GLP_MINOR_VERSION[ ]+[0-9]+" GLPK_MINOR_VERSION_LINE "${GLPK_GLPK_H}")
1.31 + STRING(REGEX REPLACE "define[ ]+GLP_MINOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MINOR "${GLPK_MINOR_VERSION_LINE}")
1.32 +
1.33 + SET(GLPK_VERSION_STRING "${GLPK_VERSION_MAJOR}.${GLPK_VERSION_MINOR}")
1.34 +
1.35 + IF(GLPK_FIND_VERSION)
1.36 + IF(GLPK_FIND_VERSION_COUNT GREATER 2)
1.37 + MESSAGE(SEND_ERROR "unexpected version string")
1.38 + ENDIF(GLPK_FIND_VERSION_COUNT GREATER 2)
1.39 +
1.40 + MATH(EXPR GLPK_REQUESTED_VERSION "${GLPK_FIND_VERSION_MAJOR}*100 + ${GLPK_FIND_VERSION_MINOR}")
1.41 + MATH(EXPR GLPK_FOUND_VERSION "${GLPK_VERSION_MAJOR}*100 + ${GLPK_VERSION_MINOR}")
1.42 +
1.43 + IF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
1.44 + SET(GLPK_PROPER_VERSION_FOUND FALSE)
1.45 + ELSE(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
1.46 + SET(GLPK_PROPER_VERSION_FOUND TRUE)
1.47 + ENDIF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
1.48 + ELSE(GLPK_FIND_VERSION)
1.49 + SET(GLPK_PROPER_VERSION_FOUND TRUE)
1.50 + ENDIF(GLPK_FIND_VERSION)
1.51 +ENDIF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
1.52
1.53 INCLUDE(FindPackageHandleStandardArgs)
1.54 -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR)
1.55 +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND)
1.56
1.57 IF(GLPK_FOUND)
1.58 SET(GLPK_INCLUDE_DIRS ${GLPK_INCLUDE_DIR})