Skip to content

Commit

Permalink
FindThrust better matches CMake best practices
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard committed Feb 11, 2021
1 parent 211863b commit 120bdef
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions cmake/install/FindThrust.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ cmake_minimum_required(VERSION 3.17..3.18 FATAL_ERROR)
find_dependency(CUDAToolkit)

find_path(
Thrust_INCLUDE_DIRS
Thrust_INCLUDE_DIR
NAMES thrust/version.h
HINTS ${CUDAToolkit_INCLUDE_DIRS})

file(READ ${Thrust_INCLUDE_DIRS}/thrust/version.h _version_header)
file(READ ${Thrust_INCLUDE_DIR}/thrust/version.h _version_header)
string(REGEX MATCH "#define THRUST_VERSION ([0-9]*)" _match "${_version_header}")
math(EXPR major "${CMAKE_MATCH_1} / 100000")
math(EXPR minor "(${CMAKE_MATCH_1} / 100) % 1000")
Expand All @@ -47,10 +47,11 @@ set(Thrust_VERSION "${major}.${minor}.${subminor}")

find_package_handle_standard_args(
Thrust
REQUIRED_VARS Thrust_INCLUDE_DIRS
REQUIRED_VARS Thrust_INCLUDE_DIR
VERSION_VAR Thrust_VERSION)

if(Thrust_FOUND)
set(Thrust_INCLUDE_DIRS "${Thrust_INCLUDE_DIR}")
# Create wrapper function to handle situation where we can't use a regular IMPORTED INTERFACE
# target since that'll use -isystem, leading to the wrong search order with nvcc
function(thrust_create_target tgt)
Expand Down

0 comments on commit 120bdef

Please sign in to comment.