Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Commit

Permalink
Support custom infix directories when installing cub
Browse files Browse the repository at this point in the history
  • Loading branch information
robertmaynard committed Dec 17, 2021
1 parent b105781 commit 65d6b98
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
7 changes: 7 additions & 0 deletions cmake/CubInstallRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)

install(DIRECTORY "${CUB_SOURCE_DIR}/cub"
TYPE INCLUDE
DESTINATION include/${CUB_INSTALL_HEADER_INFIX}
FILES_MATCHING
PATTERN "*.cuh"
)

install(DIRECTORY "${CUB_SOURCE_DIR}/cub/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cub"
PATTERN cub-header-search EXCLUDE
)
configure_file("${CUB_SOURCE_DIR}/cub/cmake/cub-header-search.cmake.in"
"${CUB_BINARY_DIR}/cub/cmake/cub-header-search.cmake"
@ONLY)
install(FILE "${CUB_BINARY_DIR}/cub/cmake/cub-header-search.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cub")
10 changes: 2 additions & 8 deletions cub/cmake/cub-config-version.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# Parse version information from version.cuh:
unset(_CUB_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search
find_path(_CUB_VERSION_INCLUDE_DIR cub/version.cuh
NO_DEFAULT_PATH # Only search explicit paths below:
PATHS
${CMAKE_CURRENT_LIST_DIR}/../.. # Source tree
${CMAKE_CURRENT_LIST_DIR}/../../../include # Install tree
)
set_property(CACHE _CUB_VERSION_INCLUDE_DIR PROPERTY TYPE INTERNAL)
include(${CMAKE_CURRENT_LIST_DIR}/cub-header-search.cmake)

file(READ "${_CUB_VERSION_INCLUDE_DIR}/cub/version.cuh" CUB_VERSION_HEADER)
string(REGEX MATCH "#define[ \t]+CUB_VERSION[ \t]+([0-9]+)" DUMMY "${CUB_VERSION_HEADER}")
set(CUB_VERSION_FLAT ${CMAKE_MATCH_1})
Expand Down
7 changes: 7 additions & 0 deletions cub/cmake/cub-header-search.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
unset(_CUB_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search
find_path(_CUB_VERSION_INCLUDE_DIR cub/version.cuh
NO_DEFAULT_PATH # Only search explicit paths below:
PATHS
${CMAKE_CURRENT_LIST_DIR}/../.. # Source tree
)
set_property(CACHE _CUB_VERSION_INCLUDE_DIR PROPERTY TYPE INTERNAL)
8 changes: 8 additions & 0 deletions cub/cmake/cub-header-search.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Parse version information from version.h:
unset(_CUB_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search
find_path(_CUB_VERSION_INCLUDE_DIR cub/version.cuh
NO_DEFAULT_PATH # Only search explicit paths below:
PATHS
${CMAKE_CURRENT_LIST_DIR}/../../../include/@CUB_INSTALL_HEADER_INFIX@ # Install tree
)
set_property(CACHE _CUB_VERSION_INCLUDE_DIR PROPERTY TYPE INTERNAL)

0 comments on commit 65d6b98

Please sign in to comment.