forked from wtsnz/obs-ios-camera-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
374 lines (299 loc) · 9.45 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
cmake_minimum_required(VERSION 3.2)
project(obs-ios-camera-source)
set(CMAKE_PREFIX_PATH "${QTDIR}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set (CMAKE_CXX_STANDARD 17)
if (WIN32 OR APPLE)
include(external/FindLibObs.cmake)
endif()
find_package(LibObs REQUIRED)
find_package(FFmpeg REQUIRED COMPONENTS avcodec avutil)
# find_ffmpeg_library(avcodec)
# find_ffmpeg_library(avutil)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH 64)
else()
set(ARCH 32)
endif()
if(WIN32)
find_library(WS2_32_LIBRARY ws2_32)
endif()
# ---- libcnary
set(libcnary_HEADERS
deps/libplist/libcnary/include/iterator.h
deps/libplist/libcnary/include/list.h
deps/libplist/libcnary/include/node_iterator.h
deps/libplist/libcnary/include/node_list.h
deps/libplist/libcnary/include/node.h
deps/libplist/libcnary/include/object.h
)
set(libcnary_SOURCES
deps/libplist/libcnary/cnary.c
deps/libplist/libcnary/iterator.c
deps/libplist/libcnary/list.c
deps/libplist/libcnary/node_iterator.c
deps/libplist/libcnary/node_list.c
deps/libplist/libcnary/node.c
)
include_directories(libcnary deps/libplist/libcnary/include)
add_library(libcnary STATIC
${libcnary_SOURCES}
${libcnary_HEADERS})
#------- libplist
set(libplist_HEADERS
deps/libplist/src/base64.h
deps/libplist/src/bytearray.h
deps/libplist/src/hashtable.h
deps/libplist/src/msc_config.h
deps/libplist/src/plist.h
deps/libplist/src/ptrarray.h
deps/libplist/src/strbuf.h
deps/libplist/src/time64_limits.h
deps/libplist/src/time64.h
deps/libplist/include/plist/Array.h
deps/libplist/include/plist/Boolean.h
deps/libplist/include/plist/Data.h
deps/libplist/include/plist/Date.h
deps/libplist/include/plist/Dictionary.h
deps/libplist/include/plist/Integer.h
deps/libplist/include/plist/Key.h
deps/libplist/include/plist/Node.h
deps/libplist/include/plist/plist.h
deps/libplist/include/plist/plist++.h
deps/libplist/include/plist/Real.h
deps/libplist/include/plist/String.h
deps/libplist/include/plist/Structure.h
deps/libplist/include/plist/Uid.h
)
include_directories(libplist deps/libplist/include
deps/libplist/src
deps/libplist/libcnary/include)
set(libplist_SOURCES
deps/libplist/src/Array.cpp
deps/libplist/src/base64.c
deps/libplist/src/Boolean.cpp
deps/libplist/src/bplist.c
deps/libplist/src/bytearray.c
deps/libplist/src/Data.cpp
deps/libplist/src/Date.cpp
deps/libplist/src/Dictionary.cpp
deps/libplist/src/hashtable.c
deps/libplist/src/Integer.cpp
deps/libplist/src/Key.cpp
deps/libplist/src/Node.cpp
deps/libplist/src/plist.c
deps/libplist/src/ptrarray.c
deps/libplist/src/Real.cpp
deps/libplist/src/String.cpp
deps/libplist/src/Structure.cpp
deps/libplist/src/time64.c
deps/libplist/src/Uid.cpp
deps/libplist/src/xplist.c
)
add_library(libplist STATIC
${libplist_SOURCES}
${libplist_HEADERS})
target_link_libraries(libplist
libcnary
)
#------- libusbmuxd
set(libusbmuxd_HEADERS
deps/libusbmuxd/common/collection.h
deps/libusbmuxd/common/socket.h
deps/libusbmuxd/src/msc_config.h
)
set(libusbmuxd_SOURCES
deps/libusbmuxd/common/collection.c
deps/libusbmuxd/common/socket.c
deps/libusbmuxd/src/libusbmuxd.c
)
include_directories(libusbmuxd include
deps/libusbmuxd/common
deps/libusbmuxd/include)
add_library(libusbmuxd STATIC
${libusbmuxd_SOURCES}
${libusbmuxd_HEADERS})
target_link_libraries(libusbmuxd
libplist
)
if(WIN32)
target_link_libraries(libusbmuxd wsock32 ws2_32)
endif()
# -------- Portal Lib
set(portal_HEADERS
deps/portal/src/Channel.hpp
deps/portal/src/Device.hpp
deps/portal/src/Portal.hpp
deps/portal/src/Protocol.hpp
deps/portal/src/logging.h
)
set(portal_SOURCES
deps/portal/src/Channel.cpp
deps/portal/src/Device.cpp
deps/portal/src/Portal.cpp
deps/portal/src/Protocol.cpp
)
include_directories(portal include
deps/portal/src/
)
add_library(portal STATIC
${portal_SOURCES}
${portal_HEADERS})
target_link_libraries(portal
libusbmuxd
)
## --
set(ENABLE_PROGRAMS false)
set(obs-ios-camera-source_SOURCES
src/obs-ios-camera-plugin.cpp
src/obs-ios-camera-source.cpp
src/ffmpeg-decode.c
src/VideoDecoder.cpp
src/FFMpegVideoDecoder.cpp
src/FFMpegAudioDecoder.cpp
src/Thread.cpp)
set(obs-ios-camera-source_HEADERS
src/obs-ios-camera-source.h
src/ffmpeg-decode.h
src/VideoDecoder.h
src/FFMpegVideoDecoder.h
src/FFMpegAudioDecoder.h
src/Thread.hpp
src/Queue.hpp)
if(APPLE)
message("Linking Video Toolbox")
find_library(AVFOUNDATION AVFoundation)
find_library(COCOA Cocoa)
find_library(COREFOUNDATION CoreFoundation)
find_library(COREMEDIA CoreMedia)
find_library(COREVIDEO CoreVideo)
find_library(COREMEDIAIO CoreMediaIO)
find_library(VIDEOTOOLBOX VideoToolbox)
include_directories(${AVFOUNDATION}
${COCOA}
${COREFOUNDATION}
${COREMEDIA}
${COREVIDEO}
${COREMEDIAIO}
${VIDEOTOOLBOX}
${COCOA})
list(APPEND obs-ios-camera-source_SOURCES
src/VideoToolboxVideoDecoder.cpp)
list(APPEND obs-ios-camera-source_HEADERS
src/VideoToolboxVideoDecoder.h)
add_definitions(-fobjc-arc)
endif()
# --- Platform-independent build settings ---
add_library(obs-ios-camera-source MODULE
${obs-ios-camera-source_SOURCES}
${obs-ios-camera-source_HEADERS})
#find_package(FFmpeg REQUIRED COMPONENTS avcodec avutil)
include_directories(
"${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api"
${FFMPEG_INCLUDE_DIRS}
)
if(MSVC)
# https://stackoverflow.com/q/33290879
# needed for some MSVC installations
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /SAFESEH:NO")
endif()
target_link_libraries(obs-ios-camera-source
libobs
portal
${FFMPEG_LIBRARIES}
)
# --- End of section ---
# --- Windows-specific build settings and tasks ---
if(WIN32)
if(NOT DEFINED OBS_FRONTEND_LIB)
set(OBS_FRONTEND_LIB "OBS_FRONTEND_LIB-NOTFOUND" CACHE FILEPATH "OBS frontend library")
message(FATAL_ERROR "Could not find OBS Frontend API\'s library !")
endif()
if(MSVC)
# Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL)
add_definitions(/MP /d2FH4-)
endif()
if(ARCH EQUAL 64)
set(OBS_ARCH_NAME "64bit")
set(OBS_BUILDDIR_ARCH "build64")
else()
set(OBS_ARCH_NAME "32bit")
set(OBS_BUILDDIR_ARCH "build32")
add_definitions(/arch:SSE2)
endif()
include_directories(
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/UI"
)
# target_link_libraries(obs-ios-camera-source
# "${OBS_FRONTEND_LIB}")
# --- Release package helper ---
# The "release" folder has a structure similar OBS' one on Windows
set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release")
add_custom_command(TARGET obs-ios-camera-source POST_BUILD
# If config is Release, package release files
COMMAND if $<CONFIG:Release>==1 (
"${CMAKE_COMMAND}" -E make_directory
"${RELEASE_DIR}/data/obs-plugins/obs-ios-camera-source"
"${RELEASE_DIR}/obs-plugins/${OBS_ARCH_NAME}")
COMMAND if $<CONFIG:Release>==1 (
"${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/data"
"${RELEASE_DIR}/data/obs-plugins/obs-ios-camera-source")
COMMAND if $<CONFIG:Release>==1 (
"${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:obs-ios-camera-source>"
"${RELEASE_DIR}/obs-plugins/${OBS_ARCH_NAME}")
# If config is RelWithDebInfo, package release files
COMMAND if $<CONFIG:RelWithDebInfo>==1 (
"${CMAKE_COMMAND}" -E make_directory
"${RELEASE_DIR}/data/obs-plugins/obs-ios-camera-source"
"${RELEASE_DIR}/obs-plugins/${OBS_ARCH_NAME}")
COMMAND if $<CONFIG:RelWithDebInfo>==1 (
"${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/data"
"${RELEASE_DIR}/data/obs-plugins/obs-ios-camera-source")
COMMAND if $<CONFIG:RelWithDebInfo>==1 (
"${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:obs-ios-camera-source>"
"${RELEASE_DIR}/obs-plugins/${OBS_ARCH_NAME}")
COMMAND if $<CONFIG:RelWithDebInfo>==1 (
"${CMAKE_COMMAND}" -E copy
"$<TARGET_PDB_FILE:obs-ios-camera-source>"
"${RELEASE_DIR}/obs-plugins/${OBS_ARCH_NAME}")
# Copy to obs-studio dev environment for immediate testing
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E copy
"$<TARGET_FILE:obs-ios-camera-source>"
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${OBS_ARCH_NAME}")
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E make_directory
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-ios-camera-source")
COMMAND if $<CONFIG:Debug>==1 (
"${CMAKE_COMMAND}" -E copy_directory
"${PROJECT_SOURCE_DIR}/data"
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-ios-camera-source")
)
# --- End of sub-section ---
endif()
# --- End of section ---
# -- OS X specific build settings and tasks --
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fvisibility=default")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-unused-function -Werror-implicit-function-declaration -Wno-missing-field-initializers ${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-unused-function -Werror-implicit-function-declaration -Wno-missing-braces -Wno-missing-field-initializers ${CMAKE_C_FLAGS} -std=gnu99 -fno-strict-aliasing")
set_target_properties(obs-ios-camera-source PROPERTIES PREFIX "")
target_link_libraries(obs-ios-camera-source "${OBS_FRONTEND_LIB}"
${AVFOUNDATION}
${COCOA}
${COREFOUNDATION}
${COREMEDIA}
${COREVIDEO}
${COREMEDIAIO}
${VIDEOTOOLBOX}
${COCOA})
endif()
# -- End of section --