diff --git a/cmake/ThrustInstallRules.cmake b/cmake/ThrustInstallRules.cmake index 4f4f4d0115..8a4117dd18 100644 --- a/cmake/ThrustInstallRules.cmake +++ b/cmake/ThrustInstallRules.cmake @@ -5,7 +5,7 @@ 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" @@ -13,7 +13,15 @@ install(DIRECTORY "${Thrust_SOURCE_DIR}/thrust" 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 @@ -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() diff --git a/thrust/cmake/thrust-config-version.cmake b/thrust/cmake/thrust-config-version.cmake index 28d68bbce3..8a12a862cd 100644 --- a/thrust/cmake/thrust-config-version.cmake +++ b/thrust/cmake/thrust-config-version.cmake @@ -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}) diff --git a/thrust/cmake/thrust-header-search.cmake b/thrust/cmake/thrust-header-search.cmake new file mode 100644 index 0000000000..643ec90b70 --- /dev/null +++ b/thrust/cmake/thrust-header-search.cmake @@ -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) diff --git a/thrust/cmake/thrust-header-search.cmake.in b/thrust/cmake/thrust-header-search.cmake.in new file mode 100644 index 0000000000..1f0ffd6c32 --- /dev/null +++ b/thrust/cmake/thrust-header-search.cmake.in @@ -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)