-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
182 lines (151 loc) · 7.78 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
# VERSION MAJOR = 125, MINOR=0, BUILD=6422, PATCH=224
set(WEBRTC_CHECKOUT 8505a9838ea91c66c96c173d30cd66f9dbcc7548)
if(WIN32)
list(APPEND CMAKE_PROGRAM_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../depot_tools/")
message(STATUS "Current PATH: $ENV{PATH}")
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/webrtc)
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/webrtc/src")
execute_process(
COMMAND ${CMAKE_COMMAND} -E env DEPOT_TOOLS_WIN_TOOLCHAIN=0 ${CMAKE_CURRENT_SOURCE_DIR}/../depot_tools/fetch.bat webrtc
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/webrtc"
RESULT_VARIABLE fetch_webrtc_result
)
if(NOT ${fetch_webrtc_result} EQUAL 0)
message(FATAL_ERROR "\"fetch webrtc\" failed (${fetch_webrtc_result})")
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} -E env DEPOT_TOOLS_WIN_TOOLCHAIN=0 ${CMAKE_CURRENT_SOURCE_DIR}/../depot_tools/gclient.bat sync --with_branch_heads --with_tags
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/webrtc"
RESULT_VARIABLE gclient_sync_webrtc_result
)
if(NOT ${gclient_sync_webrtc_result} EQUAL 0)
message(FATAL_ERROR "\"gclient sync --with_branch_heads --with_tags\" failed (${gclient_sync_webrtc_result})")
endif()
execute_process(
COMMAND git checkout ${WEBRTC_CHECKOUT}
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/webrtc/src"
RESULT_VARIABLE git_checkout_webrtc_result
)
if(NOT ${git_checkout_webrtc_result} EQUAL 0)
message(FATAL_ERROR "\"git checkout\" failed (${git_checkout_webrtc_result})")
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} -E env DEPOT_TOOLS_WIN_TOOLCHAIN=0 ${CMAKE_CURRENT_SOURCE_DIR}/../depot_tools/gclient.bat sync --with_branch_heads --with_tags
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/webrtc"
RESULT_VARIABLE gclient_sync_webrtc_result
)
if(NOT ${gclient_sync_webrtc_result} EQUAL 0)
message(FATAL_ERROR "\"gclient sync --with_branch_heads --with_tags\" failed (${gclient_sync_webrtc_result})")
endif()
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} -E env DEPOT_TOOLS_WIN_TOOLCHAIN=0 "${CMAKE_CURRENT_SOURCE_DIR}/generate_ninja_files.bat"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/webrtc/src"
RESULT_VARIABLE generate_ninja_files_result
)
if(NOT ${generate_ninja_files_result} EQUAL 0)
message(FATAL_ERROR "\"generate_ninja_files.cmake\" failed (${generate_ninja_files_result})")
endif()
add_custom_target(
webrtc_native ALL
COMMAND ${CMAKE_COMMAND} -E env DEPOT_TOOLS_WIN_TOOLCHAIN=0 ninja -C ${CMAKE_CURRENT_SOURCE_DIR}/webrtc/src/out/${CMAKE_BUILD_TYPE}
)
else(WIN32)
set(ENV{PATH} $ENV{PATH}:${CMAKE_CURRENT_LIST_DIR}/../depot_tools/)
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/webrtc")
execute_process(
COMMAND mkdir webrtc
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
RESULT_VARIABLE mkdir_webrtc_result
)
if(NOT ${mkdir_webrtc_result} EQUAL 0)
message(FATAL_ERROR "\"mkdir webrtc\" failed (${mkdir_webrtc_result})")
endif()
endif()
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/webrtc/src")
execute_process(
COMMAND fetch --nohooks webrtc
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/webrtc"
RESULT_VARIABLE fetch_webrtc_result
)
if(NOT ${fetch_webrtc_result} EQUAL 0)
message(FATAL_ERROR "\"fetch --nohooks webrtc\" failed (${fetch_webrtc_result})")
endif()
execute_process(
COMMAND git fetch
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/webrtc"
RESULT_VARIABLE git_fetch_webrtc_result
)
if(NOT ${git_fetch_webrtc_result} EQUAL 0)
message(FATAL_ERROR "\"git fetch\" failed (${git_fetch_webrtc_result})")
endif()
execute_process(
COMMAND git checkout -f ${WEBRTC_CHECKOUT}
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/webrtc/src"
RESULT_VARIABLE git_checkout_webrtc_result
)
if(NOT ${git_checkout_webrtc_result} EQUAL 0)
message(FATAL_ERROR "\"git checkout\" failed (${git_checkout_webrtc_result})")
endif()
execute_process(
# Removing unused files and directory
COMMAND gclient sync -D
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/webrtc"
RESULT_VARIABLE gclient_sync_webrtc_result
)
if(NOT ${gclient_sync_webrtc_result} EQUAL 0)
message(FATAL_ERROR "\"gclient sync -D\" failed (${gclient_sync_webrtc_result})")
endif()
endif()
if (CMAKE_BUILD_ARCHITECTURE MATCHES arm64)
execute_process(
COMMAND python3 install-sysroot.py --arch=${CMAKE_BUILD_ARCHITECTURE}
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/webrtc/src/build/linux/sysroot_scripts"
RESULT_VARIABLE build_sysroot_architecture
)
if(NOT ${build_sysroot_architecture} EQUAL 0)
message(FATAL_ERROR "\"python3 install-sysroot.py --arch=arm64\" failed (${build_sysroot_architecture})")
endif()
endif()
if (CMAKE_BUILD_ARCHITECTURE MATCHES arm32)
execute_process(
COMMAND python3 install-sysroot.py --arch=arm
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/webrtc/src/build/linux/sysroot_scripts"
RESULT_VARIABLE build_sysroot_architecture
)
if(NOT ${build_sysroot_architecture} EQUAL 0)
message(FATAL_ERROR "\"python3 install-sysroot.py --arch=arm\" failed (${build_sysroot_architecture})")
endif()
endif()
execute_process(
COMMAND "${CMAKE_CURRENT_LIST_DIR}/generate_ninja_files.bash" "${CMAKE_BUILD_ARCHITECTURE}" "${CMAKE_SYSROOT}"
WORKING_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/webrtc/src"
RESULT_VARIABLE generate_ninja_files_result
)
if(NOT ${generate_ninja_files_result} EQUAL 0)
message(FATAL_ERROR "\"generate_ninja_files.cmake\" failed (${generate_ninja_files_result})")
endif()
add_custom_target(
webrtc_native ALL
COMMAND ninja -C ${CMAKE_CURRENT_LIST_DIR}/webrtc/src/out/${CMAKE_BUILD_TYPE}
)
endif(WIN32)
# Manual installation of all dependencies.
list(GET webrtc_native_LIBRARY 0 webrtc_native_LIBRARY_only)
install(FILES ${webrtc_native_LIBRARY_only} DESTINATION lib)
install(FILES ${boringssl_LIBRARY} DESTINATION lib)
install(FILES ${libyuv_LIBRARY} DESTINATION lib)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/webrtc/src/out/${CMAKE_BUILD_TYPE}/obj/third_party/boringssl/boringssl DESTINATION lib)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/webrtc/src/out/${CMAKE_BUILD_TYPE}/obj/third_party/boringssl/boringssl_asm DESTINATION lib)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/webrtc/src/out/${CMAKE_BUILD_TYPE}/obj/third_party/libyuv/libyuv_internal DESTINATION lib)
# Install all includes except from third_party
install(DIRECTORY webrtc/src/ DESTINATION include
FILES_MATCHING PATTERN "*.h"
PATTERN webrtc/src/third_party EXCLUDE)
install(DIRECTORY webrtc/src/third_party/abseil-cpp/absl DESTINATION include
FILES_MATCHING PATTERN "*.h")
install(DIRECTORY webrtc/src/third_party/boringssl/src/include/openssl DESTINATION include
FILES_MATCHING PATTERN "*.h")
install(FILES webrtc/src/third_party/libyuv/include/libyuv.h DESTINATION include)
install(DIRECTORY webrtc/src/third_party/libyuv/include/libyuv DESTINATION include
FILES_MATCHING PATTERN "*.h")