-
-
Notifications
You must be signed in to change notification settings - Fork 60
/
CMakeLists.txt
89 lines (70 loc) · 2.41 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
cmake_minimum_required(VERSION 3.15)
cmake_policy(SET CMP0091 NEW)
cmake_policy(SET CMP0042 NEW)
project(node_datachannel VERSION 0.20.0)
# -Dnapi_build_version=8
add_definitions(-DNAPI_VERSION=8)
include_directories(${CMAKE_JS_INC})
set(CMAKE_BUILD_TYPE Release)
if(WIN32)
set(OPENSSL_MSVC_STATIC_RT TRUE)
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
set(CMAKE_C_FLAGS "-Wno-error=unused-but-set-variable -Wno-error=strict-prototypes")
endif()
set(OPENSSL_USE_STATIC_LIBS TRUE)
find_package(OpenSSL REQUIRED)
include(FetchContent)
# Fetch libdatachannel
FetchContent_Declare(
libdatachannel
GIT_REPOSITORY https://github.com/paullouisageneau/libdatachannel.git
GIT_TAG "v0.22.2"
)
option(NO_MEDIA "Disable media transport support in libdatachannel" OFF)
option(NO_WEBSOCKET "Disable WebSocket support in libdatachannel" OFF)
FetchContent_GetProperties(libdatachannel)
if(NOT libdatachannel)
FetchContent_Populate(libdatachannel)
add_subdirectory(${libdatachannel_SOURCE_DIR} ${libdatachannel_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
add_library(${PROJECT_NAME} SHARED
src/cpp/rtc-wrapper.cpp
src/cpp/media-direction.cpp
src/cpp/media-rtcpreceivingsession-wrapper.cpp
src/cpp/media-track-wrapper.cpp
src/cpp/media-audio-wrapper.cpp
src/cpp/media-video-wrapper.cpp
src/cpp/data-channel-wrapper.cpp
src/cpp/peer-connection-wrapper.cpp
src/cpp/thread-safe-callback.cpp
src/cpp/web-socket-wrapper.cpp
src/cpp/web-socket-server-wrapper.cpp
src/cpp/main.cpp
${CMAKE_JS_SRC}
)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 17)
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
target_include_directories(${PROJECT_NAME} PRIVATE
${CMAKE_SOURCE_DIR}/node_modules/node-addon-api
${CMAKE_BINARY_DIR}/_deps/libdatachannel-src/include
${CMAKE_BINARY_DIR}/_deps/libdatachannel-src/deps/plog
)
set(LINK_LIBRARIES
${CMAKE_JS_LIB}
datachannel-static
plog::plog
)
if(APPLE)
#
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Android")
list(APPEND LINK_LIBRARIES -static-libgcc)
elseif(UNIX)
list(APPEND LINK_LIBRARIES -static-libgcc -static-libstdc++)
endif()
if(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
list(APPEND LINK_LIBRARIES crypt32.lib)
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE ${LINK_LIBRARIES})