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

Support user defined CMAKE_INSTALL_INCLUDEDIR values #1584

Merged
merged 2 commits into from
Jan 12, 2022
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
19 changes: 17 additions & 2 deletions cmake/ThrustInstallRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,23 @@ include(GNUInstallDirs)
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)

install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust"
TYPE INCLUDE
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING
PATTERN "*.h"
PATTERN "*.inl"
)

install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/thrust"
PATTERN thrust-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("${Thrust_SOURCE_DIR}/thrust/cmake/thrust-header-search.cmake.in"
"${Thrust_BINARY_DIR}/thrust/cmake/thrust-header-search.cmake"
@ONLY)
install(FILES "${Thrust_BINARY_DIR}/thrust/cmake/thrust-header-search.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/thrust")

# Depending on how Thrust is configured, CUB's CMake scripts may or may not be
# included, so maintain a set of CUB install rules in both projects. By default
Expand All @@ -22,12 +30,19 @@ install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust/cmake/"
option(THRUST_INSTALL_CUB_HEADERS "Include cub headers when installing." ON)
if (THRUST_INSTALL_CUB_HEADERS)
install(DIRECTORY "${Thrust_SOURCE_DIR}/dependencies/cub/cub"
TYPE INCLUDE
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
FILES_MATCHING
PATTERN "*.cuh"
)

# Need to configure a file to store THRUST_INSTALL_HEADER_INFIX
install(DIRECTORY "${Thrust_SOURCE_DIR}/dependencies/cub/cub/cmake/"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cub"
PATTERN cub-header-search EXCLUDE
)
configure_file("${Thrust_SOURCE_DIR}/dependencies/cub/cub/cmake/cub-header-search.cmake.in"
"${Thrust_BINARY_DIR}/dependencies/cub/cub/cmake/cub-header-search.cmake"
@ONLY)
install(FILES "${Thrust_BINARY_DIR}/dependencies/cub/cub/cmake/cub-header-search.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/cub")
endif()
10 changes: 2 additions & 8 deletions thrust/cmake/thrust-config-version.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
# Parse version information from version.h:
unset(_THRUST_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search
find_path(_THRUST_VERSION_INCLUDE_DIR thrust/version.h
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 _THRUST_VERSION_INCLUDE_DIR PROPERTY TYPE INTERNAL)
include("${CMAKE_CURRENT_LIST_DIR}/thrust-header-search.cmake")

file(READ "${_THRUST_VERSION_INCLUDE_DIR}/thrust/version.h" THRUST_VERSION_HEADER)
string(REGEX MATCH "#define[ \t]+THRUST_VERSION[ \t]+([0-9]+)" DUMMY "${THRUST_VERSION_HEADER}")
set(THRUST_VERSION_FLAT ${CMAKE_MATCH_1})
Expand Down
8 changes: 8 additions & 0 deletions thrust/cmake/thrust-header-search.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Parse version information from version.h:
unset(_THRUST_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search
find_path(_THRUST_VERSION_INCLUDE_DIR thrust/version.h
NO_DEFAULT_PATH # Only search explicit paths below:
PATHS
"${CMAKE_CURRENT_LIST_DIR}/../.." # Source tree
)
set_property(CACHE _THRUST_VERSION_INCLUDE_DIR PROPERTY TYPE INTERNAL)
8 changes: 8 additions & 0 deletions thrust/cmake/thrust-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(_THRUST_VERSION_INCLUDE_DIR CACHE) # Clear old result to force search
find_path(_THRUST_VERSION_INCLUDE_DIR thrust/version.h
NO_DEFAULT_PATH # Only search explicit paths below:
PATHS
"${CMAKE_CURRENT_LIST_DIR}/../../../@CMAKE_INSTALL_INCLUDEDIR@"
)
set_property(CACHE _THRUST_VERSION_INCLUDE_DIR PROPERTY TYPE INTERNAL)