@@ -55,13 +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
- )
64
- target_link_libraries (test_common PUBLIC OpenSSL::Crypto OpenSSL::SSL )
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 )
65
73
target_compile_features (test_common PUBLIC cxx_std_17 )
66
74
if (MSVC )
67
75
target_compile_options (test_common PRIVATE /bigobj )
@@ -70,22 +78,19 @@ endif()
70
78
71
79
#=======================================================================
72
80
73
- add_library (common STATIC
74
- examples/start.cpp
75
- examples/main.cpp
76
- examples/boost_redis.cpp
77
- )
78
- 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 )
79
84
if (MSVC )
80
- target_compile_options (common PRIVATE /bigobj )
81
- 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 )
82
87
endif ()
83
88
84
89
# Executables
85
90
#=======================================================================
86
91
87
92
add_executable (cpp20_intro examples/cpp20_intro.cpp )
88
- target_link_libraries (cpp20_intro PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
93
+ target_link_libraries (cpp20_intro PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
89
94
target_compile_features (cpp20_intro PUBLIC cxx_std_20 )
90
95
add_test (cpp20_intro cpp20_intro )
91
96
if (MSVC )
@@ -94,7 +99,7 @@ if (MSVC)
94
99
endif ()
95
100
96
101
add_executable (cpp20_streams examples/cpp20_streams.cpp )
97
- target_link_libraries (cpp20_streams PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
102
+ target_link_libraries (cpp20_streams PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
98
103
target_compile_features (cpp20_streams PUBLIC cxx_std_20 )
99
104
if (MSVC )
100
105
target_compile_options (cpp20_streams PRIVATE /bigobj )
@@ -120,12 +125,12 @@ endif()
120
125
if (NOT MSVC )
121
126
add_executable (cpp20_chat_room examples/cpp20_chat_room.cpp )
122
127
target_compile_features (cpp20_chat_room PUBLIC cxx_std_20 )
123
- target_link_libraries (cpp20_chat_room PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
128
+ target_link_libraries (cpp20_chat_room PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
124
129
endif ()
125
130
126
131
add_executable (cpp20_containers examples/cpp20_containers.cpp )
127
132
target_compile_features (cpp20_containers PUBLIC cxx_std_20 )
128
- target_link_libraries (cpp20_containers PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
133
+ target_link_libraries (cpp20_containers PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
129
134
add_test (cpp20_containers cpp20_containers )
130
135
if (MSVC )
131
136
target_compile_options (cpp20_containers PRIVATE /bigobj )
@@ -135,12 +140,12 @@ endif()
135
140
if (NOT MSVC )
136
141
add_executable (cpp20_echo_server examples/cpp20_echo_server.cpp )
137
142
target_compile_features (cpp20_echo_server PUBLIC cxx_std_20 )
138
- target_link_libraries (cpp20_echo_server PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
143
+ target_link_libraries (cpp20_echo_server PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
139
144
endif ()
140
145
141
146
add_executable (cpp20_resolve_with_sentinel examples/cpp20_resolve_with_sentinel.cpp )
142
147
target_compile_features (cpp20_resolve_with_sentinel PUBLIC cxx_std_20 )
143
- target_link_libraries (cpp20_resolve_with_sentinel PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
148
+ target_link_libraries (cpp20_resolve_with_sentinel PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
144
149
#add_test(cpp20_resolve_with_sentinel cpp20_resolve_with_sentinel)
145
150
if (MSVC )
146
151
target_compile_options (cpp20_resolve_with_sentinel PRIVATE /bigobj )
@@ -149,7 +154,7 @@ endif()
149
154
150
155
add_executable (cpp20_json examples/cpp20_json.cpp )
151
156
target_compile_features (cpp20_json PUBLIC cxx_std_20 )
152
- target_link_libraries (cpp20_json PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
157
+ target_link_libraries (cpp20_json PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
153
158
add_test (cpp20_json cpp20_json )
154
159
if (MSVC )
155
160
target_compile_options (cpp20_json PRIVATE /bigobj )
@@ -160,7 +165,7 @@ if (Protobuf_FOUND)
160
165
protobuf_generate_cpp (PROTO_SRCS PROTO_HDRS examples/person.proto )
161
166
add_executable (cpp20_protobuf examples/cpp20_protobuf.cpp ${PROTO_SRCS} ${PROTO_HDRS} )
162
167
target_compile_features (cpp20_protobuf PUBLIC cxx_std_20 )
163
- target_link_libraries (cpp20_protobuf PRIVATE OpenSSL::Crypto OpenSSL::SSL common ${Protobuf_LIBRARIES} )
168
+ target_link_libraries (cpp20_protobuf PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common ${Protobuf_LIBRARIES} )
164
169
target_include_directories (cpp20_protobuf PUBLIC ${Protobuf_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR} )
165
170
add_test (cpp20_protobuf cpp20_protobuf )
166
171
if (MSVC )
@@ -171,7 +176,7 @@ endif()
171
176
172
177
add_executable (cpp20_subscriber examples/cpp20_subscriber.cpp )
173
178
target_compile_features (cpp20_subscriber PUBLIC cxx_std_20 )
174
- target_link_libraries (cpp20_subscriber PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
179
+ target_link_libraries (cpp20_subscriber PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
175
180
if (MSVC )
176
181
target_compile_options (cpp20_subscriber PRIVATE /bigobj )
177
182
target_compile_definitions (cpp20_subscriber PRIVATE _WIN32_WINNT=0x0601 )
@@ -180,7 +185,7 @@ endif()
180
185
add_executable (cpp20_intro_tls examples/cpp20_intro_tls.cpp )
181
186
target_compile_features (cpp20_intro_tls PUBLIC cxx_std_20 )
182
187
add_test (cpp20_intro_tls cpp20_intro_tls )
183
- target_link_libraries (cpp20_intro_tls PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
188
+ target_link_libraries (cpp20_intro_tls PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common )
184
189
if (MSVC )
185
190
target_compile_options (cpp20_intro_tls PRIVATE /bigobj )
186
191
target_compile_definitions (cpp20_intro_tls PRIVATE _WIN32_WINNT=0x0601 )
@@ -189,7 +194,7 @@ endif()
189
194
add_executable (cpp20_low_level_async tests/cpp20_low_level_async.cpp )
190
195
target_compile_features (cpp20_low_level_async PUBLIC cxx_std_20 )
191
196
add_test (cpp20_low_level_async cpp20_low_level_async )
192
- target_link_libraries (cpp20_low_level_async PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
197
+ target_link_libraries (cpp20_low_level_async PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common boost_redis_src )
193
198
if (MSVC )
194
199
target_compile_options (cpp20_low_level_async PRIVATE /bigobj )
195
200
target_compile_definitions (cpp20_low_level_async PRIVATE _WIN32_WINNT=0x0601 )
@@ -211,6 +216,7 @@ endif()
211
216
212
217
add_executable (cpp17_low_level_sync tests/cpp17_low_level_sync.cpp )
213
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 )
214
220
add_test (cpp17_low_level_sync cpp17_low_level_sync )
215
221
if (MSVC )
216
222
target_compile_options (cpp17_low_level_sync PRIVATE /bigobj )
@@ -255,7 +261,7 @@ endif()
255
261
256
262
add_executable (test_conn_reconnect tests/conn_reconnect.cpp )
257
263
target_compile_features (test_conn_reconnect PUBLIC cxx_std_20 )
258
- target_link_libraries (test_conn_reconnect PRIVATE OpenSSL::Crypto OpenSSL::SSL common test_common )
264
+ target_link_libraries (test_conn_reconnect PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common )
259
265
add_test (test_conn_reconnect test_conn_reconnect )
260
266
if (MSVC )
261
267
target_compile_options (test_conn_reconnect PRIVATE /bigobj )
@@ -265,14 +271,15 @@ endif()
265
271
add_executable (test_conn_tls tests/conn_tls.cpp )
266
272
add_test (test_conn_tls test_conn_tls )
267
273
target_compile_features (test_conn_tls PUBLIC cxx_std_17 )
268
- target_link_libraries (test_conn_tls PRIVATE OpenSSL::Crypto OpenSSL::SSL )
274
+ target_link_libraries (test_conn_tls PRIVATE OpenSSL::Crypto OpenSSL::SSL boost_redis_src )
269
275
if (MSVC )
270
276
target_compile_options (test_conn_tls PRIVATE /bigobj )
271
277
target_compile_definitions (test_conn_tls PRIVATE _WIN32_WINNT=0x0601 )
272
278
endif ()
273
279
274
280
add_executable (test_low_level tests/low_level.cpp )
275
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 )
276
283
add_test (test_low_level test_low_level )
277
284
if (MSVC )
278
285
target_compile_options (test_low_level PRIVATE /bigobj )
@@ -282,15 +289,15 @@ endif()
282
289
add_executable (test_conn_run_cancel tests/conn_run_cancel.cpp )
283
290
target_compile_features (test_conn_run_cancel PUBLIC cxx_std_20 )
284
291
add_test (test_conn_run_cancel test_conn_run_cancel )
285
- target_link_libraries (test_conn_run_cancel PRIVATE OpenSSL::Crypto OpenSSL::SSL )
292
+ target_link_libraries (test_conn_run_cancel PRIVATE OpenSSL::Crypto OpenSSL::SSL boost_redis_src )
286
293
if (MSVC )
287
294
target_compile_options (test_conn_run_cancel PRIVATE /bigobj )
288
295
target_compile_definitions (test_conn_run_cancel PRIVATE _WIN32_WINNT=0x0601 )
289
296
endif ()
290
297
291
298
add_executable (test_conn_exec_cancel tests/conn_exec_cancel.cpp )
292
299
target_compile_features (test_conn_exec_cancel PUBLIC cxx_std_20 )
293
- target_link_libraries (test_conn_exec_cancel PRIVATE OpenSSL::Crypto OpenSSL::SSL common test_common )
300
+ target_link_libraries (test_conn_exec_cancel PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
294
301
add_test (test_conn_exec_cancel test_conn_exec_cancel )
295
302
if (MSVC )
296
303
target_compile_options (test_conn_exec_cancel PRIVATE /bigobj )
@@ -299,7 +306,7 @@ endif()
299
306
300
307
add_executable (test_conn_exec_cancel2 tests/conn_exec_cancel2.cpp )
301
308
target_compile_features (test_conn_exec_cancel2 PUBLIC cxx_std_20 )
302
- target_link_libraries (test_conn_exec_cancel2 PRIVATE OpenSSL::Crypto OpenSSL::SSL common test_common )
309
+ target_link_libraries (test_conn_exec_cancel2 PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
303
310
add_test (test_conn_exec_cancel2 test_conn_exec_cancel2 )
304
311
if (MSVC )
305
312
target_compile_options (test_conn_exec_cancel2 PRIVATE /bigobj )
@@ -308,7 +315,7 @@ endif()
308
315
309
316
add_executable (test_conn_exec_error tests/conn_exec_error.cpp )
310
317
target_compile_features (test_conn_exec_error PUBLIC cxx_std_17 )
311
- target_link_libraries (test_conn_exec_error PRIVATE OpenSSL::Crypto OpenSSL::SSL common test_common )
318
+ target_link_libraries (test_conn_exec_error PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
312
319
add_test (test_conn_exec_error test_conn_exec_error )
313
320
if (MSVC )
314
321
target_compile_options (test_conn_exec_error PRIVATE /bigobj )
@@ -317,7 +324,7 @@ endif()
317
324
318
325
add_executable (test_conn_echo_stress tests/conn_echo_stress.cpp )
319
326
target_compile_features (test_conn_echo_stress PUBLIC cxx_std_20 )
320
- target_link_libraries (test_conn_echo_stress PRIVATE OpenSSL::Crypto OpenSSL::SSL common test_common )
327
+ target_link_libraries (test_conn_echo_stress PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
321
328
add_test (test_conn_echo_stress test_conn_echo_stress )
322
329
if (MSVC )
323
330
target_compile_options (test_conn_echo_stress PRIVATE /bigobj )
@@ -326,6 +333,7 @@ endif()
326
333
327
334
add_executable (test_request tests/request.cpp )
328
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 )
329
337
add_test (test_request test_request )
330
338
if (MSVC )
331
339
target_compile_options (test_request PRIVATE /bigobj )
@@ -334,7 +342,7 @@ endif()
334
342
335
343
add_executable (test_issue_50 tests/issue_50.cpp )
336
344
target_compile_features (test_issue_50 PUBLIC cxx_std_20 )
337
- target_link_libraries (test_issue_50 PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
345
+ target_link_libraries (test_issue_50 PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common boost_redis_src )
338
346
add_test (test_issue_50 test_issue_50 )
339
347
if (MSVC )
340
348
target_compile_options (test_issue_50 PRIVATE /bigobj )
@@ -343,7 +351,7 @@ endif()
343
351
344
352
add_executable (test_conn_check_health tests/conn_check_health.cpp )
345
353
target_compile_features (test_conn_check_health PUBLIC cxx_std_17 )
346
- target_link_libraries (test_conn_check_health PRIVATE OpenSSL::Crypto OpenSSL::SSL common )
354
+ target_link_libraries (test_conn_check_health PRIVATE OpenSSL::Crypto OpenSSL::SSL examples_common boost_redis_src )
347
355
add_test (test_conn_check_health test_conn_check_health )
348
356
if (MSVC )
349
357
target_compile_options (test_conn_check_health PRIVATE /bigobj )
@@ -352,7 +360,7 @@ endif()
352
360
353
361
add_executable (test_run tests/run.cpp )
354
362
target_compile_features (test_run PUBLIC cxx_std_17 )
355
- target_link_libraries (test_run PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common )
363
+ target_link_libraries (test_run PRIVATE OpenSSL::Crypto OpenSSL::SSL test_common boost_redis_src )
356
364
add_test (test_run test_run )
357
365
if (MSVC )
358
366
target_compile_options (test_run PRIVATE /bigobj )
0 commit comments