-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
133 lines (105 loc) · 3.59 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
cmake_minimum_required(VERSION 3.5)
project(mediasoupclient LANGUAGES CXX)
# Set version number.
set(mediasoupclient_VERSION_MAJOR 3)
set(mediasoupclient_VERSION_MINOR 0)
set(mediasoupclient_VERSION_PATCH 8)
# Configure a header file to pass the version.
configure_file (
"${PROJECT_SOURCE_DIR}/version.hpp.in"
"${PROJECT_SOURCE_DIR}/include/version.hpp"
)
# C++ standard requirements.
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Project options.
option(MEDIASOUPCLIENT_BUILD_TESTS "Build unit tests" OFF)
option(MEDIASOUPCLIENT_LOG_TRACE "Enable MSC_LOG_TRACE (See Logger.hpp)" OFF)
option(MEDIASOUPCLIENT_LOG_DEV "Enable MSC_LOG_DEV (See Logger.hpp)" OFF)
# Project configuration.
set(LIBWEBRTC_INCLUDE_PATH "" CACHE STRING "libwebrtc include path")
set(LIBWEBRTC_BINARY_PATH "" CACHE STRING "libwebrtc binary path")
if(NOT LIBWEBRTC_INCLUDE_PATH)
message(FATAL_ERROR "LIBWEBRTC_INCLUDE_PATH not provided")
endif()
if(NOT LIBWEBRTC_BINARY_PATH)
message(FATAL_ERROR "LIBWEBRTC_BINARY_PATH not provided")
endif()
message ("\n=========== libmediasoupclient Build Configuration =============\n")
message (STATUS "MEDIASOUPCLIENT_BUILD_TESTS = " ${MEDIASOUPCLIENT_BUILD_TESTS})
message (STATUS "MEDIASOUPCLIENT_LOG_TRACE = " ${MEDIASOUPCLIENT_LOG_TRACE})
message (STATUS "MEDIASOUPCLIENT_LOG_DEV = " ${MEDIASOUPCLIENT_LOG_DEV})
message (STATUS "LIBWEBRTC_INCLUDE_PATH = " ${LIBWEBRTC_INCLUDE_PATH})
message (STATUS "LIBWEBRTC_BINARY_PATH = " ${LIBWEBRTC_BINARY_PATH})
message ("")
# GCC >= 4.9 is required due to std::regex use.
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
message(FATAL_ERROR "GCC version must be at least 4.9!")
endif()
endif()
if (${MEDIASOUPCLIENT_BUILD_TESTS})
add_subdirectory(test)
endif()
set(HEADER_FILES
include/mediasoupclient.hpp
)
set(
SOURCE_FILES
src/Consumer.cpp
src/Device.cpp
src/Handler.cpp
src/Logger.cpp
src/mediasoupclient.cpp
src/PeerConnection.cpp
src/Producer.cpp
src/Transport.cpp
src/ortc.cpp
src/scalabilityMode.cpp
src/sdp/MediaSection.cpp
src/sdp/RemoteSdp.cpp
src/sdp/Utils.cpp
)
# Create target.
add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES})
if(${MEDIASOUPCLIENT_LOG_TRACE})
target_compile_definitions(${PROJECT_NAME}
PRIVATE MSC_LOG_TRACE=1
)
endif()
if(${MEDIASOUPCLIENT_LOG_DEV})
target_compile_definitions(${PROJECT_NAME}
PRIVATE MSC_LOG_DEV=1
)
endif()
# Source Dependencies.
add_subdirectory(deps/libsdptransform "${CMAKE_CURRENT_BINARY_DIR}/libsdptransform")
# Add some compile flags to our source files.
if(MSVC)
set_source_files_properties(${SOURCE_FILES}
PROPERTIES COMPILE_FLAGS "/W3 ")
else()
set_source_files_properties(${SOURCE_FILES}
PROPERTIES COMPILE_FLAGS -Wall -Wextra -Wpedantic)
endif()
# Private (implementation) header files.
target_include_directories(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
# Public (interface) headers from dependencies.
target_include_directories(${PROJECT_NAME} PUBLIC
"${PROJECT_SOURCE_DIR}/deps/libsdptransform/include"
"${LIBWEBRTC_INCLUDE_PATH}"
"${LIBWEBRTC_INCLUDE_PATH}/third_party/abseil-cpp"
)
# Public (interface) dependencies.
target_link_libraries(${PROJECT_NAME} PUBLIC
sdptransform
${LIBWEBRTC_BINARY_PATH}/libwebrtc${CMAKE_STATIC_LIBRARY_SUFFIX}
)
# Compile definitions for libwebrtc.
target_compile_definitions(${PROJECT_NAME} PUBLIC
$<$<NOT:$<PLATFORM_ID:Windows>>:WEBRTC_POSIX>
$<$<PLATFORM_ID:Windows>:WEBRTC_WIN>
$<$<PLATFORM_ID:Darwin>:WEBRTC_MAC>
)
install(TARGETS mediasoupclient DESTINATION lib)
install(FILES ${HEADER_FILES} DESTINATION include/mediasoupclient)