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.

54 lines
1.5 KiB

  1. #
  2. # FindCusp
  3. #
  4. # This module finds the CUSP header files and extracts their version. It
  5. # sets the following variables.
  6. #
  7. # CUSP_INCLUDE_DIR - Include directory for cusp header files. (All header
  8. # files will actually be in the cusp subdirectory.)
  9. # CUSP_VERSION - Version of cusp in the form "major.minor.patch".
  10. #
  11. # CUSP_FOUND - Indicates whether Cusp has been found
  12. #
  13. find_path(CUSP_INCLUDE_DIR
  14. HINTS
  15. /usr/include/cusp
  16. /usr/local/include
  17. /usr/local/cusp/include
  18. ${CUSP_INCLUDE_DIRS}
  19. ${CUSP_HINT}
  20. NAMES cusp/version.h
  21. DOC "Cusp headers"
  22. )
  23. if(CUSP_INCLUDE_DIR)
  24. list(REMOVE_DUPLICATES CUSP_INCLUDE_DIR)
  25. endif(CUSP_INCLUDE_DIR)
  26. # Find cusp version
  27. file(STRINGS ${CUSP_INCLUDE_DIR}/cusp/version.h
  28. version
  29. REGEX "#define CUSP_VERSION[ \t]+([0-9x]+)"
  30. )
  31. string(REGEX REPLACE
  32. "#define CUSP_VERSION[ \t]+"
  33. ""
  34. version
  35. "${version}"
  36. )
  37. #define CUSP_MAJOR_VERSION (CUSP_VERSION / 100000)
  38. #define CUSP_MINOR_VERSION (CUSP_VERSION / 100 % 1000)
  39. #define CUSP_SUBMINOR_VERSION (CUSP_VERSION % 100)
  40. math(EXPR CUSP_MAJOR_VERSION "${version} / 100000")
  41. math(EXPR CUSP_MINOR_VERSION "${version} / 100 % 1000")
  42. math(EXPR CUSP_PATCH_VERSION "${version} % 100")
  43. set(CUSP_VERSION "${CUSP_MAJOR_VERSION}.${CUSP_MINOR_VERSION}.${CUSP_PATCH_VERSION}")
  44. # Check for required components
  45. include(FindPackageHandleStandardArgs)
  46. find_package_handle_standard_args(Cusp REQUIRED_VARS CUSP_INCLUDE_DIR VERSION_VAR CUSP_VERSION)
  47. set(CUSP_INCLUDE_DIRS ${CUSP_INCLUDE_DIR})
  48. mark_as_advanced(CUSP_INCLUDE_DIR)