forked from rsocket/rsocket-cpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
675 lines (573 loc) · 19.1 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
cmake_minimum_required(VERSION 3.2)
# The RSOCKET_CC CMake variable specifies the C compiler, e.g. gcc-4.9.
# The C++ compiler name is obtained by replacing "gcc" with "g++" and "clang"
# with "clang++"". If RSOCKET_CC is not given, the compiler is detected
# automatically.
if (RSOCKET_CC)
set(ENV{CC} ${RSOCKET_CC})
if (${RSOCKET_CC} MATCHES clang)
string(REPLACE clang clang++ CXX ${RSOCKET_CC})
else ()
string(REPLACE gcc g++ CXX ${RSOCKET_CC})
endif ()
set(ENV{CXX} ${CXX})
endif ()
project(ReactiveSocket)
# CMake modules.
set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")
# Joins arguments and stores the result in ${var}.
function(join var)
unset(result)
foreach (arg ${ARGN})
if (DEFINED result)
set(result "${result}${arg}")
else ()
set(result "${arg}")
endif ()
endforeach ()
set(${var} "${result}" PARENT_SCOPE)
endfunction()
# Generate compilation database for use by YouCompleteMe.
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
# make sure to bail on in-source builds for cleanliness
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory)"
"and run CMake from there. You may need to remove CMakeCache.txt.")
endif()
# default built type is Debug
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build" FORCE)
endif(NOT CMAKE_BUILD_TYPE)
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
# Enable ASAN by default on debug macOS builds.
if (APPLE)
set(OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
if ("${BUILD_TYPE_LOWER}" MATCHES "debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address,integer -fno-sanitize=unsigned-integer-overflow")
endif()
endif()
# Add compiler-specific options.
if (CMAKE_COMPILER_IS_GNUCXX)
if (RSOCKET_ASAN)
set(ASAN_FLAGS -fsanitize=address,undefined)
endif ()
set(EXTRA_LINK_FLAGS ${EXTRA_LINK_FLAGS} -fuse-ld=gold)
# Enable code coverage.
add_compile_options(--coverage)
set(EXTRA_LINK_FLAGS ${EXTRA_LINK_FLAGS} --coverage)
set(COVERAGE_INFO coverage.info)
add_custom_command(
OUTPUT ${COVERAGE_INFO}
# Capture coverage info.
COMMAND lcov --directory . --capture --output-file ${COVERAGE_INFO}
# Filter out system and test code.
COMMAND lcov --remove ${COVERAGE_INFO} 'tests/*' 'test/*' 'tck-test/*' '/usr/*' 'gmock/*' 'folly/*' --output-file
${COVERAGE_INFO}
# Debug before upload.
COMMAND lcov --list ${COVERAGE_INFO})
elseif (${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
if (RSOCKET_ASAN)
set(ASAN_FLAGS
-fsanitize=address,undefined,integer
-fno-sanitize=unsigned-integer-overflow)
endif ()
endif ()
if (DEFINED ASAN_FLAGS)
add_compile_options(${ASAN_FLAGS})
set(EXTRA_LINK_FLAGS ${EXTRA_LINK_FLAGS} ${ASAN_FLAGS})
endif ()
add_custom_target(coverage DEPENDS ${COVERAGE_INFO})
option(BUILD_BENCHMARKS "Build benchmarks" ON)
enable_testing()
include(ExternalProject)
include(CTest)
if (NOT FOLLY_INSTALL_DIR)
set(FOLLY_INSTALL_DIR $ENV{HOME}/folly)
endif ()
# Check if the correct version of folly is already installed.
set(FOLLY_VERSION v2017.07.10.00)
set(FOLLY_VERSION_FILE ${FOLLY_INSTALL_DIR}/${FOLLY_VERSION})
if (RSOCKET_INSTALL_DEPS)
if (NOT EXISTS ${FOLLY_VERSION_FILE})
# Remove the old version of folly.
file(REMOVE_RECURSE ${FOLLY_INSTALL_DIR})
set(INSTALL_FOLLY True)
endif ()
endif ()
if (INSTALL_FOLLY)
# Build and install folly.
ExternalProject_Add(
folly-ext
GIT_REPOSITORY https://github.com/facebook/folly
GIT_TAG ${FOLLY_VERSION}
BINARY_DIR folly-ext-prefix/src/folly-ext/folly
CONFIGURE_COMMAND autoreconf -ivf
COMMAND ./configure CXX=${CMAKE_CXX_COMPILER}
--prefix=${FOLLY_INSTALL_DIR}
BUILD_COMMAND make -j4
INSTALL_COMMAND make install
COMMAND cmake -E touch ${FOLLY_VERSION_FILE})
set(FOLLY_INCLUDE_DIR ${FOLLY_INSTALL_DIR}/include)
set(lib ${CMAKE_SHARED_LIBRARY_PREFIX}folly${CMAKE_SHARED_LIBRARY_SUFFIX})
set(FOLLY_LIBRARY ${FOLLY_INSTALL_DIR}/lib/${lib})
# CMake requires directories listed in INTERFACE_INCLUDE_DIRECTORIES to exist.
file(MAKE_DIRECTORY ${FOLLY_INCLUDE_DIR})
else ()
# Use installed folly.
find_package(Folly REQUIRED)
endif ()
find_package(Threads)
find_library(EVENT_LIBRARY event)
add_library(folly SHARED IMPORTED)
set_property(TARGET folly PROPERTY IMPORTED_LOCATION ${FOLLY_LIBRARY})
set_property(TARGET folly
APPEND PROPERTY INTERFACE_LINK_LIBRARIES
${EXTRA_LINK_FLAGS} ${EVENT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT})
if (TARGET folly-ext)
add_dependencies(folly folly-ext)
endif ()
# Folly includes are marked as system to prevent errors on non-standard
# extensions when compiling with -pedantic and -Werror.
set_property(TARGET folly
APPEND PROPERTY INTERFACE_SYSTEM_INCLUDE_DIRECTORIES ${FOLLY_INCLUDE_DIR})
set_property(TARGET folly
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${FOLLY_INCLUDE_DIR})
# gmock
ExternalProject_Add(
gmock
URL ${CMAKE_CURRENT_SOURCE_DIR}/googletest-release-1.8.0.zip
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(gmock source_dir)
set(GMOCK_SOURCE_DIR ${source_dir})
ExternalProject_Get_Property(gmock binary_dir)
set(GMOCK_BINARY_DIR ${binary_dir})
set(GMOCK_LIBS
${GMOCK_BINARY_DIR}/${CMAKE_CFG_INTDIR}/googlemock/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}
${GMOCK_BINARY_DIR}/${CMAKE_CFG_INTDIR}/googlemock/${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX}
)
set(CMAKE_CXX_STANDARD 14)
# Common configuration for all build modes.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Woverloaded-virtual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
set(EXTRA_CXX_FLAGS ${EXTRA_CXX_FLAGS} -Werror)
if("${BUILD_TYPE_LOWER}" MATCHES "debug")
message("debug mode was set")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unreachable-code")
else()
message("release mode was set")
endif()
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(TEST_CXX_FLAGS ${TEST_CXX_FLAGS} -Wno-inconsistent-missing-override)
endif()
find_library(DOUBLE-CONVERSION double-conversion)
find_package(OpenSSL REQUIRED)
# Find glog and gflags libraries specifically
find_path(GLOG_INCLUDE_DIR glog/logging.h)
find_path(GFLAGS_INCLUDE_DIR gflags/gflags.h)
find_library(GLOG_LIBRARY glog)
find_library(GFLAGS_LIBRARY gflags)
message("gflags include_dir <${GFLAGS_INCLUDE_DIR}> lib <${GFLAGS_LIBRARY}>")
message("glog include_dir <${GLOG_INCLUDE_DIR}> lib <${GLOG_LIBRARY}>")
include_directories(SYSTEM ${OPENSSL_INCLUDE_DIR})
include_directories(SYSTEM ${GFLAGS_INCLUDE_DIR})
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR}/reactivestreams/include)
include_directories(${GMOCK_SOURCE_DIR}/googlemock/include)
include_directories(${GMOCK_SOURCE_DIR}/googletest/include)
add_subdirectory(yarpl)
add_library(
ReactiveSocket
rsocket/RSocket.cpp
rsocket/RSocket.h
rsocket/RSocketServer.h
rsocket/RSocketServer.cpp
rsocket/RSocketClient.h
rsocket/RSocketClient.cpp
rsocket/RSocketRequester.h
rsocket/RSocketRequester.cpp
rsocket/RSocketErrors.h
rsocket/RSocketParameters.cpp
rsocket/RSocketParameters.h
rsocket/ConnectionAcceptor.h
rsocket/ConnectionFactory.h
rsocket/transports/tcp/TcpConnectionAcceptor.h
rsocket/transports/tcp/TcpConnectionAcceptor.cpp
rsocket/transports/tcp/TcpConnectionFactory.h
rsocket/transports/tcp/TcpConnectionFactory.cpp
rsocket/RSocketResponder.cpp
rsocket/RSocketResponder.h
rsocket/statemachine/ChannelRequester.cpp
rsocket/statemachine/ChannelRequester.h
rsocket/statemachine/ChannelResponder.cpp
rsocket/statemachine/ChannelResponder.h
rsocket/statemachine/ConsumerBase.cpp
rsocket/statemachine/ConsumerBase.h
rsocket/statemachine/PublisherBase.cpp
rsocket/statemachine/PublisherBase.h
rsocket/statemachine/RequestResponseRequester.cpp
rsocket/statemachine/RequestResponseRequester.h
rsocket/statemachine/RequestResponseResponder.cpp
rsocket/statemachine/RequestResponseResponder.h
rsocket/statemachine/StreamStateMachineBase.cpp
rsocket/statemachine/StreamStateMachineBase.h
rsocket/statemachine/StreamRequester.cpp
rsocket/statemachine/StreamRequester.h
rsocket/statemachine/StreamResponder.cpp
rsocket/statemachine/StreamResponder.h
rsocket/statemachine/StreamsFactory.cpp
rsocket/statemachine/StreamsFactory.h
rsocket/statemachine/StreamsWriter.h
rsocket/statemachine/StreamState.cpp
rsocket/statemachine/StreamState.h
rsocket/internal/ClientResumeStatusCallback.h
rsocket/internal/Common.cpp
rsocket/internal/Common.h
rsocket/statemachine/RSocketStateMachine.cpp
rsocket/statemachine/RSocketStateMachine.h
rsocket/DuplexConnection.h
rsocket/internal/FollyKeepaliveTimer.cpp
rsocket/internal/FollyKeepaliveTimer.h
rsocket/framing/ErrorCode.cpp
rsocket/framing/ErrorCode.h
rsocket/framing/Frame.cpp
rsocket/framing/Frame.h
rsocket/framing/FrameFlags.cpp
rsocket/framing/FrameFlags.h
rsocket/framing/FrameProcessor.h
rsocket/framing/FrameSerializer.cpp
rsocket/framing/FrameSerializer.h
rsocket/framing/FrameTransport.cpp
rsocket/framing/FrameTransport.h
rsocket/framing/FrameType.cpp
rsocket/framing/FrameType.cpp
rsocket/framing/FrameType.h
rsocket/framing/FrameType.h
rsocket/framing/FramedDuplexConnection.cpp
rsocket/framing/FramedDuplexConnection.h
rsocket/framing/FramedReader.cpp
rsocket/framing/FramedReader.h
rsocket/framing/FramedWriter.cpp
rsocket/framing/FramedWriter.h
rsocket/Payload.cpp
rsocket/Payload.h
rsocket/internal/ResumeCache.cpp
rsocket/internal/ResumeCache.h
rsocket/internal/SetupResumeAcceptor.cpp
rsocket/internal/SetupResumeAcceptor.h
rsocket/RSocketStats.cpp
rsocket/RSocketStats.h
rsocket/transports/tcp/TcpDuplexConnection.cpp
rsocket/transports/tcp/TcpDuplexConnection.h
rsocket/framing/FrameSerializer_v0.cpp
rsocket/framing/FrameSerializer_v0.h
rsocket/framing/FrameSerializer_v0_1.cpp
rsocket/framing/FrameSerializer_v0_1.h
rsocket/framing/FrameSerializer_v1_0.cpp
rsocket/framing/FrameSerializer_v1_0.h
rsocket/internal/ScheduledSubscription.cpp
rsocket/internal/ScheduledSubscription.h
rsocket/internal/ScheduledSubscriber.h
rsocket/internal/ScheduledRSocketResponder.cpp
rsocket/internal/ScheduledRSocketResponder.h
rsocket/internal/ScheduledSingleObserver.h
rsocket/internal/ScheduledSingleSubscription.cpp
rsocket/internal/ScheduledSingleSubscription.h
rsocket/internal/RSocketConnectionManager.cpp
rsocket/internal/RSocketConnectionManager.h
rsocket/RSocketSetup.cpp
rsocket/RSocketSetup.h
rsocket/ResumeManager.h
rsocket/ColdResumeHandler.h
rsocket/Exception.h)
target_include_directories(ReactiveSocket PUBLIC "${PROJECT_SOURCE_DIR}/yarpl/include")
target_include_directories(ReactiveSocket PUBLIC "${PROJECT_SOURCE_DIR}/yarpl/src")
target_link_libraries(ReactiveSocket yarpl ${GFLAGS_LIBRARY} ${GLOG_LIBRARY})
target_compile_options(
ReactiveSocket
PRIVATE ${EXTRA_CXX_FLAGS})
enable_testing()
install(TARGETS ReactiveSocket DESTINATION lib)
install(DIRECTORY rsocket DESTINATION include FILES_MATCHING PATTERN "*.h")
# CMake doesn't seem to support "transitive" installing, and I can't access the
# "yarpl" target from this file, so just grab the library file directly.
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/yarpl/libyarpl.a" DESTINATION lib)
install(DIRECTORY yarpl/include/yarpl DESTINATION include FILES_MATCHING PATTERN "*.h")
add_executable(
tests
test/MocksTest.cpp
test/PayloadTest.cpp
test/RSocketClientServerTest.cpp
test/RSocketTests.h
test/RequestChannelTest.cpp
test/RequestResponseTest.cpp
test/RequestStreamTest.cpp
test/Test.cpp
test/framing/FrameTest.cpp
test/framing/FrameTransportTest.cpp
test/handlers/HelloStreamRequestHandler.cpp
test/handlers/HelloStreamRequestHandler.h
test/internal/AllowanceSemaphoreTest.cpp
test/internal/FollyKeepaliveTimerTest.cpp
test/test_utils/MockDuplexConnection.h
test/test_utils/MockKeepaliveTimer.h
test/test_utils/MockRequestHandler.h
test/test_utils/MockStats.h
test/test_utils/Mocks.h
test/transport/DuplexConnectionTest.cpp
test/transport/DuplexConnectionTest.h
test/transport/TcpDuplexConnectionTest.cpp)
target_link_libraries(
tests
ReactiveSocket
yarpl
${GMOCK_LIBS}
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
target_compile_options(
tests
PRIVATE ${TEST_CXX_FLAGS})
add_dependencies(tests gmock ReactiveSocket)
add_test(NAME ReactiveSocketTests COMMAND tests)
########################################
# TCK Drivers
########################################
add_executable(
tckclient
tck-test/client.cpp
tck-test/TestFileParser.cpp
tck-test/TestFileParser.h
tck-test/FlowableSubscriber.cpp
tck-test/FlowableSubscriber.h
tck-test/SingleSubscriber.cpp
tck-test/SingleSubscriber.h
tck-test/TestSuite.cpp
tck-test/TestSuite.h
tck-test/TestInterpreter.cpp
tck-test/TestInterpreter.h
tck-test/TypedCommands.h
tck-test/BaseSubscriber.cpp
tck-test/BaseSubscriber.h)
target_link_libraries(
tckclient
ReactiveSocket
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
add_executable(
tckserver
tck-test/server.cpp
tck-test/MarbleProcessor.cpp
tck-test/MarbleProcessor.h
test/test_utils/StatsPrinter.cpp
test/test_utils/StatsPrinter.h)
target_link_libraries(
tckserver
ReactiveSocket
yarpl
${GFLAGS_LIBRARY}
${GMOCK_LIBS}
${GLOG_LIBRARY}
${DOUBLE-CONVERSION})
# Download the latest TCK drivers JAR.
set(TCK_DRIVERS_JAR reactivesocket-tck-drivers-0.9-SNAPSHOT.jar)
join(TCK_DRIVERS_URL
"https://oss.jfrog.org/libs-snapshot/io/reactivesocket/"
"reactivesocket-tck-drivers/0.9-SNAPSHOT/${TCK_DRIVERS_JAR}")
message(STATUS "Downloading ${TCK_DRIVERS_URL}")
file(DOWNLOAD ${TCK_DRIVERS_URL} ${CMAKE_SOURCE_DIR}/${TCK_DRIVERS_JAR})
########################################
# Examples
########################################
add_library(
reactivesocket_examples_util
examples/util/ExampleSubscriber.cpp
examples/util/ExampleSubscriber.h
)
target_link_libraries(
reactivesocket_examples_util
yarpl
ReactiveSocket
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
# request-response-hello-world
add_executable(
example_request-response-hello-world-server
examples/request-response-hello-world/RequestResponseHelloWorld_Server.cpp
)
target_link_libraries(
example_request-response-hello-world-server
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
add_executable(
example_request-response-hello-world-client
examples/request-response-hello-world/RequestResponseHelloWorld_Client.cpp
)
target_link_libraries(
example_request-response-hello-world-client
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
# fire-and-forget-hello-world
add_executable(
example_fire-and-forget-hello-world-server
examples/fire-and-forget-hello-world/FireAndForgetHelloWorld_Server.cpp
)
target_link_libraries(
example_fire-and-forget-hello-world-server
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
add_executable(
example_fire-and-forget-hello-world-client
examples/fire-and-forget-hello-world/FireAndForgetHelloWorld_Client.cpp
)
target_link_libraries(
example_fire-and-forget-hello-world-client
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
# stream-hello-world
add_executable(
example_stream-hello-world-server
examples/stream-hello-world/StreamHelloWorld_Server.cpp
)
target_link_libraries(
example_stream-hello-world-server
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
add_executable(
example_stream-hello-world-client
examples/stream-hello-world/StreamHelloWorld_Client.cpp
)
target_link_libraries(
example_stream-hello-world-client
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
# channel-hello-world
add_executable(
example_channel-hello-world-server
examples/channel-hello-world/ChannelHelloWorld_Server.cpp
)
target_link_libraries(
example_channel-hello-world-server
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
add_executable(
example_channel-hello-world-client
examples/channel-hello-world/ChannelHelloWorld_Client.cpp
)
target_link_libraries(
example_channel-hello-world-client
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
# stream-observable-to-flowable
add_executable(
example_observable-to-flowable-server
examples/stream-observable-to-flowable/StreamObservableToFlowable_Server.cpp
)
target_link_libraries(
example_observable-to-flowable-server
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
add_executable(
example_observable-to-flowable-client
examples/stream-observable-to-flowable/StreamObservableToFlowable_Client.cpp
)
target_link_libraries(
example_observable-to-flowable-client
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
# conditional-request-handling
add_executable(
example_conditional-request-handling-server
examples/conditional-request-handling/ConditionalRequestHandling_Server.cpp
examples/conditional-request-handling/TextRequestHandler.h
examples/conditional-request-handling/TextRequestHandler.cpp
examples/conditional-request-handling/JsonRequestHandler.cpp
examples/conditional-request-handling/JsonRequestHandler.h
)
target_link_libraries(
example_conditional-request-handling-server
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
add_executable(
example_conditional-request-handling-client
examples/conditional-request-handling/ConditionalRequestHandling_Client.cpp
)
target_link_libraries(
example_conditional-request-handling-client
ReactiveSocket
reactivesocket_examples_util
yarpl
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
########################################
# End Examples
########################################
if(BUILD_BENCHMARKS)
ExternalProject_Add(
google_benchmark
URL ${CMAKE_SOURCE_DIR}/benchmark-1.1.0.zip
URL_MD5 c3c5cca410a1959efc93946f1739547f
CMAKE_ARGS "-DCMAKE_BUILD_TYPE=Release"
INSTALL_COMMAND ""
)
ExternalProject_Get_Property(google_benchmark source_dir)
set(GOOGLE_BENCHMARK_SOURCE_DIR ${source_dir})
ExternalProject_Get_Property(google_benchmark binary_dir)
set(GOOGLE_BENCHMARK_BINARY_DIR ${binary_dir})
set(
GOOGLE_BENCHMARK_LIBS
${GOOGLE_BENCHMARK_BINARY_DIR}/src/${CMAKE_STATIC_LIBRARY_PREFIX}benchmark${CMAKE_STATIC_LIBRARY_SUFFIX}
)
include_directories(${GOOGLE_BENCHMARK_SOURCE_DIR}/include)
include_directories(${CMAKE_SOURCE_DIR}/experimental)
function(benchmark name file)
add_executable(${name} ${file})
target_link_libraries(
${name}
ReactiveSocket
yarpl
${GOOGLE_BENCHMARK_LIBS}
${GFLAGS_LIBRARY}
${GLOG_LIBRARY})
add_dependencies(
${name}
google_benchmark)
endfunction()
add_subdirectory(benchmarks)
add_subdirectory(yarpl/perf)
endif(BUILD_BENCHMARKS)