You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.8 KiB

3 months ago
  1. # - Try to find libglpk
  2. # Once done this will define
  3. # GLPK_FOUND - System has glpk
  4. # GLPK_INCLUDE_DIR - The glpk include directory
  5. # GLPK_LIBRARIES - The libraries needed to use glpk
  6. # GLPK_VERSION_STRING - The version of glpk ("major.minor")
  7. # use pkg-config to get the directories and then use these values
  8. # in the find_path() and find_library() calls
  9. find_package(PkgConfig QUIET)
  10. PKG_CHECK_MODULES(PC_GLPK QUIET glpk)
  11. find_path(GLPK_INCLUDE_DIR NAMES glpk.h
  12. HINTS
  13. ${PC_GLPK_INCLUDEDIR}
  14. ${PC_GLPK_INCLUDE_DIRS}
  15. PATH_SUFFIXES glpk
  16. )
  17. find_library(GLPK_LIBRARIES NAMES glpk
  18. HINTS
  19. ${PC_GLPK_LIBDIR}
  20. ${PC_GLPK_LIBRARY_DIRS}
  21. )
  22. if(PC_GLPK_VERSION)
  23. set(GLPK_VERSION_STRING ${PC_GLPK_VERSION})
  24. elseif(GLPK_INCLUDE_DIR AND EXISTS "${GLPK_INCLUDE_DIR}/glpk.h")
  25. file(STRINGS "${GLPK_INCLUDE_DIR}/glpk.h" glpk_major_version
  26. REGEX "^#define[\t ]+GLP_MAJOR_VERSION[\t ]+.+")
  27. file(STRINGS "${GLPK_INCLUDE_DIR}/glpk.h" glpk_minor_version
  28. REGEX "^#define[\t ]+GLP_MINOR_VERSION[\t ]+.+")
  29. string(REGEX REPLACE "^#define[\t ]+GLP_MAJOR_VERSION[\t ]+(.+)" "\\1"
  30. glpk_major_version "${glpk_major_version}")
  31. string(REGEX REPLACE "^#define[\t ]+GLP_MINOR_VERSION[\t ]+(.+)" "\\1"
  32. glpk_minor_version "${glpk_minor_version}")
  33. set(GLPK_VERSION_STRING "${glpk_major_version}.${glpk_minor_version}")
  34. unset(glpk_major_version)
  35. unset(glpk_minor_version)
  36. endif()
  37. # handle the QUIETLY and REQUIRED arguments and set GLPK_FOUND to TRUE if
  38. # all listed variables are TRUE
  39. include(FindPackageHandleStandardArgs)
  40. FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLPK
  41. REQUIRED_VARS GLPK_LIBRARIES GLPK_INCLUDE_DIR
  42. VERSION_VAR GLPK_VERSION_STRING)
  43. mark_as_advanced(GLPK_INCLUDE_DIR GLPK_LIBRARIES)