Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: Install backend-specific find modules in subdirectories #117

Merged
merged 1 commit into from
Mar 18, 2020
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 CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ string(REGEX REPLACE "^STDGPU_BACKEND_" "" STDGPU_BACKEND_DIRECTORY ${STDGPU_BAC
string(TOLOWER ${STDGPU_BACKEND_DIRECTORY} STDGPU_BACKEND_DIRECTORY)


list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
# Backend-specific modules have higher priority than generic modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/${STDGPU_BACKEND_DIRECTORY}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")


if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
Expand Down
9 changes: 9 additions & 0 deletions cmake/stdgpu-dependencies.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
include(CMakeFindDependencyMacro)

set(STDGPU_BACKEND_DIRECTORY "@STDGPU_BACKEND_DIRECTORY@")

# Backend-specific modules have higher priority than generic modules
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/${STDGPU_BACKEND_DIRECTORY}")

@STDGPU_DEPENDENCIES_INIT@
@STDGPU_DEPENDENCIES_BACKEND_INIT@

list(POP_FRONT CMAKE_MODULE_PATH)
list(POP_FRONT CMAKE_MODULE_PATH)
8 changes: 4 additions & 4 deletions src/stdgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ set(STDGPU_BUILD_CMAKE_DIR "${CMAKE_CURRENT_BINARY_DIR}/cmake")
find_package(thrust 1.9.3 REQUIRED MODULE)

set(STDGPU_DEPENDENCIES_INIT "
list(PREPEND CMAKE_MODULE_PATH \${CMAKE_CURRENT_LIST_DIR})
find_dependency(thrust 1.9.3 REQUIRED MODULE)
list(POP_FRONT CMAKE_MODULE_PATH)
")


Expand All @@ -28,7 +26,8 @@ option(STDGPU_USE_FAST_DESTROY "Use fast destruction of allocated arrays (filled
option(STDGPU_USE_FIBONACCI_HASHING "Use Fibonacci Hashing instead of Modulo to compute hash bucket indices (deprecated), default: ON" ON)

configure_file("${STDGPU_INCLUDE_LOCAL_DIR}/stdgpu/config.h.in"
"${STDGPU_BUILD_INCLUDE_DIR}/stdgpu/config.h")
"${STDGPU_BUILD_INCLUDE_DIR}/stdgpu/config.h"
@ONLY)


if(STDGPU_BUILD_SHARED_LIBS)
Expand Down Expand Up @@ -72,7 +71,8 @@ install(DIRECTORY "${STDGPU_INCLUDE_LOCAL_DIR}/" "${STDGPU_BUILD_INCLUDE_DIR}/"

# Install dependencies file and custom thrust module
configure_file("${stdgpu_SOURCE_DIR}/cmake/stdgpu-dependencies.cmake.in"
"${STDGPU_BUILD_CMAKE_DIR}/stdgpu-dependencies.cmake")
"${STDGPU_BUILD_CMAKE_DIR}/stdgpu-dependencies.cmake"
@ONLY)

install(FILES "${STDGPU_BUILD_CMAKE_DIR}/stdgpu-dependencies.cmake"
DESTINATION "${CMAKE_INSTALL_PREFIX}/${STDGPU_CMAKE_INSTALL_DIR}"
Expand Down
4 changes: 1 addition & 3 deletions src/stdgpu/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
find_package(CUDAToolkit 10.0 REQUIRED MODULE)

set(STDGPU_DEPENDENCIES_BACKEND_INIT "
list(PREPEND CMAKE_MODULE_PATH \${CMAKE_CURRENT_LIST_DIR})
find_dependency(CUDAToolkit 10.0 REQUIRED MODULE)
list(POP_FRONT CMAKE_MODULE_PATH)
" PARENT_SCOPE)

target_sources(stdgpu PRIVATE impl/memory.cpp
Expand All @@ -18,5 +16,5 @@ target_link_libraries(stdgpu PUBLIC CUDA::cudart)

# Install custom CUDA module
install(FILES "${stdgpu_SOURCE_DIR}/cmake/${STDGPU_BACKEND_DIRECTORY}/FindCUDAToolkit.cmake"
DESTINATION "${CMAKE_INSTALL_PREFIX}/${STDGPU_CMAKE_INSTALL_DIR}"
DESTINATION "${CMAKE_INSTALL_PREFIX}/${STDGPU_CMAKE_INSTALL_DIR}/${STDGPU_BACKEND_DIRECTORY}"
COMPONENT stdgpu)