Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
137 lines (114 loc) · 3.8 KB
/
Copy pathCMakeLists.txt
File metadata and controls
137 lines (114 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
cmake_minimum_required(VERSION 3.18)
# 3.18: first class CUDA support, CUDAToolkit package and CUDA_ARCHITECTURES
# Build for the GPU(s) of this machine unless architectures are given explicitly
# (e.g. -DCMAKE_CUDA_ARCHITECTURES="86;89"). "native" needs CMake >= 3.24.
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.24)
set(CMAKE_CUDA_ARCHITECTURES native)
else()
set(CMAKE_CUDA_ARCHITECTURES 75)
endif()
endif()
project(cuNSearch LANGUAGES CXX CUDA)
find_package(CUDAToolkit REQUIRED)
# Visual studio solution directories.
set_property(GLOBAL PROPERTY USE_FOLDERS on)
option(CUNSEARCH_USE_DOUBLE_PRECISION "Use double precision." ON)
if(CUNSEARCH_USE_DOUBLE_PRECISION)
message(STATUS "cuNSearch::Real = double")
else()
message(STATUS "cuNSearch::Real = float")
endif(CUNSEARCH_USE_DOUBLE_PRECISION)
# Note: CUNSEARCH_USE_DOUBLE_PRECISION is set as a PUBLIC compile definition of the cuNSearch
# target below, so that targets linking cuNSearch see the same Real type as the library.
OPTION(BUILD_AS_SHARED_LIBS "Build all the libraries as shared" OFF)
if (BUILD_AS_SHARED_LIBS)
if(WIN32)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON CACHE BOOL "Export all symbols")
endif(WIN32)
endif (BUILD_AS_SHARED_LIBS)
# CUDA 13 (CCCL/Thrust) requires C++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
# CCCL requires MSVC's standard conforming preprocessor
if(MSVC)
add_compile_options(
$<$<COMPILE_LANGUAGE:CXX>:/Zc:preprocessor>
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/Zc:preprocessor>)
endif()
SET(CMAKE_DEBUG_POSTFIX "_d")
set (INCLUDE_HEADERS
include/PointSet.h
include/ActivationTable.h
include/Common.h
include/cuNSearch.h
include/DeviceNeighborList.h
)
set (HEADER_FILES
src/Types.h
src/cuNSearchDeviceData.h
src/GridInfo.h
src/NotImplementedException.h
src/PointSetImplementation.h
src/cuNSearchKernels.cuh
src/helper_mortonCode.h
Utils/cuda_helper.h
Utils/Timing.h
Utils/IDFactory.h
)
set (SOURCE_FILES
src/PointSet.cu
src/PointSetImplementation.cu
src/cuNSearch.cu
src/cuNSearchDeviceData.cu
src/cuNSearchKernels.cu
Utils/cuda_helper.cu
Utils/Timing.cpp
Utils/IDFactory.cpp
)
if(BUILD_AS_SHARED_LIBS)
add_library(cuNSearch SHARED ${INCLUDE_HEADERS} ${HEADER_FILES} ${SOURCE_FILES})
else()
add_library(cuNSearch STATIC ${INCLUDE_HEADERS} ${HEADER_FILES} ${SOURCE_FILES})
endif()
include(GenerateExportHeader)
generate_export_header(cuNSearch
BASE_NAME cuNSearch
EXPORT_MACRO_NAME cuNSearch_EXPORT
EXPORT_FILE_NAME ${CMAKE_CURRENT_BINARY_DIR}/cuNSearch/cuNSearch_export.h
)
target_include_directories(cuNSearch PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/Utils
# Directory of the generated cuNSearch_export.h (CMAKE_CURRENT_BINARY_DIR, not
# CMAKE_BINARY_DIR, so that cuNSearch also works when added via add_subdirectory()).
${CMAKE_CURRENT_BINARY_DIR}/cuNSearch
)
target_link_libraries(cuNSearch PUBLIC CUDA::cudart)
target_compile_definitions(cuNSearch PUBLIC $<$<CONFIG:DEBUG>:DEBUG>)
if(CUNSEARCH_USE_DOUBLE_PRECISION)
# PUBLIC: Real must be the same type in the library and in all code using its headers.
target_compile_definitions(cuNSearch PUBLIC CUNSEARCH_USE_DOUBLE_PRECISION)
endif()
list(APPEND INCLUDE_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/cuNSearch/cuNSearch_export.h)
install(FILES ${INCLUDE_HEADERS}
DESTINATION include/)
install(TARGETS cuNSearch
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
enable_testing()
option(BUILD_DEMO "Build example of how to use this library."
ON)
if(BUILD_DEMO)
add_subdirectory(demo)
endif(BUILD_DEMO)
option(BUILD_TESTS "Build the tests (comparison with brute-force neighborhood search)." ON)
if(BUILD_TESTS)
add_subdirectory(tests)
endif(BUILD_TESTS)
unset(USE_DOUBLE_PRECISION CACHE)