-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
177 lines (144 loc) · 2.63 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
cmake_minimum_required(VERSION 3.1)
project(crypto_benchmark)
option(hydrogen "Build libhydrogen benchmark" OFF)
option(nss "Build NSS benchmark" ON)
option(openssl "Build OpenSSL benchmark" ON)
option(sodium "Build libsodium benchmark" ON)
option(wolfcrypt "Build wolfCrypt benchmark" ON)
find_package(Threads
REQUIRED
)
if(nss OR sodium OR wolfcrypt)
find_package(PkgConfig
REQUIRED
)
endif()
if(wolfcrypt)
include(CheckIncludeFile)
endif()
add_executable(crypto_benchmark
"main.c"
"utils.c"
"utils.h"
)
target_link_libraries(crypto_benchmark
PRIVATE
Threads::Threads
)
if(hydrogen)
add_subdirectory(libhydrogen)
target_compile_definitions(crypto_benchmark
PRIVATE
"BENCHMARK_HYDROGEN"
)
target_sources(crypto_benchmark
PRIVATE
"hydrogen.c"
"hydrogen.h"
)
target_link_libraries(crypto_benchmark
PRIVATE
hydrogen::hydrogen
)
endif()
if(nss)
pkg_search_module(nss
REQUIRED
nss
)
target_compile_definitions(crypto_benchmark
PRIVATE
"BENCHMARK_NSS"
)
target_include_directories(crypto_benchmark
PRIVATE
${nss_INCLUDE_DIRS}
)
target_sources(crypto_benchmark
PRIVATE
"nss.c"
"nss.h"
)
target_link_libraries(crypto_benchmark
PRIVATE
${nss_LIBRARIES}
)
endif()
if(openssl)
find_package(OpenSSL
COMPONENTS Crypto
REQUIRED
)
target_compile_definitions(crypto_benchmark
PRIVATE
"BENCHMARK_OPENSSL"
)
target_sources(crypto_benchmark
PRIVATE
"openssl.c"
"openssl.h"
)
target_link_libraries(crypto_benchmark
PRIVATE
OpenSSL::Crypto
)
endif()
if(sodium)
pkg_search_module(libsodium
REQUIRED
libsodium
)
target_compile_definitions(crypto_benchmark
PRIVATE
"BENCHMARK_SODIUM"
)
target_include_directories(crypto_benchmark
PRIVATE
${libsodium_INCLUDE_DIRS}
)
target_sources(crypto_benchmark
PRIVATE
"sodium.c"
"sodium.h"
)
target_link_libraries(crypto_benchmark
PRIVATE
${libsodium_LIBRARIES}
)
endif()
if(wolfcrypt)
pkg_search_module(wolfssl
REQUIRED
wolfssl
)
# The official Ubuntu Bionic package doesn't provide the header.
check_include_file(
"wolfssl/options.h"
HAS_WOLFSSL_OPTIONS
CMAKE_REQUIRED_INCLUDES wolfssl_INCLUDE_DIRS
)
target_compile_definitions(crypto_benchmark
PRIVATE
"BENCHMARK_WOLFCRYPT"
"HAS_WOLFSSL_OPTIONS"
)
if(NOT HAS_WOLFSSL_OPTIONS)
target_include_directories(crypto_benchmark
PRIVATE
"${CMAKE_SOURCE_DIR}/include"
)
endif()
target_include_directories(crypto_benchmark
PRIVATE
${wolfssl_INCLUDE_DIRS}
)
target_sources(crypto_benchmark
PRIVATE
"wolfcrypt.c"
"wolfcrypt.h"
)
target_link_libraries(crypto_benchmark
PRIVATE
${wolfssl_LIBRARIES}
)
endif()