Skip to content
This repository was archived by the owner on Mar 21, 2024. It is now read-only.
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add libcu++ dependency.
  • Loading branch information
alliepiper committed May 16, 2022
commit f42070e314021a29efeb1550b54930b19bb8932c
67 changes: 59 additions & 8 deletions cub/cmake/cub-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ if (TARGET CUB::CUB)
return()
endif()

# Minimum supported libcudacxx version:
set(cub_libcudacxx_version 1.8.0)

function(_cub_declare_interface_alias alias_name ugly_name)
# 1) Only IMPORTED and ALIAS targets can be placed in a namespace.
# 2) When an IMPORTED library is linked to another target, its include
Expand All @@ -27,16 +30,64 @@ function(_cub_declare_interface_alias alias_name ugly_name)
endfunction()

#
# Setup targets
# Setup some internal cache variables
#

_cub_declare_interface_alias(CUB::CUB _CUB_CUB)
# Pull in the include dir detected by cub-config-version.cmake
set(_CUB_INCLUDE_DIR "${_CUB_VERSION_INCLUDE_DIR}"
CACHE INTERNAL "Location of CUB headers."
FORCE
)
unset(_CUB_VERSION_INCLUDE_DIR CACHE) # Clear tmp variable from cache

if (${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
set(_CUB_QUIET ON CACHE INTERNAL "Quiet mode enabled for CUB find_package calls." FORCE)
set(_CUB_QUIET_FLAG "QUIET" CACHE INTERNAL "" FORCE)
else()
set(_CUB_QUIET OFF CACHE INTERNAL "Quiet mode enabled for CUB find_package calls." FORCE)
set(_CUB_QUIET_FLAG "" CACHE INTERNAL "" FORCE)
endif()

#
# Setup dependencies
#

if (NOT TARGET CUB::libcudacxx)
if (TARGET Thrust::libcudacxx)
# Prefer the same libcudacxx as Thrust, if available:
_cub_declare_interface_alias(CUB::libcudacxx _CUB_libcudacxx)
target_link_libraries(_CUB_libcudacxx INTERFACE Thrust::libcudacxx)
else()
if (NOT TARGET libcudacxx::libcudacxx)
# First do a non-required search for any co-packaged versions.
# These are preferred.
find_package(libcudacxx ${cub_libcudacxx_version} CONFIG
${_CUB_QUIET_FLAG}
NO_DEFAULT_PATH # Only check the explicit HINTS below:
HINTS
"${_CUB_INCLUDE_DIR}/../libcudacxx" # Source layout
"${_CUB_CMAKE_DIR}/.." # Install layout
)

# A second required search allows externally packaged to be used and fails if
# no suitable package exists.
find_package(libcudacxx ${cub_libcudacxx_version} CONFIG
REQUIRED
${_CUB_QUIET_FLAG}
)
endif()
_cub_declare_interface_alias(CUB::libcudacxx _CUB_libcudacxx)
target_link_libraries(_CUB_libcudacxx INTERFACE libcudacxx::libcudacxx)
endif()
endif()

#
# Setup targets
#

_cub_declare_interface_alias(CUB::CUB _CUB_CUB)
target_include_directories(_CUB_CUB INTERFACE "${_CUB_INCLUDE_DIR}")
target_link_libraries(_CUB_CUB INTERFACE CUB::libcudacxx)

if (CUB_IGNORE_DEPRECATED_API OR THRUST_IGNORE_DEPRECATED_API)
target_compile_definitions(_CUB_CUB INTERFACE "CUB_IGNORE_DEPRECATED_API")
Expand All @@ -61,12 +112,12 @@ endif()
# Standardize version info
#

set(CUB_VERSION ${${CMAKE_FIND_PACKAGE_NAME}_VERSION} CACHE INTERNAL "")
set(CUB_VERSION_MAJOR ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_MAJOR} CACHE INTERNAL "")
set(CUB_VERSION_MINOR ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_MINOR} CACHE INTERNAL "")
set(CUB_VERSION_PATCH ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_PATCH} CACHE INTERNAL "")
set(CUB_VERSION_TWEAK ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_TWEAK} CACHE INTERNAL "")
set(CUB_VERSION_COUNT ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_COUNT} CACHE INTERNAL "")
set(CUB_VERSION ${${CMAKE_FIND_PACKAGE_NAME}_VERSION} CACHE INTERNAL "" FORCE)
set(CUB_VERSION_MAJOR ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_MAJOR} CACHE INTERNAL "" FORCE)
set(CUB_VERSION_MINOR ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_MINOR} CACHE INTERNAL "" FORCE)
set(CUB_VERSION_PATCH ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_PATCH} CACHE INTERNAL "" FORCE)
set(CUB_VERSION_TWEAK ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_TWEAK} CACHE INTERNAL "" FORCE)
set(CUB_VERSION_COUNT ${${CMAKE_FIND_PACKAGE_NAME}_VERSION_COUNT} CACHE INTERNAL "" FORCE)

include(FindPackageHandleStandardArgs)
if (NOT CUB_CONFIG)
Expand Down