@@ -55,12 +55,21 @@ find_package(OpenSSL REQUIRED)
55
55
enable_testing ()
56
56
include_directories (include )
57
57
58
+ #=======================================================================
59
+
60
+ add_library (boost_redis_src STATIC examples/boost_redis.cpp )
61
+ target_compile_features (boost_redis_src PUBLIC cxx_std_20 )
62
+ if (MSVC )
63
+ target_compile_options (boost_redis_src PRIVATE /bigobj )
64
+ target_compile_definitions (boost_redis_src PRIVATE _WIN32_WINNT=0x0601 )
65
+ endif ()
66
+
58
67
# Main function for the examples.
59
68
#=======================================================================
60
69
61
- add_library (test_common STATIC
62
- tests/common.cpp
63
- )
70
+ add_library (test_common STATIC )
71
+ target_sources ( test_common PUBLIC tests/common.cpp )
72
+ target_link_libraries ( test_common PUBLIC OpenSSL::Crypto OpenSSL::SSL boost_redis_src )
64
73
target_compile_features (test_common PUBLIC cxx_std_17 )
65
74
if (MSVC )
66
75
target_compile_options (test_common PRIVATE /bigobj )
@@ -69,22 +78,19 @@ endif()
69
78
70
79
#=======================================================================
71
80
72
- add_library (common STATIC
73
- examples/start.cpp
74
- examples/main.cpp
75
- examples/boost_redis.cpp
76
- )
77
- target_compile_features (common PUBLIC cxx_std_20 )
81
+ add_library (examples_common STATIC examples/main.cpp )
82
+ target_compile_features (examples_common PUBLIC cxx_std_20 )
83
+ target_link_libraries (examples_common PRIVATE boost_redis_src )
78
84
if (MSVC )
79
- target_compile_options (common PRIVATE /bigobj )
80
- target_compile_definitions (common PRIVATE _WIN32_WINNT=0x0601 )
85
+ target_compile_options (examples_common PRIVATE /bigobj )
86
+ target_compile_definitions (examples_common PRIVATE _WIN32_WINNT=0x0601 )
81
87
endif ()
82
88
83
89
# Executables
84
90
#=======================================================================
85
91
86
92
add_executable (cpp20_intro examples/cpp20_intro.cpp )
87
- target_link_libraries (cpp20_intro common )
93
+ target_link_libraries (cpp20_intro PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
88
94
target_compile_features (cpp20_intro PUBLIC cxx_std_20 )
89
95
add_test (cpp20_intro cpp20_intro )
90
96
if (MSVC )
@@ -93,14 +99,15 @@ if (MSVC)
93
99
endif ()
94
100
95
101
add_executable (cpp20_streams examples/cpp20_streams.cpp )
96
- target_link_libraries (cpp20_streams common )
102
+ target_link_libraries (cpp20_streams PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
97
103
target_compile_features (cpp20_streams PUBLIC cxx_std_20 )
98
104
if (MSVC )
99
105
target_compile_options (cpp20_streams PRIVATE /bigobj )
100
106
target_compile_definitions (cpp20_streams PRIVATE _WIN32_WINNT=0x0601 )
101
107
endif ()
102
108
103
109
add_executable (cpp17_intro examples/cpp17_intro.cpp )
110
+ target_link_libraries (cpp17_intro PRIVATE OpenSSL::Crypto OpenSSL::SSL )
104
111
target_compile_features (cpp17_intro PUBLIC cxx_std_17 )
105
112
add_test (cpp17_intro cpp17_intro )
106
113
if (MSVC )
@@ -111,18 +118,19 @@ endif()
111
118
if (NOT MSVC )
112
119
add_executable (cpp17_intro_sync examples/cpp17_intro_sync.cpp )
113
120
target_compile_features (cpp17_intro_sync PUBLIC cxx_std_17 )
121
+ target_link_libraries (cpp17_intro_sync PRIVATE OpenSSL::Crypto OpenSSL::SSL )
114
122
add_test (cpp17_intro_sync cpp17_intro_sync )
115
123
endif ()
116
124
117
125
if (NOT MSVC )
118
126
add_executable (cpp20_chat_room examples/cpp20_chat_room.cpp )
119
127
target_compile_features (cpp20_chat_room PUBLIC cxx_std_20 )
120
- target_link_libraries (cpp20_chat_room common )
128
+ target_link_libraries (cpp20_chat_room PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
121
129
endif ()
122
130
123
131
add_executable (cpp20_containers examples/cpp20_containers.cpp )
124
132
target_compile_features (cpp20_containers PUBLIC cxx_std_20 )
125
- target_link_libraries (cpp20_containers common )
133
+ target_link_libraries (cpp20_containers PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
126
134
add_test (cpp20_containers cpp20_containers )
127
135
if (MSVC )
128
136
target_compile_options (cpp20_containers PRIVATE /bigobj )
@@ -132,12 +140,12 @@ endif()
132
140
if (NOT MSVC )
133
141
add_executable (cpp20_echo_server examples/cpp20_echo_server.cpp )
134
142
target_compile_features (cpp20_echo_server PUBLIC cxx_std_20 )
135
- target_link_libraries (cpp20_echo_server common )
143
+ target_link_libraries (cpp20_echo_server PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
136
144
endif ()
137
145
138
146
add_executable (cpp20_resolve_with_sentinel examples/cpp20_resolve_with_sentinel.cpp )
139
147
target_compile_features (cpp20_resolve_with_sentinel PUBLIC cxx_std_20 )
140
- target_link_libraries (cpp20_resolve_with_sentinel common )
148
+ target_link_libraries (cpp20_resolve_with_sentinel PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
141
149
#add_test(cpp20_resolve_with_sentinel cpp20_resolve_with_sentinel)
142
150
if (MSVC )
143
151
target_compile_options (cpp20_resolve_with_sentinel PRIVATE /bigobj )
@@ -146,7 +154,7 @@ endif()
146
154
147
155
add_executable (cpp20_json examples/cpp20_json.cpp )
148
156
target_compile_features (cpp20_json PUBLIC cxx_std_20 )
149
- target_link_libraries (cpp20_json common )
157
+ target_link_libraries (cpp20_json PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
150
158
add_test (cpp20_json cpp20_json )
151
159
if (MSVC )
152
160
target_compile_options (cpp20_json PRIVATE /bigobj )
@@ -157,7 +165,7 @@ if (Protobuf_FOUND)
157
165
protobuf_generate_cpp (PROTO_SRCS PROTO_HDRS examples/person.proto )
158
166
add_executable (cpp20_protobuf examples/cpp20_protobuf.cpp ${PROTO_SRCS} ${PROTO_HDRS} )
159
167
target_compile_features (cpp20_protobuf PUBLIC cxx_std_20 )
160
- target_link_libraries (cpp20_protobuf common ${Protobuf_LIBRARIES} )
168
+ target_link_libraries (cpp20_protobuf PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common ${Protobuf_LIBRARIES} )
161
169
target_include_directories (cpp20_protobuf PUBLIC ${Protobuf_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} )
162
170
add_test (cpp20_protobuf cpp20_protobuf )
163
171
if (MSVC )
@@ -168,7 +176,7 @@ endif()
168
176
169
177
add_executable (cpp20_subscriber examples/cpp20_subscriber.cpp )
170
178
target_compile_features (cpp20_subscriber PUBLIC cxx_std_20 )
171
- target_link_libraries (cpp20_subscriber common )
179
+ target_link_libraries (cpp20_subscriber PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
172
180
if (MSVC )
173
181
target_compile_options (cpp20_subscriber PRIVATE /bigobj )
174
182
target_compile_definitions (cpp20_subscriber PRIVATE _WIN32_WINNT=0x0601 )
@@ -177,8 +185,7 @@ endif()
177
185
add_executable (cpp20_intro_tls examples/cpp20_intro_tls.cpp )
178
186
target_compile_features (cpp20_intro_tls PUBLIC cxx_std_20 )
179
187
add_test (cpp20_intro_tls cpp20_intro_tls )
180
- target_link_libraries (cpp20_intro_tls OpenSSL::Crypto OpenSSL::SSL )
181
- target_link_libraries (cpp20_intro_tls common )
188
+ target_link_libraries (cpp20_intro_tls PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
182
189
if (MSVC )
183
190
target_compile_options (cpp20_intro_tls PRIVATE /bigobj )
184
191
target_compile_definitions (cpp20_intro_tls PRIVATE _WIN32_WINNT=0x0601 )
@@ -187,7 +194,7 @@ endif()
187
194
add_executable (cpp20_low_level_async tests/cpp20_low_level_async.cpp )
188
195
target_compile_features (cpp20_low_level_async PUBLIC cxx_std_20 )
189
196
add_test (cpp20_low_level_async cpp20_low_level_async )
190
- target_link_libraries (cpp20_low_level_async common )
197
+ target_link_libraries (cpp20_low_level_async PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common boost_redis_src )
191
198
if (MSVC )
192
199
target_compile_options (cpp20_low_level_async PRIVATE /bigobj )
193
200
target_compile_definitions (cpp20_low_level_async PRIVATE _WIN32_WINNT=0x0601 )
@@ -209,6 +216,7 @@ endif()
209
216
210
217
add_executable (cpp17_low_level_sync tests/cpp17_low_level_sync.cpp )
211
218
target_compile_features (cpp17_low_level_sync PUBLIC cxx_std_17 )
219
+ target_link_libraries (cpp17_low_level_sync PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common boost_redis_src )
212
220
add_test (cpp17_low_level_sync cpp17_low_level_sync )
213
221
if (MSVC )
214
222
target_compile_options (cpp17_low_level_sync PRIVATE /bigobj )
@@ -217,7 +225,7 @@ endif()
217
225
218
226
add_executable (test_conn_exec tests/conn_exec.cpp )
219
227
target_compile_features (test_conn_exec PUBLIC cxx_std_20 )
220
- target_link_libraries (test_conn_exec test_common )
228
+ target_link_libraries (test_conn_exec PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common )
221
229
add_test (test_conn_exec test_conn_exec )
222
230
if (MSVC )
223
231
target_compile_options (test_conn_exec PRIVATE /bigobj )
@@ -226,7 +234,7 @@ endif()
226
234
227
235
add_executable (test_conn_exec_retry tests/conn_exec_retry.cpp )
228
236
target_compile_features (test_conn_exec_retry PUBLIC cxx_std_20 )
229
- target_link_libraries (test_conn_exec_retry test_common )
237
+ target_link_libraries (test_conn_exec_retry PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common )
230
238
add_test (test_conn_exec_retry test_conn_exec_retry )
231
239
if (MSVC )
232
240
target_compile_options (test_conn_exec_retry PRIVATE /bigobj )
@@ -235,7 +243,7 @@ endif()
235
243
236
244
add_executable (test_conn_push tests/conn_push.cpp )
237
245
target_compile_features (test_conn_push PUBLIC cxx_std_20 )
238
- target_link_libraries (test_conn_push test_common )
246
+ target_link_libraries (test_conn_push PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common )
239
247
add_test (test_conn_push test_conn_push )
240
248
if (MSVC )
241
249
target_compile_options (test_conn_push PRIVATE /bigobj )
@@ -244,6 +252,7 @@ endif()
244
252
245
253
add_executable (test_conn_quit tests/conn_quit.cpp )
246
254
target_compile_features (test_conn_quit PUBLIC cxx_std_17 )
255
+ target_link_libraries (test_conn_quit PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common )
247
256
add_test (test_conn_quit test_conn_quit )
248
257
if (MSVC )
249
258
target_compile_options (test_conn_quit PRIVATE /bigobj )
@@ -252,7 +261,7 @@ endif()
252
261
253
262
add_executable (test_conn_reconnect tests/conn_reconnect.cpp )
254
263
target_compile_features (test_conn_reconnect PUBLIC cxx_std_20 )
255
- target_link_libraries (test_conn_reconnect common test_common )
264
+ target_link_libraries (test_conn_reconnect PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common )
256
265
add_test (test_conn_reconnect test_conn_reconnect )
257
266
if (MSVC )
258
267
target_compile_options (test_conn_reconnect PRIVATE /bigobj )
@@ -262,14 +271,15 @@ endif()
262
271
add_executable (test_conn_tls tests/conn_tls.cpp )
263
272
add_test (test_conn_tls test_conn_tls )
264
273
target_compile_features (test_conn_tls PUBLIC cxx_std_17 )
265
- target_link_libraries (test_conn_tls OpenSSL::Crypto OpenSSL::SSL )
274
+ target_link_libraries (test_conn_tls PRIVATE OpenSSL::Crypto OpenSSL::SSL boost_redis_src )
266
275
if (MSVC )
267
276
target_compile_options (test_conn_tls PRIVATE /bigobj )
268
277
target_compile_definitions (test_conn_tls PRIVATE _WIN32_WINNT=0x0601 )
269
278
endif ()
270
279
271
280
add_executable (test_low_level tests/low_level.cpp )
272
281
target_compile_features (test_low_level PUBLIC cxx_std_17 )
282
+ target_link_libraries (test_low_level PRIVATE OpenSSL::Crypto OpenSSL::SSL boost_redis_src )
273
283
add_test (test_low_level test_low_level )
274
284
if (MSVC )
275
285
target_compile_options (test_low_level PRIVATE /bigobj )
@@ -279,14 +289,15 @@ endif()
279
289
add_executable (test_conn_run_cancel tests/conn_run_cancel.cpp )
280
290
target_compile_features (test_conn_run_cancel PUBLIC cxx_std_20 )
281
291
add_test (test_conn_run_cancel test_conn_run_cancel )
292
+ target_link_libraries (test_conn_run_cancel PRIVATE OpenSSL::Crypto OpenSSL::SSL boost_redis_src )
282
293
if (MSVC )
283
294
target_compile_options (test_conn_run_cancel PRIVATE /bigobj )
284
295
target_compile_definitions (test_conn_run_cancel PRIVATE _WIN32_WINNT=0x0601 )
285
296
endif ()
286
297
287
298
add_executable (test_conn_exec_cancel tests/conn_exec_cancel.cpp )
288
299
target_compile_features (test_conn_exec_cancel PUBLIC cxx_std_20 )
289
- target_link_libraries (test_conn_exec_cancel common test_common )
300
+ target_link_libraries (test_conn_exec_cancel PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
290
301
add_test (test_conn_exec_cancel test_conn_exec_cancel )
291
302
if (MSVC )
292
303
target_compile_options (test_conn_exec_cancel PRIVATE /bigobj )
@@ -295,7 +306,7 @@ endif()
295
306
296
307
add_executable (test_conn_exec_cancel2 tests/conn_exec_cancel2.cpp )
297
308
target_compile_features (test_conn_exec_cancel2 PUBLIC cxx_std_20 )
298
- target_link_libraries (test_conn_exec_cancel2 common test_common )
309
+ target_link_libraries (test_conn_exec_cancel2 PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
299
310
add_test (test_conn_exec_cancel2 test_conn_exec_cancel2 )
300
311
if (MSVC )
301
312
target_compile_options (test_conn_exec_cancel2 PRIVATE /bigobj )
@@ -304,7 +315,7 @@ endif()
304
315
305
316
add_executable (test_conn_exec_error tests/conn_exec_error.cpp )
306
317
target_compile_features (test_conn_exec_error PUBLIC cxx_std_17 )
307
- target_link_libraries (test_conn_exec_error common test_common )
318
+ target_link_libraries (test_conn_exec_error PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
308
319
add_test (test_conn_exec_error test_conn_exec_error )
309
320
if (MSVC )
310
321
target_compile_options (test_conn_exec_error PRIVATE /bigobj )
@@ -313,7 +324,7 @@ endif()
313
324
314
325
add_executable (test_conn_echo_stress tests/conn_echo_stress.cpp )
315
326
target_compile_features (test_conn_echo_stress PUBLIC cxx_std_20 )
316
- target_link_libraries (test_conn_echo_stress common test_common )
327
+ target_link_libraries (test_conn_echo_stress PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
317
328
add_test (test_conn_echo_stress test_conn_echo_stress )
318
329
if (MSVC )
319
330
target_compile_options (test_conn_echo_stress PRIVATE /bigobj )
@@ -322,6 +333,7 @@ endif()
322
333
323
334
add_executable (test_request tests/request.cpp )
324
335
target_compile_features (test_request PUBLIC cxx_std_17 )
336
+ target_link_libraries (test_request PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
325
337
add_test (test_request test_request )
326
338
if (MSVC )
327
339
target_compile_options (test_request PRIVATE /bigobj )
@@ -330,7 +342,7 @@ endif()
330
342
331
343
add_executable (test_issue_50 tests/issue_50.cpp )
332
344
target_compile_features (test_issue_50 PUBLIC cxx_std_20 )
333
- target_link_libraries (test_issue_50 common )
345
+ target_link_libraries (test_issue_50 PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common boost_redis_src )
334
346
add_test (test_issue_50 test_issue_50 )
335
347
if (MSVC )
336
348
target_compile_options (test_issue_50 PRIVATE /bigobj )
@@ -339,7 +351,7 @@ endif()
339
351
340
352
add_executable (test_conn_check_health tests/conn_check_health.cpp )
341
353
target_compile_features (test_conn_check_health PUBLIC cxx_std_17 )
342
- target_link_libraries (test_conn_check_health common )
354
+ target_link_libraries (test_conn_check_health PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common boost_redis_src )
343
355
add_test (test_conn_check_health test_conn_check_health )
344
356
if (MSVC )
345
357
target_compile_options (test_conn_check_health PRIVATE /bigobj )
@@ -348,7 +360,7 @@ endif()
348
360
349
361
add_executable (test_run tests/run.cpp )
350
362
target_compile_features (test_run PUBLIC cxx_std_17 )
351
- target_link_libraries (test_run test_common )
363
+ target_link_libraries (test_run PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
352
364
add_test (test_run test_run )
353
365
if (MSVC )
354
366
target_compile_options (test_run PRIVATE /bigobj )
0 commit comments