Skip to content

Commit 5b93c0a

Browse files
Decouple library from BoringSSL and specific protobuf versions. Update libwebrtc/platform in demo. Refactor READMEs. (#29)
1 parent 1870350 commit 5b93c0a

39 files changed

+1274
-35245
lines changed

chime-sdk-signaling-cpp/CMakeLists.txt

+42-32
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.17...3.20)
22

33
set(CMAKE_CXX_STANDARD 17)
44

5-
set(LIBRARY_NAME amazon-chime-signaling-sdk-cpp-lib)
5+
set(LIBRARY_NAME amazon-chime-signaling-sdk-cpp)
66

77
set(SIGNALING_LANGUAGES C CXX)
88
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
@@ -16,9 +16,7 @@ project(
1616
LANGUAGES ${SIGNALING_LANGUAGES})
1717

1818
# list of options available
19-
# Enable Address Sanitizer
2019
option(ENABLE_ASAN "Enable Address Sanitizer" OFF)
21-
# Build test
2220
option(BUILD_TEST "Build tests" ON)
2321

2422
if(ENABLE_ASAN)
@@ -74,48 +72,69 @@ set(SDK_SRC
7472
src/utils/logging.cc
7573
src/websocket/libwebsockets_websocket.cc
7674
src/websocket/default_websocket_factory.cc
77-
src/proto/video_control.pb.cc)
75+
src/proto/video_control_sdk.proto
76+
)
7877

7978
add_library(${LIBRARY_NAME} "${SDK_HEADERS}" "${SDK_SRC}")
8079

8180
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/")
81+
include(FetchContent)
82+
8283

8384
# Libwebsocket dependency
84-
#find_package(LibWebsockets REQUIRED)
85-
include(FetchContent)
85+
8686
FetchContent_Declare(
8787
libwebsockets
8888
GIT_REPOSITORY https://github.com/warmcat/libwebsockets.git
89-
GIT_TAG 141ebf373ca0fed7b41eb960cdbd7ab1f29490dc
89+
GIT_TAG v4.3-stable
9090
)
9191

92-
# Use open ssl static lib
93-
set(OPENSSL_USE_STATIC_LIBS TRUE)
94-
9592
set(LWS_CTEST_INTERNET_AVAILABLE OFF CACHE BOOL "enable tests for proto" FORCE)
9693
set(LWS_WITHOUT_TESTAPPS ON CACHE BOOL "Don't build the libwebsocket-test-apps" FORCE)
9794
set(LWS_WITHOUT_TEST_SERVER ON CACHE BOOL "Don't build the libwebsocket-test-apps" FORCE)
9895
set(LWS_WITHOUT_TEST_SERVER_EXTPOLL ON CACHE BOOL "Don't build the libwebsocket-test-apps" FORCE)
9996
set(LWS_WITHOUT_TEST_PING ON CACHE BOOL "Don't build the libwebsocket-test-apps" FORCE)
10097
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)
10398
FetchContent_MakeAvailable(libwebsockets)
10499

105100
target_link_libraries(${LIBRARY_NAME} PRIVATE websockets)
106101

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
114103

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)
116112
FetchContent_MakeAvailable(protobuf)
117113

118114
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
119138

120139
# Include src directory so that we can avoid .. in the header includes
121140
target_include_directories(${LIBRARY_NAME}
@@ -127,7 +146,6 @@ target_include_directories(
127146
$<INSTALL_INTERFACE:include>)
128147

129148
target_compile_features(${LIBRARY_NAME} PUBLIC cxx_std_17)
130-
# set flag as c++11 instead of gnu++11 for some compilers
131149
set_target_properties(${LIBRARY_NAME} PROPERTIES CXX_EXTENSIONS OFF)
132150

133151
# Add stack smashing protection. MSVC uses /GS which is enabled by default. See
@@ -136,11 +154,6 @@ if(NOT MSVC)
136154
target_compile_options(${LIBRARY_NAME} PRIVATE "-fstack-protector")
137155
endif()
138156

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()
144157

145158
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
146159
target_link_options(${LIBRARY_NAME} PUBLIC "-ObjC")
@@ -153,20 +166,18 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
153166
"MultiThreaded$<$<CONFIG:Debug>:Debug>")
154167
endif()
155168

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.
158171

159172
set(SDK_BINARY_LIB_NAME "libamazon_chime_signaling_sdk")
160-
161173
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
162174
set(SDK_BINARY_NAME "${SDK_BINARY_LIB_NAME}.a")
163175

164-
# TODO @hokyungh: might be better to use mri script
165176
add_custom_command(
166177
TARGET ${LIBRARY_NAME}
167178
POST_BUILD
168179
COMMAND ar -x $<TARGET_FILE:${LIBRARY_NAME}>
169-
COMMAND ar -x $<TARGET_FILE:protobuf::libprotobuf>
180+
COMMAND ar -x $<TARGET_FILE:protobuf::libprotobuf>
170181
COMMAND ar -x $<TARGET_FILE:websockets>
171182
COMMAND ar -qc ${SDK_BINARY_NAME} *.o
172183
)
@@ -184,7 +195,6 @@ elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
184195
)
185196
endif()
186197

187-
# Run unit test
188198
if (BUILD_TEST)
189199
include(CTest)
190200
enable_testing()

0 commit comments

Comments
 (0)