The source code and dockerfile for the GSW2024 AI Lab.
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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

54 lines
1.3 KiB

2 months ago
  1. # Include dir
  2. STRING(REPLACE ":" ";" CPATH "$ENV{CPATH}")
  3. find_path(GMP_INCLUDE_DIR
  4. NAMES gmp.h
  5. HINTS ${CPATH}
  6. DOC "Include directory for GMP"
  7. )
  8. # Library files
  9. STRING(REPLACE ":" ";" LIBRARY_PATH "$ENV{LIBRARY_PATH}")
  10. find_library(GMP_LIBRARY
  11. NAMES gmp
  12. HINTS ${LIBRARY_PATH}
  13. PATHS /usr/local/lib
  14. )
  15. # Version
  16. function(GetVersionPart OUTPUT FILENAME DESC)
  17. file(STRINGS ${FILENAME} RES REGEX "^#define __GNU_MP_${DESC}[ \\t]+.*")
  18. string(REGEX MATCH "[0-9]+" RES "${RES}")
  19. set(${OUTPUT} "${RES}" PARENT_SCOPE)
  20. endfunction()
  21. function(GetVersion OUTPUT FILENAME)
  22. GetVersionPart(MAJOR "${FILENAME}" "VERSION")
  23. GetVersionPart(MINOR "${FILENAME}" "VERSION_MINOR")
  24. GetVersionPart(PATCH "${FILENAME}" "VERSION_PATCHLEVEL")
  25. set(${OUTPUT} "${MAJOR}.${MINOR}.${PATCH}" PARENT_SCOPE)
  26. endfunction()
  27. if(GMP_INCLUDE_DIR AND GMP_LIBRARY)
  28. set(GMP_FOUND TRUE)
  29. if (EXISTS "${GMP_INCLUDE_DIR}/gmp-x86_64.h")
  30. GetVersion(GMP_VERSION "${GMP_INCLUDE_DIR}/gmp-x86_64.h")
  31. else()
  32. GetVersion(GMP_VERSION "${GMP_INCLUDE_DIR}/gmp.h")
  33. endif()
  34. if(GMP_FIND_VERSION VERSION_GREATER GMP_VERSION)
  35. message(WARNING "Required GMP ${GMP_FIND_VERSION} but found only GMP ${GMP_VERSION}.")
  36. unset(GMP_FOUND)
  37. unset(GMP_INCLUDE_DIR)
  38. unset(GMP_LIBRARY)
  39. unset(GMP_VERSION)
  40. return()
  41. endif()
  42. endif()
  43. mark_as_advanced(
  44. GMP_FOUND
  45. GMP_INCLUDE_DIR
  46. GMP_LIBRARY
  47. GMP_VERSION
  48. )