forked from node-webrtc/node-webrtc
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
157 lines (136 loc) · 4.37 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
cmake_minimum_required(VERSION 3.1)
include(ExternalProject)
if(EXISTS ${CMAKE_SOURCE_DIR}/third_party/webrtc)
else()
execute_process(COMMAND node ${CMAKE_SOURCE_DIR}/scripts/download-webrtc-libraries-and-headers.js)
endif()
set(MODULE wrtc)
include(${CMAKE_SOURCE_DIR}/NodeJS.cmake)
nodejs_init()
file(GLOB_RECURSE MODULE_SRC src/*.cc src/*.h)
add_nodejs_module(${MODULE} ${MODULE_SRC})
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(${MODULE} PRIVATE -DDEBUG)
endif()
target_include_directories(${MODULE} PRIVATE ${CMAKE_SOURCE_DIR})
find_package(Threads)
target_include_directories(${MODULE} SYSTEM PRIVATE
${CMAKE_SOURCE_DIR}/third_party/webrtc/include)
if(WIN32)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
target_link_libraries(${MODULE} PRIVATE
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_SOURCE_DIR}/third_party/webrtc/lib/webrtc.lib
dmoguids.lib
msdmo.lib
secur32.lib
winmm.lib
wmcodecdspuuid.lib
ws2_32.lib)
target_compile_definitions(${MODULE} PRIVATE
-DWEBRTC_WIN
-DNOGDI
-DNOMINMAX)
else()
target_link_libraries(${MODULE} PRIVATE
${CMAKE_THREAD_LIBS_INIT}
${CMAKE_SOURCE_DIR}/third_party/webrtc/lib/libwebrtc.a)
target_compile_options(${MODULE} PUBLIC
# -Werror
-Wall
-Wpedantic
-Wno-missing-field-initializers
-Wextra
-Wno-unused-local-typedefs
-Wno-uninitialized
-Wno-unused-variable)
endif()
if(APPLE)
target_compile_definitions(${MODULE} PRIVATE
-DWEBRTC_MAC
-DWEBRTC_IOS
-DWEBRTC_POSIX=1)
target_link_libraries(${MODULE} PRIVATE
"-framework AppKit")
elseif(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")
target_compile_definitions(${MODULE} PRIVATE
-DWEBRTC_POSIX=1)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
list(APPEND ASTYLE_CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}")
ExternalProject_Add(
astyle
GIT_REPOSITORY https://github.com/Bareflank/astyle.git
GIT_TAG v1.2
GIT_SHALLOW 1
CMAKE_ARGS ${ASTYLE_CMAKE_ARGS}
PREFIX ${CMAKE_BINARY_DIR}/external/astyle/prefix
TMP_DIR ${CMAKE_BINARY_DIR}/external/astyle/tmp
STAMP_DIR ${CMAKE_BINARY_DIR}/external/astyle/stamp
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/external/astyle/download
SOURCE_DIR ${CMAKE_BINARY_DIR}/external/astyle/src
BINARY_DIR ${CMAKE_BINARY_DIR}/external/astyle/build)
list(APPEND ASTYLE_ARGS
--style=google
--lineend=linux
--suffix=none
--pad-oper
--unpad-paren
--align-pointer=type
--align-reference=type
--indent-preproc-define
--indent-switches
--indent-col1-comments
--keep-one-line-statements
--keep-one-line-blocks
--pad-header
--convert-tabs
--min-conditional-indent=0
--indent=spaces=2
--indent-continuation=2
--indent-after-parens
--close-templates
--add-brackets
--break-after-logical
${CMAKE_SOURCE_DIR}/src/*.cc
${CMAKE_SOURCE_DIR}/src/*.h)
if(NOT WIN32 STREQUAL "1")
add_custom_target(
format
COMMAND ${CMAKE_BINARY_DIR}/bin/astyle ${ASTYLE_ARGS}
COMMENT "running astyle")
else()
add_custom_target(
format
COMMAND ${CMAKE_BINARY_DIR}/bin/astyle.exe ${ASTYLE_ARGS}
COMMENT "running astyle")
endif()
list(APPEND CPPCHECK_CMAKE_ARGS
"-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}")
ExternalProject_Add(
cppcheck
GIT_REPOSITORY https://github.com/danmar/cppcheck.git
GIT_TAG 1.79
GIT_SHALLOW 1
CMAKE_ARGS ${CPPCHECK_CMAKE_ARGS}
PREFIX ${CMAKE_BINARY_DIR}/external/cppcheck/prefix
TMP_DIR ${CMAKE_BINARY_DIR}/external/cppcheck/tmp
STAMP_DIR ${CMAKE_BINARY_DIR}/external/cppcheck/stamp
DOWNLOAD_DIR ${CMAKE_BINARY_DIR}/external/cppcheck/download
SOURCE_DIR ${CMAKE_BINARY_DIR}/external/cppcheck/src
BINARY_DIR ${CMAKE_BINARY_DIR}/external/cppcheck/build)
list(APPEND CPPCHECK_ARGS
--enable=warning,style,performance,portability,unusedFunction
--std=c++11
--verbose
--error-exitcode=1
--language=c++
${CMAKE_SOURCE_DIR}/src/*.cc)
add_custom_target(
check
COMMAND ${CMAKE_BINARY_DIR}/bin/cppcheck ${CPPCHECK_ARGS}
COMMENT "running cppcheck")
endif()