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

Commit

Permalink
Merge pull request #415 from robertmaynard/cub_install_infix
Browse files Browse the repository at this point in the history
Support user defined CMAKE_INSTALL_INCLUDEDIR values
  • Loading branch information
alliepiper authored Jan 12, 2022
2 parents 899ee53 + cda9c7a commit 66e2be6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
10 changes: 9 additions & 1 deletion cmake/CubInstallRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,19 @@ include(GNUInstallDirs)
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)

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

install(DIRECTORY "${CUB_SOURCE_DIR}/cub/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cub"
PATTERN cub-header-search EXCLUDE
)
# Need to configure a file to store the infix specified in
# CMAKE_INSTALL_INCLUDEDIR since it can be defined by the user
configure_file("${CUB_SOURCE_DIR}/cub/cmake/cub-header-search.cmake.in"
"${CUB_BINARY_DIR}/cub/cmake/cub-header-search.cmake"
@ONLY)
install(FILES "${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}/../../../@CMAKE_INSTALL_INCLUDEDIR@" # Install tree
)
set_property(CACHE _CUB_VERSION_INCLUDE_DIR PROPERTY TYPE INTERNAL)

0 comments on commit 66e2be6

Please sign in to comment.