forked from obsproject/obs-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
227 lines (194 loc) · 6.24 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
cmake_minimum_required(VERSION 2.8.12)
project(obs-browser)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
include_directories(SYSTEM "${CMAKE_SOURCE_DIR}/UI/obs-frontend-api")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}")
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/deps")
find_package(CEF QUIET)
if(NOT CEF_FOUND)
message(STATUS "CEF Not found -- obs-browser plugin disabled.")
return()
endif()
option(EXPERIMENTAL_SHARED_TEXTURE_SUPPORT_ENABLED "Enable shared texture support for the browser plugin (Win32)" ON)
option(BROWSER_PANEL_SUPPORT_ENABLED "Enables Qt web browser panel support" ON)
if(NOT APPLE)
option(USE_QT_LOOP "Runs CEF on the main UI thread alongside Qt instead of in its own thread" OFF)
else()
set(USE_QT_LOOP TRUE)
endif()
if(APPLE)
option(BROWSER_DEPLOY "Marks full deployment of browser plugin" OFF)
if(BROWSER_DEPLOY)
add_definitions(-DBROWSER_DEPLOY)
endif()
endif()
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/browser-config.h.in"
"${CMAKE_CURRENT_BINARY_DIR}/browser-config.h")
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories("${CEF_ROOT_DIR}")
# ----------------------------------------------------------------------------
set(obs-browser_LIBRARIES
libobs
obs-frontend-api
)
list(APPEND obs-browser_LIBRARIES
${CEF_LIBRARIES})
if(BROWSER_PANEL_SUPPORT_ENABLED OR USE_QT_LOOP)
if(DEFINED QTDIR${_lib_suffix})
list(APPEND CMAKE_PREFIX_PATH "${QTDIR${_lib_suffix}}")
elseif(DEFINED QTDIR)
list(APPEND CMAKE_PREFIX_PATH "${QTDIR}")
elseif(DEFINED ENV{QTDIR${_lib_suffix}})
list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR${_lib_suffix}}")
elseif(DEFINED ENV{QTDIR})
list(APPEND CMAKE_PREFIX_PATH "$ENV{QTDIR}")
endif()
set(CMAKE_AUTOMOC TRUE)
find_package(Qt5Widgets REQUIRED)
list(APPEND obs-browser_LIBRARIES
Qt5::Widgets
)
endif()
if(MSVC)
string(REPLACE "/MD" "/MT"
"CMAKE_C_FLAGS"
"${CMAKE_C_FLAGS}")
string(REPLACE "/MD" "/MT"
"CMAKE_CXX_FLAGS"
"${CMAKE_CXX_FLAGS}")
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" UPPER_CONFIG_TYPES)
foreach(CONFIG_TYPE ${UPPER_CONFIG_TYPES})
string(REPLACE "/MD" "/MT"
"CMAKE_C_FLAGS_${CONFIG_TYPE}"
"${CMAKE_C_FLAGS_${CONFIG_TYPE}}")
string(REPLACE "/MD" "/MT"
"CMAKE_CXX_FLAGS_${CONFIG_TYPE}"
"${CMAKE_CXX_FLAGS_${CONFIG_TYPE}}")
endforeach()
list(APPEND obs-browser_LIBRARIES
d3d11
dxgi
)
endif()
set(obs-browser_SOURCES
obs-browser-source.cpp
obs-browser-source-audio.cpp
obs-browser-plugin.cpp
browser-scheme.cpp
browser-client.cpp
browser-app.cpp
deps/json11/json11.cpp
deps/base64/base64.cpp
deps/wide-string.cpp
)
set(obs-browser_HEADERS
obs-browser-source.hpp
browser-scheme.hpp
browser-client.hpp
browser-app.hpp
browser-version.h
deps/json11/json11.hpp
deps/base64/base64.hpp
deps/wide-string.hpp
cef-headers.hpp
)
# only allow browser panels on win32 for now -- other operating systems
# need more testing
if(WIN32 AND BROWSER_PANEL_SUPPORT_ENABLED)
list(APPEND obs-browser_SOURCES
panel/browser-panel.cpp
panel/browser-panel-client.cpp
)
list(APPEND obs-browser_HEADERS
panel/browser-panel.hpp
panel/browser-panel-client.hpp
panel/browser-panel-internal.hpp
)
endif()
add_library(obs-browser MODULE
${obs-browser_SOURCES}
${obs-browser_HEADERS}
)
target_link_libraries(obs-browser
${obs-browser_LIBRARIES}
)
if(USE_QT_LOOP)
target_compile_definitions(obs-browser PRIVATE USE_QT_LOOP)
endif()
# ----------------------------------------------------------------------------
set(obs-browser-page_SOURCES
obs-browser-page/obs-browser-page-main.cpp
browser-app.cpp
deps/json11/json11.cpp
)
set(obs-browser-page_HEADERS
obs-browser-page/obs-browser-page-main.cpp
browser-app.hpp
deps/json11/json11.hpp
cef-headers.hpp
)
add_executable(obs-browser-page
${obs-browser-page_SOURCES}
${obs-browser-page_HEADERS}
)
target_link_libraries(obs-browser-page
${CEF_LIBRARIES}
)
if (APPLE)
set_target_properties(obs-browser-page PROPERTIES
COMPILE_FLAGS "-mmacosx-version-min=10.8")
endif(APPLE)
if (WIN32)
set_target_properties(obs-browser-page PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS")
endif(WIN32)
if (APPLE AND XCODE)
set_xcode_property(obs-browser-page CLANG_CXX_LIBRARY "libc++")
endif(APPLE AND XCODE)
# ----------------------------------------------------------------------------
if (WIN32)
math(EXPR BITS "8*${CMAKE_SIZEOF_VOID_P}")
add_custom_command(TARGET obs-browser POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CEF_ROOT_DIR}/Resources"
"${CMAKE_BINARY_DIR}/rundir/$<CONFIGURATION>/obs-plugins/${BITS}bit/"
)
add_custom_command(TARGET obs-browser POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${CEF_ROOT_DIR}/Release/chrome_elf.dll"
"${CMAKE_BINARY_DIR}/rundir/$<CONFIGURATION>/obs-plugins/${BITS}bit/"
COMMAND ${CMAKE_COMMAND} -E copy
"${CEF_ROOT_DIR}/Release/libcef.dll"
"${CMAKE_BINARY_DIR}/rundir/$<CONFIGURATION>/obs-plugins/${BITS}bit/"
COMMAND ${CMAKE_COMMAND} -E copy
"${CEF_ROOT_DIR}/Release/libEGL.dll"
"${CMAKE_BINARY_DIR}/rundir/$<CONFIGURATION>/obs-plugins/${BITS}bit/"
COMMAND ${CMAKE_COMMAND} -E copy
"${CEF_ROOT_DIR}/Release/libGLESv2.dll"
"${CMAKE_BINARY_DIR}/rundir/$<CONFIGURATION>/obs-plugins/${BITS}bit/"
COMMAND ${CMAKE_COMMAND} -E copy
"${CEF_ROOT_DIR}/Release/natives_blob.bin"
"${CMAKE_BINARY_DIR}/rundir/$<CONFIGURATION>/obs-plugins/${BITS}bit/"
COMMAND ${CMAKE_COMMAND} -E copy
"${CEF_ROOT_DIR}/Release/snapshot_blob.bin"
"${CMAKE_BINARY_DIR}/rundir/$<CONFIGURATION>/obs-plugins/${BITS}bit/"
COMMAND ${CMAKE_COMMAND} -E copy
"${CEF_ROOT_DIR}/Release/v8_context_snapshot.bin"
"${CMAKE_BINARY_DIR}/rundir/$<CONFIGURATION>/obs-plugins/${BITS}bit/"
)
endif()
if(APPLE AND NOT BROWSER_DEPLOY)
add_custom_command(TARGET obs-browser POST_BUILD
COMMAND "install_name_tool" -change
"@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework"
"${CEF_LIBRARY}/Chromium Embedded Framework"
"obs-browser.so")
add_custom_command(TARGET obs-browser-page POST_BUILD
COMMAND "install_name_tool" -change
"@rpath/Frameworks/Chromium Embedded Framework.framework/Chromium Embedded Framework"
"${CEF_LIBRARY}/Chromium Embedded Framework"
"obs-browser-page")
endif()
install_obs_plugin_with_data(obs-browser data)
install_obs_plugin(obs-browser-page)