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: Fix inconsistent thrust detection across the backends #92

Merged
merged 1 commit into from
Feb 7, 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
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ 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/${STDGPU_BACKEND_DIRECTORY}")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")


if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
Expand Down
File renamed without changes.
13 changes: 10 additions & 3 deletions src/stdgpu/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@

find_package(thrust 1.9.3 REQUIRED)


if(${CMAKE_BUILD_TYPE} MATCHES "Release" OR ${CMAKE_BUILD_TYPE} MATCHES "MinSizeRel")
set(STDGPU_ENABLE_CONTRACT_CHECKS_DEFAULT OFF)
else()
Expand All @@ -12,13 +15,13 @@ option(STDGPU_USE_32_BIT_INDEX "Use 32-bit instead of 64-bit signed integer for
option(STDGPU_USE_FAST_DESTROY "Use fast destruction of allocated arrays (filled with a default value) by omitting destructor calls in memory API, default: OFF" OFF)
option(STDGPU_USE_FIBONACCI_HASHING "Use Fibonacci Hashing instead of Modulo to compute hash bucket indices, default: ON" ON)


set(STDGPU_INCLUDE_LOCAL_DIR "${CMAKE_CURRENT_LIST_DIR}/..")
set(STDGPU_CONFIG_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/include")

configure_file("${STDGPU_INCLUDE_LOCAL_DIR}/stdgpu/config.h.in"
"${STDGPU_CONFIG_BUILD_DIR}/stdgpu/config.h")


if(STDGPU_BUILD_SHARED_LIBS)
add_library(stdgpu SHARED)
else()
Expand All @@ -29,17 +32,21 @@ target_sources(stdgpu PRIVATE impl/iterator.cpp
impl/memory.cpp
impl/limits.cpp)

add_subdirectory(${STDGPU_BACKEND_DIRECTORY})

target_include_directories(stdgpu PUBLIC
$<BUILD_INTERFACE:${STDGPU_INCLUDE_LOCAL_DIR}>
$<BUILD_INTERFACE:${STDGPU_CONFIG_BUILD_DIR}>
$<INSTALL_INTERFACE:${STDGPU_INCLUDE_INSTALL_DIR}>)

target_compile_features(stdgpu PUBLIC cxx_std_14)

target_link_libraries(stdgpu PUBLIC thrust::thrust)

add_library(stdgpu::stdgpu ALIAS stdgpu)


add_subdirectory(${STDGPU_BACKEND_DIRECTORY})


# Export targets and install header files
install(TARGETS stdgpu
EXPORT stdgpu-targets
Expand Down
2 changes: 2 additions & 0 deletions src/stdgpu/cuda/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ target_sources(stdgpu PRIVATE impl/memory.cpp
impl/bitset.cu
impl/mutex.cu)

target_compile_definitions(stdgpu PUBLIC THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_CUDA)

target_include_directories(stdgpu PUBLIC
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
4 changes: 1 addition & 3 deletions src/stdgpu/openmp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

find_package(thrust 1.9.3 REQUIRED)
find_package(OpenMP 2.0 REQUIRED)

target_sources(stdgpu PRIVATE impl/memory.cpp
Expand All @@ -8,5 +7,4 @@ target_sources(stdgpu PRIVATE impl/memory.cpp

target_compile_definitions(stdgpu PUBLIC THRUST_DEVICE_SYSTEM=THRUST_DEVICE_SYSTEM_OMP)

target_link_libraries(stdgpu PUBLIC OpenMP::OpenMP_CXX
thrust::thrust)
target_link_libraries(stdgpu PUBLIC OpenMP::OpenMP_CXX)