FindTHRUST.cmake 1.41 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
# Finder for thrust library
# thrust is template only, so only includes are searched
# 
# THRUST_INCLUDE_DIR Toplevel include dir containing thrust, includes have to be defined like <thrust/header.h>


IF (THRUST_INCLUDE_DIR)
  # Already in cache, be silent
  SET(THRUST_FIND_QUIETLY TRUE)
ENDIF (THRUST_INCLUDE_DIR)


find_path( THRUST_INCLUDE_DIR
    HINTS /usr/include /usr/local/include
    NAMES thrust/version.h
    DOC "Lib Thrust Include dir"
)

# ensure that we only get one
if( THRUST_INCLUDE_DIR )
    list( REMOVE_DUPLICATES THRUST_INCLUDE_DIR )
endif( THRUST_INCLUDE_DIR )

# Check for required components
if ( THRUST_INCLUDE_DIR )

    # Parse version file to get the thrust version numbers

    file( STRINGS ${THRUST_INCLUDE_DIR}/thrust/version.h
        version
        REGEX "#define THRUST_VERSION[ \t]+([0-9x]+)"
    )

    string( REGEX REPLACE "#define THRUST_VERSION[ \t]+" "" version ${version} )

    string( REGEX MATCH "^[0-9]" major ${version} )
    string( REGEX REPLACE "^${major}00" "" version ${version} )
    string( REGEX MATCH "^[0-9]" minor ${version} )
    string( REGEX REPLACE "^${minor}0" "" version ${version} )
    set( THRUST_VERSION "${major}.${minor}.${version}")


    SET( THRUST_FOUND TRUE )

    include( FindPackageHandleStandardArgs )
    find_package_handle_standard_args( Thrust
        REQUIRED_VARS
            THRUST_INCLUDE_DIR
        VERSION_VAR
            THRUST_VERSION
    )
 
endif()