@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.17...3.20)
2
2
3
3
set (CMAKE_CXX_STANDARD 17)
4
4
5
- set (LIBRARY_NAME amazon-chime-signaling-sdk-cpp-lib )
5
+ set (LIBRARY_NAME amazon-chime-signaling-sdk-cpp)
6
6
7
7
set (SIGNALING_LANGUAGES C CXX)
8
8
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
@@ -16,9 +16,7 @@ project(
16
16
LANGUAGES ${SIGNALING_LANGUAGES} )
17
17
18
18
# list of options available
19
- # Enable Address Sanitizer
20
19
option (ENABLE_ASAN "Enable Address Sanitizer" OFF )
21
- # Build test
22
20
option (BUILD_TEST "Build tests" ON )
23
21
24
22
if (ENABLE_ASAN)
@@ -74,48 +72,69 @@ set(SDK_SRC
74
72
src/utils/logging.cc
75
73
src/websocket/libwebsockets_websocket.cc
76
74
src/websocket/default_websocket_factory.cc
77
- src/proto/video_control.pb.cc)
75
+ src/proto/video_control_sdk.proto
76
+ )
78
77
79
78
add_library (${LIBRARY_NAME} "${SDK_HEADERS} " "${SDK_SRC} " )
80
79
81
80
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake/" )
81
+ include (FetchContent)
82
+
82
83
83
84
# Libwebsocket dependency
84
- #find_package(LibWebsockets REQUIRED)
85
- include (FetchContent)
85
+
86
86
FetchContent_Declare(
87
87
libwebsockets
88
88
GIT_REPOSITORY https://github.com/warmcat/libwebsockets.git
89
- GIT_TAG 141ebf373ca0fed7b41eb960cdbd7ab1f29490dc
89
+ GIT_TAG v4.3-stable
90
90
)
91
91
92
- # Use open ssl static lib
93
- set (OPENSSL_USE_STATIC_LIBS TRUE )
94
-
95
92
set (LWS_CTEST_INTERNET_AVAILABLE OFF CACHE BOOL "enable tests for proto" FORCE)
96
93
set (LWS_WITHOUT_TESTAPPS ON CACHE BOOL "Don't build the libwebsocket-test-apps" FORCE)
97
94
set (LWS_WITHOUT_TEST_SERVER ON CACHE BOOL "Don't build the libwebsocket-test-apps" FORCE)
98
95
set (LWS_WITHOUT_TEST_SERVER_EXTPOLL ON CACHE BOOL "Don't build the libwebsocket-test-apps" FORCE)
99
96
set (LWS_WITHOUT_TEST_PING ON CACHE BOOL "Don't build the libwebsocket-test-apps" FORCE)
100
97
set (LWS_WITHOUT_TEST_CLIENT ON CACHE BOOL "Don't build the libwebsocket-test-apps" FORCE)
101
- # TODO @hokyungh: Add more options to only build library.
102
- set (LWS_WITH_BORINGSSL ON CACHE BOOL "Use OpenSSL fork BoringSSL" FORCE)
103
98
FetchContent_MakeAvailable(libwebsockets)
104
99
105
100
target_link_libraries (${LIBRARY_NAME} PRIVATE websockets)
106
101
107
- # Protobuf
108
- FetchContent_Declare(
109
- protobuf
110
- GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
111
- GIT_TAG fde7cf7358ec7cd69e8db9be4f1fa6a5c431386a
112
- SOURCE_SUBDIR cmake
113
- )
102
+ # Protobuf dependency
114
103
115
- set (protobuf_BUILD_TESTS OFF CACHE BOOL "enable tests for proto" FORCE)
104
+ FetchContent_Declare(
105
+ protobuf
106
+ GIT_REPOSITORY https://github.com/protocolbuffers/protobuf.git
107
+ # Revert to version before Abseil dependency as we haven't found a workaround for
108
+ # issues similar to https://github.com/protocolbuffers/protobuf/issues/12637
109
+ GIT_TAG v3.21.12
110
+ )
111
+ set (protobuf_BUILD_TESTS OFF CACHE BOOL "Disable tests for protobuf" FORCE)
116
112
FetchContent_MakeAvailable(protobuf)
117
113
118
114
target_link_libraries (${LIBRARY_NAME} PRIVATE protobuf::libprotobuf)
115
+ target_include_directories (${LIBRARY_NAME} PUBLIC ${Protobuf_INCLUDE_DIRS} )
116
+
117
+ # Generate .proto files with the current version of protobuf. These are not
118
+ # added to SCM because in the future we will allow custom protobuf usage
119
+ # i.e. to reuse the one in a libwebrtc build as to not duplicate symbols
120
+
121
+ # Newer versions of protobuf include protobuf-generate.cmake. For now we use the one bundled
122
+ # with cmake
123
+ include (FindProtobuf)
124
+ set (PROTO_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR} /src/proto" )
125
+ protobuf_generate(
126
+ TARGET ${LIBRARY_NAME}
127
+ )
128
+ # Include generated *.pb.h files. Since we do not upload headers to source control
129
+ # we 'include' them without a path (e.g. '#include "video_control_sdk.pb.h'). Since
130
+ # we expose these classes and types in external headers, we need to expose the protobuf
131
+ # headers as well.
132
+ target_include_directories (${LIBRARY_NAME} PUBLIC ${PROTO_OUTPUT_PATH} )
133
+ # Additional include since the generated source file will reference the full path
134
+ # of the generated header.
135
+ target_include_directories (${LIBRARY_NAME} PRIVATE ${CMAKE_CURRENT_BINARY_DIR} )
136
+
137
+ # Project configuration
119
138
120
139
# Include src directory so that we can avoid .. in the header includes
121
140
target_include_directories (${LIBRARY_NAME}
@@ -127,7 +146,6 @@ target_include_directories(
127
146
$<INSTALL_INTERFACE:include >)
128
147
129
148
target_compile_features (${LIBRARY_NAME} PUBLIC cxx_std_17)
130
- # set flag as c++11 instead of gnu++11 for some compilers
131
149
set_target_properties (${LIBRARY_NAME} PROPERTIES CXX_EXTENSIONS OFF )
132
150
133
151
# Add stack smashing protection. MSVC uses /GS which is enabled by default. See
@@ -136,11 +154,6 @@ if(NOT MSVC)
136
154
target_compile_options (${LIBRARY_NAME} PRIVATE "-fstack-protector" )
137
155
endif ()
138
156
139
- if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
140
- set (SDK_BINARY_NAME "${LIBRARY_NAME} .a" )
141
- elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows" )
142
- set (SDK_BINARY_NAME "${LIBRARY_NAME} .lib" )
143
- endif ()
144
157
145
158
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin" )
146
159
target_link_options (${LIBRARY_NAME} PUBLIC "-ObjC" )
@@ -153,20 +166,18 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
153
166
"MultiThreaded$<$<CONFIG:Debug>:Debug>" )
154
167
endif ()
155
168
156
- # Combine binaries
157
- # Currently supporting Mac and Linux
169
+ # For downstream projects that do not use CMake, we output static
170
+ # libraries that combine all of the dependencies.
158
171
159
172
set (SDK_BINARY_LIB_NAME "libamazon_chime_signaling_sdk" )
160
-
161
173
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
162
174
set (SDK_BINARY_NAME "${SDK_BINARY_LIB_NAME} .a" )
163
175
164
- # TODO @hokyungh: might be better to use mri script
165
176
add_custom_command (
166
177
TARGET ${LIBRARY_NAME}
167
178
POST_BUILD
168
179
COMMAND ar -x $<TARGET_FILE:${LIBRARY_NAME} >
169
- COMMAND ar -x $<TARGET_FILE:protobuf::libprotobuf>
180
+ COMMAND ar -x $<TARGET_FILE:protobuf::libprotobuf>
170
181
COMMAND ar -x $<TARGET_FILE:websockets>
171
182
COMMAND ar -qc ${SDK_BINARY_NAME} *.o
172
183
)
@@ -184,7 +195,6 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
184
195
)
185
196
endif ()
186
197
187
- # Run unit test
188
198
if (BUILD_TEST)
189
199
include (CTest)
190
200
enable_testing ()
0 commit comments