This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for importing CUB targets with add_subdirectory.
- Loading branch information
1 parent
60faccd
commit a39e385
Showing
6 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
find_package(CUB REQUIRED CONFIG | ||
NO_DEFAULT_PATH # Only check the explicit path in HINTS: | ||
HINTS "${CMAKE_CURRENT_LIST_DIR}/.." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
add_test( | ||
NAME cub.example.cmake.add_subdir | ||
COMMAND "${CMAKE_COMMAND}" | ||
--log-level=VERBOSE | ||
-G "${CMAKE_GENERATOR}" | ||
-S "${CMAKE_CURRENT_SOURCE_DIR}/add_subdir" | ||
-B "${CMAKE_CURRENT_BINARY_DIR}/add_subdir" | ||
-D "CUB_ROOT=${CUB_SOURCE_DIR}" | ||
-D "CMAKE_CUDA_COMPILER=${CMAKE_CUDA_COMPILER}" | ||
-D "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# This example demonstrates / tests adding CUB via a CMake add_subdirectory | ||
# call from a parent project. | ||
|
||
cmake_minimum_required(VERSION 3.15) | ||
|
||
# Silence warnings about empty CUDA_ARCHITECTURES properties on example targets: | ||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.18) | ||
cmake_policy(SET CMP0104 OLD) | ||
endif() | ||
|
||
project(CubAddSubDirExample CUDA) | ||
|
||
# Use your project's checkout of CUB here, for most cases | ||
# `add_subdirectory(cub)` will be sufficient. | ||
add_subdirectory("${CUB_ROOT}" cub) | ||
|
||
# Link the CUB::CUB target to your project's targets | ||
add_executable(HelloCUB dummy.cu) | ||
target_link_libraries(HelloCUB CUB::CUB) | ||
|
||
# | ||
# Validation | ||
# | ||
|
||
function(assert_target target_name) | ||
if (NOT TARGET "${target_name}") | ||
message(FATAL_ERROR "Target '${target_name}' not defined.") | ||
endif() | ||
endfunction() | ||
|
||
assert_target(CUB::CUB) | ||
assert_target(HelloCUB) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <cub/config.cuh> | ||
|
||
#include <iostream> | ||
|
||
int main() | ||
{ | ||
std::cout << "Hello from CUB version " << CUB_VERSION << ":\n"; | ||
} |