-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
139 lines (125 loc) · 3.85 KB
/
CMakeLists.txt
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
138
139
cmake_minimum_required(VERSION 3.7)
project(argon2-gpu CXX)
set(BINARY_INSTALL_DIR /usr/local/bin)
set(LIBRARY_INSTALL_DIR /usr/local/lib)
set(INCLUDE_INSTALL_DIR /usr/local/include)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
enable_testing()
set(CUDA_FOUND FALSE)
if(NOT NO_CUDA)
find_package(CUDA)
endif()
if(CUDA_FOUND)
message("INFO: Using CUDA version ${CUDA_VERSION}")
add_definitions(-DHAVE_CUDA=1)
else()
message("INFO: Building without CUDA support")
add_definitions(-DHAVE_CUDA=0)
endif()
if(CUDA_FOUND)
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};
-std=c++11;-O3;--ptxas-options=-v;-arch sm_30;-lineinfo
)
endif()
add_subdirectory(ext/argon2)
add_library(argon2-gpu-common SHARED
lib/argon2-gpu-common/argon2params.cpp
lib/argon2-gpu-common/blake2b.cpp
)
target_include_directories(argon2-gpu-common INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_include_directories(argon2-gpu-common PRIVATE
include/argon2-gpu-common
lib/argon2-gpu-common
)
if(CUDA_FOUND)
cuda_add_library(argon2-cuda SHARED
lib/argon2-cuda/device.cpp
lib/argon2-cuda/globalcontext.cpp
lib/argon2-cuda/programcontext.cpp
lib/argon2-cuda/processingunit.cpp
lib/argon2-cuda/kernels.cu
)
else()
add_library(argon2-cuda SHARED
lib/argon2-cuda/nocuda.cpp
)
endif()
target_include_directories(argon2-cuda PRIVATE
include/argon2-cuda
lib/argon2-cuda
)
target_include_directories(argon2-cuda INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(argon2-cuda argon2-gpu-common)
add_library(argon2-opencl SHARED
lib/argon2-opencl/device.cpp
lib/argon2-opencl/globalcontext.cpp
lib/argon2-opencl/kernelloader.cpp
lib/argon2-opencl/programcontext.cpp
lib/argon2-opencl/processingunit.cpp
lib/argon2-opencl/kernelrunner.cpp
)
target_include_directories(argon2-opencl INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_include_directories(argon2-opencl PRIVATE
include/argon2-opencl
lib/argon2-opencl
)
target_link_libraries(argon2-opencl
argon2-gpu-common -lOpenCL
)
add_executable(argon2-gpu-test
src/argon2-gpu-test/main.cpp
src/argon2-gpu-test/testcase.cpp
)
target_include_directories(argon2-gpu-test PRIVATE src/argon2-gpu-test)
target_link_libraries(argon2-gpu-test
argon2-cuda argon2-opencl argon2 -lOpenCL
)
add_executable(argon2-gpu-bench
src/argon2-gpu-bench/cpuexecutive.cpp
src/argon2-gpu-bench/cudaexecutive.cpp
src/argon2-gpu-bench/openclexecutive.cpp
src/argon2-gpu-bench/benchmark.cpp
src/argon2-gpu-bench/main.cpp
)
target_include_directories(argon2-gpu-bench PRIVATE src/argon2-gpu-bench)
target_link_libraries(argon2-gpu-bench
argon2-cuda argon2-opencl argon2 -lOpenCL
)
add_test(argon2-gpu-test-opencl argon2-gpu-test -m opencl)
add_test(argon2-gpu-test-cuda argon2-gpu-test -m cuda)
install(
TARGETS argon2-gpu-common argon2-opencl argon2-cuda
DESTINATION ${LIBRARY_INSTALL_DIR}
)
install(FILES
include/argon2-gpu-common/argon2-common.h
include/argon2-gpu-common/argon2params.h
include/argon2-opencl/cl.hpp
include/argon2-opencl/opencl.h
include/argon2-opencl/device.h
include/argon2-opencl/globalcontext.h
include/argon2-opencl/programcontext.h
include/argon2-opencl/processingunit.h
include/argon2-opencl/kernelrunner.h
include/argon2-cuda/cudaexception.h
include/argon2-cuda/kernels.h
include/argon2-cuda/device.h
include/argon2-cuda/globalcontext.h
include/argon2-cuda/programcontext.h
include/argon2-cuda/processingunit.h
DESTINATION ${INCLUDE_INSTALL_DIR}
)
install(
TARGETS argon2-gpu-bench argon2-gpu-test
DESTINATION ${BINARY_INSTALL_DIR}
)