Check the version number in FindGLPK (#277)
authorAkos Ladanyi <ladanyi@tmit.bme.hu>
Tue, 28 Apr 2009 11:25:47 +0100
changeset 63857e6f560fb13
parent 637 4faa0c763906
child 639 72ac25ad276e
Check the version number in FindGLPK (#277)
cmake/FindGLPK.cmake
     1.1 --- a/cmake/FindGLPK.cmake	Mon Apr 27 18:05:04 2009 +0100
     1.2 +++ b/cmake/FindGLPK.cmake	Tue Apr 28 11:25:47 2009 +0100
     1.3 @@ -14,8 +14,37 @@
     1.4    HINTS ${GLPK_ROOT_DIR}/lib
     1.5  )
     1.6  
     1.7 +IF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
     1.8 +  FILE(READ ${GLPK_INCLUDE_DIR}/glpk.h GLPK_GLPK_H)
     1.9 +
    1.10 +  STRING(REGEX MATCH "define[ ]+GLP_MAJOR_VERSION[ ]+[0-9]+" GLPK_MAJOR_VERSION_LINE "${GLPK_GLPK_H}")
    1.11 +  STRING(REGEX REPLACE "define[ ]+GLP_MAJOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MAJOR "${GLPK_MAJOR_VERSION_LINE}")
    1.12 +
    1.13 +  STRING(REGEX MATCH "define[ ]+GLP_MINOR_VERSION[ ]+[0-9]+" GLPK_MINOR_VERSION_LINE "${GLPK_GLPK_H}")
    1.14 +  STRING(REGEX REPLACE "define[ ]+GLP_MINOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MINOR "${GLPK_MINOR_VERSION_LINE}")
    1.15 +
    1.16 +  SET(GLPK_VERSION_STRING "${GLPK_VERSION_MAJOR}.${GLPK_VERSION_MINOR}")
    1.17 +
    1.18 +  IF(GLPK_FIND_VERSION)
    1.19 +    IF(GLPK_FIND_VERSION_COUNT GREATER 2)
    1.20 +      MESSAGE(SEND_ERROR "unexpected version string")
    1.21 +    ENDIF(GLPK_FIND_VERSION_COUNT GREATER 2)
    1.22 +
    1.23 +    MATH(EXPR GLPK_REQUESTED_VERSION "${GLPK_FIND_VERSION_MAJOR}*100 + ${GLPK_FIND_VERSION_MINOR}")
    1.24 +    MATH(EXPR GLPK_FOUND_VERSION "${GLPK_VERSION_MAJOR}*100 + ${GLPK_VERSION_MINOR}")
    1.25 +
    1.26 +    IF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
    1.27 +      SET(GLPK_PROPER_VERSION_FOUND FALSE)
    1.28 +    ELSE(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
    1.29 +      SET(GLPK_PROPER_VERSION_FOUND TRUE)
    1.30 +    ENDIF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION)
    1.31 +  ELSE(GLPK_FIND_VERSION)
    1.32 +    SET(GLPK_PROPER_VERSION_FOUND TRUE)
    1.33 +  ENDIF(GLPK_FIND_VERSION)
    1.34 +ENDIF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY)
    1.35 +
    1.36  INCLUDE(FindPackageHandleStandardArgs)
    1.37 -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR)
    1.38 +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK DEFAULT_MSG GLPK_LIBRARY GLPK_INCLUDE_DIR GLPK_PROPER_VERSION_FOUND)
    1.39  
    1.40  IF(GLPK_FOUND)
    1.41    SET(GLPK_INCLUDE_DIRS ${GLPK_INCLUDE_DIR})