-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
213 lines (169 loc) · 7.16 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
cmake_minimum_required(VERSION 3.16...3.25)
# OBS 28.x.x?
if (NOT COMMAND legacy_check)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/legacy.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/legacy.cmake)
endif()
return()
endif()
legacy_check()
find_package(CEF REQUIRED)
find_package(ZLIB REQUIRED)
find_package(Detours REQUIRED)
find_package(Qt6 REQUIRED Widgets)
include(FindGRPC.cmake)
## -- Grpc between plugin and proxy
# Proto file
get_filename_component(papi_proto "sl_browser_api.proto" ABSOLUTE)
get_filename_component(papi_proto_path "${papi_proto}" PATH)
message ("${CMAKE_CURRENT_BINARY_DIR}")
# Generated sources
set(papi_proto_srcs "${CMAKE_CURRENT_BINARY_DIR}/sl_browser_api.pb.cc")
set(papi_proto_hdrs "${CMAKE_CURRENT_BINARY_DIR}/sl_browser_api.pb.h")
set(papi_grpc_srcs "${CMAKE_CURRENT_BINARY_DIR}/sl_browser_api.grpc.pb.cc")
set(papi_grpc_hdrs "${CMAKE_CURRENT_BINARY_DIR}/sl_browser_api.grpc.pb.h")
add_custom_command(
OUTPUT "${papi_proto_srcs}" "${papi_proto_hdrs}" "${papi_grpc_srcs}" "${papi_grpc_hdrs}"
COMMAND ${CMAKE_COMMAND} -E echo "Running protoc"
COMMAND ${_PROTOBUF_PROTOC}
ARGS --grpc_out "${CMAKE_CURRENT_BINARY_DIR}"
--cpp_out "${CMAKE_CURRENT_BINARY_DIR}"
-I "${papi_proto_path}"
--plugin=protoc-gen-grpc="${_GRPC_CPP_PLUGIN_EXECUTABLE}"
"${papi_proto}"
DEPENDS "${papi_proto}")
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
# papi_grpc_proto
add_library(papi_grpc_proto
${papi_grpc_srcs}
${papi_grpc_hdrs}
${papi_proto_srcs}
${papi_proto_hdrs})
target_link_libraries(papi_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
## -- Browser Proxy Process
add_executable(sl-browser WIN32)
#target_compile_definitions(sl-browser PRIVATE SL_OBS_VERSION="")
#target_compile_definitions(sl-browser PRIVATE GITHUB_REVISION="")
#target_compile_definitions(sl-browser PRIVATE SL_REVISION="")
target_compile_options(sl-browser PRIVATE $<IF:$<CONFIG:DEBUG>,/MTd,/MT>)
target_link_options(sl-browser PRIVATE /NODEFAULTLIB:msvcrt)
set_target_properties(sl-browser PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB:msvcrtd.lib")
if (CMAKE_BUILD_TYPE MATCHES Debug)
target_link_options(sl-browser PRIVATE /NODEFAULTLIB:msvcrtd.lib)
endif()
target_sources(
sl-browser
PRIVATE main.cpp
GrpcBrowser.cpp
SlBrowser.cpp
SlBrowserWidget.cpp
browser-app.cpp
browser-app.hpp
browser-client.cpp
browser-client.hpp
browser-scheme.cpp
browser-scheme.hpp
browser-version.h
cef-headers.hpp
deps/json11/json11.cpp
deps/json11/json11.hpp
deps/base64/base64.cpp
deps/base64/base64.hpp
deps/signal-restore.cpp
deps/signal-restore.hpp
${papi_proto_srcs}
${papi_grpc_srcs})
target_include_directories(sl-browser PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/deps")
target_compile_features(sl-browser PRIVATE cxx_std_17)
target_link_libraries(sl-browser PRIVATE CEF::Wrapper CEF::Library d3d11 dxgi)
target_link_libraries(sl-browser PRIVATE Qt::Widgets Qt::Core Qt::Gui)
target_link_libraries(sl-browser PRIVATE Detours::Detours)
target_link_libraries(sl-browser PRIVATE
papi_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
target_link_options(sl-browser PRIVATE
"/IGNORE:4099" # Ignore PDB warnings
"/IGNORE:4098"
)
target_compile_options(sl-browser PRIVATE $<IF:$<CONFIG:DEBUG>,/MTd,/MT>)
target_compile_definitions(sl-browser PRIVATE NOMINMAX)
add_custom_command(
TARGET sl-browser POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${CMAKE_CURRENT_SOURCE_DIR}/streamlabs-app-icon.png
$<TARGET_FILE_DIR:sl-browser>/streamlabs-app-icon.png
)
## -- Plugin loaded by obs
add_library(sl-browser-plugin MODULE)
target_sources(
sl-browser-plugin
PRIVATE sl-browser-plugin.cpp
GrpcPlugin.cpp
PluginJsHandler.cpp
QtGuiModifications.cpp
WebServer.cpp
WebServer.cpp
SlBrowserDock.cpp
deps/json11/json11.cpp
deps/minizip/ioapi.c
deps/minizip/iowin32.c
deps/minizip/mztools.c
deps/minizip/unzip.c
deps/minizip/zip.c
${papi_proto_srcs}
${papi_grpc_srcs}
)
target_link_libraries(sl-browser-plugin PRIVATE Detours::Detours)
target_link_libraries(sl-browser-plugin PRIVATE ZLIB::ZLIB)
target_link_libraries(sl-browser-plugin PRIVATE Qt::Widgets)
target_link_libraries(sl-browser-plugin PRIVATE Qt::Core)
target_link_libraries(sl-browser-plugin PRIVATE Qt::Gui)
target_link_libraries(sl-browser-plugin PRIVATE CEF::Wrapper CEF::Library) # The plugin uses ->setURL etc files that are CEF based
target_include_directories(sl-browser-plugin PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/deps")
target_include_directories(sl-browser-plugin PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/deps/json11")
target_include_directories(sl-browser-plugin PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/../obs-browser/panel")
target_include_directories(sl-browser-plugin PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/UI")
target_compile_features(sl-browser-plugin PRIVATE cxx_std_17)
target_compile_definitions(sl-browser-plugin PRIVATE BROWSER_AVAILABLE)
#target_compile_definitions(sl-browser-plugin PRIVATE SL_OBS_VERSION="")
#target_compile_definitions(sl-browser-plugin PRIVATE GITHUB_REVISION="")
#target_compile_definitions(sl-browser-plugin PRIVATE SL_REVISION="")
target_link_libraries(sl-browser-plugin PRIVATE OBS::libobs OBS::frontend-api)
target_link_libraries(sl-browser-plugin PRIVATE ZLIB::ZLIB)
target_link_libraries(sl-browser-plugin PRIVATE
papi_grpc_proto
${_REFLECTION}
${_GRPC_GRPCPP}
${_PROTOBUF_LIBPROTOBUF})
target_link_options(sl-browser-plugin PRIVATE
"/IGNORE:4099" # Ignore PDB warnings
"/IGNORE:4098"
)
target_compile_options(sl-browser-plugin PRIVATE
"/wd4996" # 'obs_frontend_add_dock': was declared deprecated
)
target_compile_options(sl-browser-plugin PRIVATE $<IF:$<CONFIG:DEBUG>,/MTd,/MT>)
target_compile_definitions(sl-browser-plugin PRIVATE NOMINMAX)
## -- Helper proxy children
add_executable(sl-browser-page)
target_sources(sl-browser-page PRIVATE cef-headers.hpp sl-browser-page/sl-browser-page-main.cpp browser-app.cpp
browser-app.hpp deps/json11/json11.cpp deps/json11/json11.hpp)
target_link_libraries(sl-browser-page PRIVATE CEF::Library)
target_include_directories(sl-browser-page PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/deps
${CMAKE_CURRENT_SOURCE_DIR}/sl-browser-page)
target_sources(sl-browser-page PRIVATE sl-browser-page.manifest)
target_compile_features(sl-browser-page PRIVATE cxx_std_17)
if(TARGET CEF::Wrapper_Debug)
target_link_libraries(sl-browser-page PRIVATE optimized CEF::Wrapper)
target_link_libraries(sl-browser-page PRIVATE debug CEF::Wrapper_Debug)
else()
target_link_libraries(sl-browser-page PRIVATE CEF::Wrapper)
endif()
target_compile_definitions(sl-browser-page PRIVATE ENABLE_BROWSER_SHARED_TEXTURE)
target_compile_options(sl-browser-page PRIVATE $<IF:$<CONFIG:DEBUG>,/MTd,/MT>)
target_link_options(sl-browser-page PRIVATE "LINKER:/IGNORE:4099" "LINKER:/SUBSYSTEM:WINDOWS")