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

Handle when CMAKE_INSTALL_LIBDIR has nested directories #452

Merged
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion cmake/CubInstallRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ install(DIRECTORY "${CUB_SOURCE_DIR}/cub/cmake/"
)
# Need to configure a file to store the infix specified in
# CMAKE_INSTALL_INCLUDEDIR since it can be defined by the user
set(install_location "${CMAKE_INSTALL_LIBDIR}/cmake/cub")
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")
DESTINATION "${install_location}")
12 changes: 11 additions & 1 deletion cub/cmake/cub-header-search.cmake.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# Parse version information from version.h:
unset(_CUB_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search

# Find CMAKE_INSTALL_INCLUDEDIR=@CMAKE_INSTALL_INCLUDEDIR@ directory"
set(from_install_prefix "@install_location@")

# Transform to a list of directories, replace each directoy with "../"
# and convert back to a string
string(REGEX REPLACE "/" ";" from_install_prefix "${from_install_prefix}")
list(TRANSFORM from_install_prefix REPLACE ".+" "../")
list(JOIN from_install_prefix "" from_install_prefix)

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
"${CMAKE_CURRENT_LIST_DIR}/${from_install_prefix}/@CMAKE_INSTALL_INCLUDEDIR@"
)
set_property(CACHE _CUB_VERSION_INCLUDE_DIR PROPERTY TYPE INTERNAL)