-
Notifications
You must be signed in to change notification settings - Fork 97
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
171 lines (142 loc) · 4.89 KB
/
CMakeLists.txt
File metadata and controls
171 lines (142 loc) · 4.89 KB
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
cmake_minimum_required (VERSION 3.2)
# To debug the project, set the build type.
set(CMAKE_BUILD_TYPE Debug)
project (yarpl)
# CMake Config
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake/)
add_definitions(-std=c++14)
option(BUILD_TESTS "BUILD_TESTS" ON)
# Generate compilation database
set(CMAKE_EXPORT_COMPILE_COMMANDS 1)
# Common configuration for all build modes.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-unused-parameter")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables -Wno-padded")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -momit-leaf-frame-pointer")
if(YARPL_WRAP_SHARED_IN_LOCK)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DYARPL_WRAP_SHARED_IN_LOCK")
message("Compiler lacks support std::atomic<std::shared_ptr>; wrapping with a mutex")
elseif(YARPL_WRAP_SHARED_IN_ATOMIC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DYARPL_WRAP_SHARED_IN_ATOMIC")
message("Compiler lacks std::shared_ptr atomic overloads; wrapping in std::atomic")
else()
message("Compiler has atomic std::shared_ptr support")
endif()
if(${CMAKE_CXX_COMPILER_ID} MATCHES GNU)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -latomic")
endif()
# The yarpl-tests binary constantly fails with an ASAN error in gtest internal
# code on macOS.
if(APPLE AND ${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
message("== macOS detected, disabling ASAN for yarpl")
add_compile_options("-fno-sanitize=address,undefined")
endif()
# Using NDEBUG in Release builds.
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
find_path(GLOG_INCLUDE_DIR glog/logging.h)
find_library(GLOG_LIBRARY glog)
IF(NOT FOLLY_VERSION)
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/InstallFolly.cmake)
ENDIF()
message("glog include_dir <${GLOG_INCLUDE_DIR}> lib <${GLOG_LIBRARY}>")
include_directories(SYSTEM ${GLOG_INCLUDE_DIR})
message("including ${CMAKE_CURRENT_SOURCE_DIR}")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
# library source
add_library(
yarpl
# public API
Refcounted.h
Common.h
# Flowable public API
Flowable.h
flowable/DeferFlowable.h
flowable/EmitterFlowable.h
flowable/Flowable.h
flowable/FlowableOperator.h
flowable/FlowableConcatOperators.h
flowable/FlowableDoOperator.h
flowable/FlowableObserveOnOperator.h
flowable/Flowable_FromObservable.h
flowable/Flowables.h
flowable/PublishProcessor.h
flowable/Subscriber.h
flowable/Subscription.h
flowable/TestSubscriber.h
flowable/Subscription.cpp
flowable/Flowables.cpp
# Observable public API
Observable.h
observable/DeferObservable.h
observable/Observable.h
observable/Observables.h
observable/ObservableOperator.h
observable/ObservableConcatOperators.h
observable/ObservableDoOperator.h
observable/Observer.h
observable/Subscription.h
observable/TestObserver.h
observable/Subscription.cpp
observable/Observables.cpp
# Single
Single.h
single/Single.h
single/Singles.h
single/SingleOperator.h
single/SingleObserver.h
single/SingleObservers.h
single/SingleSubscription.h
single/SingleSubscriptions.h
single/SingleTestObserver.h
# utils
utils/credits.h
utils/credits.cpp)
target_include_directories(
yarpl
PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../" # allow include paths such as "yarpl/observable.h"
)
message("yarpl source dir: ${CMAKE_CURRENT_SOURCE_DIR}")
target_link_libraries(
yarpl
PUBLIC Folly::folly ${GLOG_LIBRARY}
INTERFACE ${EXTRA_LINK_FLAGS})
install(TARGETS yarpl DESTINATION lib)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DESTINATION include FILES_MATCHING PATTERN "*.h")
# RSocket's tests also has dependency on this library
add_library(
yarpl-test-utils
test_utils/Tuple.cpp
test_utils/Tuple.h
test_utils/Mocks.h)
if (BUILD_TESTS)
# Executable for experimenting.
add_executable(
yarpl-playground
examples/yarpl-playground.cpp
examples/FlowableExamples.cpp
examples/FlowableExamples.h)
target_link_libraries(yarpl-playground yarpl)
# Unit tests.
add_executable(
yarpl-tests
test/MocksTest.cpp
test/FlowableTest.cpp
test/FlowableFlatMapTest.cpp
test/Observable_test.cpp
test/PublishProcessorTest.cpp
test/SubscribeObserveOnTests.cpp
test/Single_test.cpp
test/FlowableSubscriberTest.cpp
test/credits-test.cpp
test/yarpl-tests.cpp)
target_link_libraries(
yarpl-tests
yarpl
yarpl-test-utils
${GLOG_LIBRARY}
# Inherited from rsocket-cpp CMake.
${GMOCK_LIBS})
add_dependencies(yarpl-tests yarpl-test-utils gmock)
add_test(NAME yarpl-tests COMMAND yarpl-tests)
endif()