From 65d6b984ffebbaf4fc69420ad5c299355f470655 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 17 Dec 2021 12:09:47 -0500 Subject: [PATCH] Support custom infix directories when installing cub --- cmake/CubInstallRules.cmake | 7 +++++++ cub/cmake/cub-config-version.cmake | 10 ++-------- cub/cmake/cub-header-search.cmake | 7 +++++++ cub/cmake/cub-header-search.cmake.in | 8 ++++++++ 4 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 cub/cmake/cub-header-search.cmake create mode 100644 cub/cmake/cub-header-search.cmake.in diff --git a/cmake/CubInstallRules.cmake b/cmake/CubInstallRules.cmake index b2f05da2e9..2425ce4467 100644 --- a/cmake/CubInstallRules.cmake +++ b/cmake/CubInstallRules.cmake @@ -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") diff --git a/cub/cmake/cub-config-version.cmake b/cub/cmake/cub-config-version.cmake index a630b6a5ec..d715bc0b5a 100644 --- a/cub/cmake/cub-config-version.cmake +++ b/cub/cmake/cub-config-version.cmake @@ -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}) diff --git a/cub/cmake/cub-header-search.cmake b/cub/cmake/cub-header-search.cmake new file mode 100644 index 0000000000..97f98233f7 --- /dev/null +++ b/cub/cmake/cub-header-search.cmake @@ -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) \ No newline at end of file diff --git a/cub/cmake/cub-header-search.cmake.in b/cub/cmake/cub-header-search.cmake.in new file mode 100644 index 0000000000..d99cd7dd36 --- /dev/null +++ b/cub/cmake/cub-header-search.cmake.in @@ -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) \ No newline at end of file