author | Peter Kovacs <kpeter@inf.elte.hu> |
Tue, 11 Aug 2009 20:55:40 +0200 | |
changeset 765 | 3b544a9c92db |
parent 637 | 4faa0c763906 |
child 1062 | caf16813b1e8 |
permissions | -rw-r--r-- |
ladanyi@637 | 1 |
SET(GLPK_ROOT_DIR "" CACHE PATH "GLPK root directory") |
ladanyi@637 | 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@637 | 8 |
PATHS ${GLPK_REGKEY}/include |
ladanyi@637 | 9 |
HINTS ${GLPK_ROOT_DIR}/include |
ladanyi@637 | 10 |
) |
ladanyi@473 | 11 |
FIND_LIBRARY(GLPK_LIBRARY |
ladanyi@637 | 12 |
glpk |
ladanyi@637 | 13 |
PATHS ${GLPK_REGKEY}/lib |
ladanyi@637 | 14 |
HINTS ${GLPK_ROOT_DIR}/lib |
ladanyi@637 | 15 |
) |
ladanyi@473 | 16 |
|
ladanyi@638 | 17 |
IF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY) |
ladanyi@638 | 18 |
FILE(READ ${GLPK_INCLUDE_DIR}/glpk.h GLPK_GLPK_H) |
ladanyi@638 | 19 |
|
ladanyi@638 | 20 |
STRING(REGEX MATCH "define[ ]+GLP_MAJOR_VERSION[ ]+[0-9]+" GLPK_MAJOR_VERSION_LINE "${GLPK_GLPK_H}") |
ladanyi@638 | 21 |
STRING(REGEX REPLACE "define[ ]+GLP_MAJOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MAJOR "${GLPK_MAJOR_VERSION_LINE}") |
ladanyi@638 | 22 |
|
ladanyi@638 | 23 |
STRING(REGEX MATCH "define[ ]+GLP_MINOR_VERSION[ ]+[0-9]+" GLPK_MINOR_VERSION_LINE "${GLPK_GLPK_H}") |
ladanyi@638 | 24 |
STRING(REGEX REPLACE "define[ ]+GLP_MINOR_VERSION[ ]+([0-9]+)" "\\1" GLPK_VERSION_MINOR "${GLPK_MINOR_VERSION_LINE}") |
ladanyi@638 | 25 |
|
ladanyi@638 | 26 |
SET(GLPK_VERSION_STRING "${GLPK_VERSION_MAJOR}.${GLPK_VERSION_MINOR}") |
ladanyi@638 | 27 |
|
ladanyi@638 | 28 |
IF(GLPK_FIND_VERSION) |
ladanyi@638 | 29 |
IF(GLPK_FIND_VERSION_COUNT GREATER 2) |
ladanyi@638 | 30 |
MESSAGE(SEND_ERROR "unexpected version string") |
ladanyi@638 | 31 |
ENDIF(GLPK_FIND_VERSION_COUNT GREATER 2) |
ladanyi@638 | 32 |
|
ladanyi@638 | 33 |
MATH(EXPR GLPK_REQUESTED_VERSION "${GLPK_FIND_VERSION_MAJOR}*100 + ${GLPK_FIND_VERSION_MINOR}") |
ladanyi@638 | 34 |
MATH(EXPR GLPK_FOUND_VERSION "${GLPK_VERSION_MAJOR}*100 + ${GLPK_VERSION_MINOR}") |
ladanyi@638 | 35 |
|
ladanyi@638 | 36 |
IF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION) |
ladanyi@638 | 37 |
SET(GLPK_PROPER_VERSION_FOUND FALSE) |
ladanyi@638 | 38 |
ELSE(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION) |
ladanyi@638 | 39 |
SET(GLPK_PROPER_VERSION_FOUND TRUE) |
ladanyi@638 | 40 |
ENDIF(GLPK_FOUND_VERSION LESS GLPK_REQUESTED_VERSION) |
ladanyi@638 | 41 |
ELSE(GLPK_FIND_VERSION) |
ladanyi@638 | 42 |
SET(GLPK_PROPER_VERSION_FOUND TRUE) |
ladanyi@638 | 43 |
ENDIF(GLPK_FIND_VERSION) |
ladanyi@638 | 44 |
ENDIF(GLPK_INCLUDE_DIR AND GLPK_LIBRARY) |
ladanyi@638 | 45 |
|
ladanyi@473 | 46 |
INCLUDE(FindPackageHandleStandardArgs) |
ladanyi@638 | 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@619 | 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@619 | 56 |
|
ladanyi@619 | 57 |
IF(GLPK_FOUND) |
ladanyi@627 | 58 |
SET(LEMON_HAVE_LP TRUE) |
ladanyi@627 | 59 |
SET(LEMON_HAVE_MIP TRUE) |
ladanyi@627 | 60 |
SET(LEMON_HAVE_GLPK TRUE) |
ladanyi@619 | 61 |
ENDIF(GLPK_FOUND) |