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.

51 lines
1.5 KiB

3 months ago
  1. #
  2. # FindThrust
  3. #
  4. # This module finds the Thrust header files and extracts their version. It
  5. # sets the following variables.
  6. #
  7. # THRUST_INCLUDE_DIR - Include directory for thrust header files. (All header
  8. # files will actually be in the thrust subdirectory.)
  9. # THRUST_VERSION - Version of thrust in the form "major.minor.patch".
  10. #
  11. # Thrust_FOUND - Indicates whether Thrust has been found
  12. #
  13. find_path(THRUST_INCLUDE_DIR
  14. HINTS
  15. /usr/include/cuda
  16. /usr/local/include
  17. /usr/local/cuda/include
  18. ${CUDA_INCLUDE_DIRS}
  19. NAMES thrust/version.h
  20. DOC "Thrust headers"
  21. )
  22. if(THRUST_INCLUDE_DIR)
  23. list(REMOVE_DUPLICATES THRUST_INCLUDE_DIR)
  24. endif(THRUST_INCLUDE_DIR)
  25. # Find thrust version
  26. file(STRINGS ${THRUST_INCLUDE_DIR}/thrust/version.h
  27. version
  28. REGEX "#define THRUST_VERSION[ \t]+([0-9x]+)"
  29. )
  30. string(REGEX REPLACE
  31. "#define THRUST_VERSION[ \t]+"
  32. ""
  33. version
  34. "${version}"
  35. )
  36. string(REGEX MATCH "^[0-9]" major ${version})
  37. string(REGEX REPLACE "^${major}00" "" version "${version}")
  38. string(REGEX MATCH "^[0-9]" minor ${version})
  39. string(REGEX REPLACE "^${minor}0" "" version "${version}")
  40. set(THRUST_VERSION "${major}.${minor}.${version}")
  41. set(THRUST_MAJOR_VERSION "${major}")
  42. set(THRUST_MINOR_VERSION "${minor}")
  43. # Check for required components
  44. include(FindPackageHandleStandardArgs)
  45. find_package_handle_standard_args(Thrust REQUIRED_VARS THRUST_INCLUDE_DIR VERSION_VAR THRUST_VERSION)
  46. set(THRUST_INCLUDE_DIRS ${THRUST_INCLUDE_DIR})
  47. mark_as_advanced(THRUST_INCLUDE_DIR)