|
| 1 | +cmake_minimum_required(VERSION 3.0) |
| 2 | + |
| 3 | +project(cef-isolation) |
| 4 | + |
| 5 | +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}") |
| 6 | +set(CMAKE_INCLUDE_CURRENT_DIR TRUE) |
| 7 | + |
| 8 | +include(BSUtils) |
| 9 | + |
| 10 | +find_package(LibObs REQUIRED) |
| 11 | +find_package(CEF REQUIRED) |
| 12 | + |
| 13 | +if(APPLE) |
| 14 | + find_library(COCOA_FRAMEWORK Cocoa) |
| 15 | + find_library(APPKIT_FRAMEWORK AppKit) |
| 16 | + find_library(IOSURFACE_FRAMEWORK IOSurface) |
| 17 | + |
| 18 | + # Compile isolation and bootstrap as 32bit |
| 19 | + # Everything else is still 64bit |
| 20 | + if (CEF_ROOT_DIR MATCHES ".*32^") |
| 21 | + set(CEF_ISOLATION_32 "true") |
| 22 | + endif() |
| 23 | + |
| 24 | + set(_xcodebuild "xcodebuild") |
| 25 | + set(_xcodebuild_args -sdk -version) |
| 26 | + set(_sed "sed") |
| 27 | + set(_sed_args "s/Path: \\(.*10.8.sdk\\)/\\1/p") |
| 28 | + |
| 29 | + execute_process( |
| 30 | + COMMAND xcodebuild ${_xcodebuild_args} |
| 31 | + COMMAND sed -n ${_sed_args} |
| 32 | + OUTPUT_VARIABLE OSX_10_8_SDK) |
| 33 | + |
| 34 | + if(NOT OSX_10_8_SDK) |
| 35 | + message(FATAL_ERROR "macosx10.8.sdk is required to build this plugin") |
| 36 | + else(NOT OSX_10_8_SDK) |
| 37 | + message("Found macosx10.8.sdk at ${OSX_10_SDK}") |
| 38 | + endif(NOT OSX_10_8_SDK) |
| 39 | + |
| 40 | +endif(APPLE) |
| 41 | + |
| 42 | +set(obs-browser_SOURCES |
| 43 | + obs-browser/main.cpp |
| 44 | + shared/browser-source.mm) |
| 45 | + |
| 46 | +set(obs-browser_HEADERS |
| 47 | + shared/browser-manager.hpp |
| 48 | + shared/browser-source.hpp |
| 49 | + shared/browser-listener.hpp |
| 50 | + shared/browser-settings.hpp) |
| 51 | + |
| 52 | +if (APPLE) |
| 53 | + list(APPEND obs-browser_SOURCES |
| 54 | + shared-apple/browser-settings-bridge.mm |
| 55 | + obs-browser/apple/browser-manager-mac.mm |
| 56 | + obs-browser/apple/cef-isolation-service-manager.mm |
| 57 | + obs-browser/apple/cef-isolation-service.mm |
| 58 | + obs-browser/apple/client-connection-delegate.mm) |
| 59 | + |
| 60 | + |
| 61 | + list(APPEND obs-browser_HEADERS |
| 62 | + shared-apple/cef-logging.h |
| 63 | + shared-apple/cef-isolation.h |
| 64 | + shared-apple/browser-settings-bridge.h |
| 65 | + obs-browser/apple/browser-manager-mac.h |
| 66 | + obs-browser/apple/cef-isolation-service.h |
| 67 | + obs-browser/apple/cef-isolation-service-manager.h |
| 68 | + obs-browser/apple/client-connection-delegate.h) |
| 69 | + |
| 70 | +else (APPLE) |
| 71 | + list(APPEND obs-browser_SOURCES |
| 72 | + shared/browser-client.cpp |
| 73 | + shared/browser-task.cpp |
| 74 | + shared/browser-app.cpp) |
| 75 | + |
| 76 | + list(APPEND obs-browser_HEADERS |
| 77 | + shared/browser-client.hpp |
| 78 | + shared/browser-task.hpp |
| 79 | + shared/browser-app.hpp) |
| 80 | + |
| 81 | +endif(APPLE) |
| 82 | + |
| 83 | +set(obs-browser_LIBRARIES |
| 84 | + libobs) |
| 85 | + |
| 86 | +if (APPLE) |
| 87 | + list(APPEND obs-browser_LIBRARIES |
| 88 | + ${APPKIT_FRAMEWORK} |
| 89 | + ${IOSURFACE_FRAMEWORK}) |
| 90 | +endif(APPLE) |
| 91 | + |
| 92 | + |
| 93 | +add_library(obs-browser MODULE |
| 94 | + ${obs-browser_SOURCES} |
| 95 | + ${obs-browser_HEADERS}) |
| 96 | + |
| 97 | + |
| 98 | +target_include_directories(obs-browser PRIVATE |
| 99 | + "obs-browser" |
| 100 | + "shared") |
| 101 | + |
| 102 | +if (APPLE) |
| 103 | + target_include_directories(obs-browser PUBLIC |
| 104 | + "shared-apple") |
| 105 | +endif(APPLE) |
| 106 | + |
| 107 | +if (APPLE) |
| 108 | + set_xcode_property(obs-browser CLANG_CXX_LIBRARY "libc++") |
| 109 | +endif(APPLE) |
| 110 | + |
| 111 | +target_link_libraries(obs-browser |
| 112 | + ${obs-browser_LIBRARIES}) |
| 113 | + |
| 114 | +if(APPLE) |
| 115 | + target_link_libraries(obs-browser ${COCOA_FRAMEWORK} ${IOSURFACE_FRAMEWORK}) |
| 116 | + |
| 117 | + set(cef-isolation_SOURCES |
| 118 | + cef-isolation/main.mm |
| 119 | + cef-isolation/cef-isolated-client.mm |
| 120 | + cef-isolation/browser-handle.mm |
| 121 | + cef-isolation/browser-render-handler.mm |
| 122 | + cef-isolation/browser-texture-mac.mm |
| 123 | + cef-isolation/service-connection-delegate.mm |
| 124 | + shared/browser-client.cpp |
| 125 | + shared/browser-task.cpp |
| 126 | + shared/browser-app.cpp) |
| 127 | + |
| 128 | + set(cef-isolation_HEADERS |
| 129 | + shared-apple/cef-logging.h |
| 130 | + shared-apple/cef-isolation.h |
| 131 | + cef-isolation/cef-isolated-client.h |
| 132 | + cef-isolation/browser-handle.h |
| 133 | + cef-isolation/browser-render-handler.hpp |
| 134 | + cef-isolation/browser-texture-mac.h |
| 135 | + cef-isolation/service-connection-delegate.h |
| 136 | + shared/browser-texture.hpp |
| 137 | + shared/browser-client.hpp |
| 138 | + shared/browser-task.hpp |
| 139 | + shared/browser-app.hpp |
| 140 | + shared-apple/browser-settings-bridge.h) |
| 141 | + |
| 142 | + add_executable(cef-isolation |
| 143 | + ${cef-isolation_SOURCES} |
| 144 | + ${cef-isolation_HEADERS}) |
| 145 | + |
| 146 | + if (CEF_ISOLATION_32) |
| 147 | + set_target_properties(cef-isolation PROPERTIES |
| 148 | + COMPILE_FLAGS "-m32" |
| 149 | + LINK_FLAGS "-m32" |
| 150 | + OSX_ARCHITECTURES "i386") |
| 151 | + endif(CEF_ISOLATION_32) |
| 152 | + |
| 153 | + set_target_properties(cef-isolation PROPERTIES |
| 154 | + XCODE_ATTRIBUTE_SDKROOT macosx10.8) |
| 155 | + |
| 156 | + set_xcode_property(cef-isolation CLANG_CXX_LIBRARY "libc++") |
| 157 | + |
| 158 | + target_include_directories(cef-isolation PRIVATE |
| 159 | + "cef-isolation" |
| 160 | + "shared" |
| 161 | + "shared-apple") |
| 162 | + |
| 163 | + target_include_directories_system(cef-isolation PUBLIC ${CEF_INCLUDE_DIR}) |
| 164 | + |
| 165 | + target_link_libraries(cef-isolation |
| 166 | + ${CEF_LIBRARIES} |
| 167 | + ${APPKIT_FRAMEWORK} |
| 168 | + ${IOSURFACE_FRAMEWORK}) |
| 169 | + |
| 170 | +endif(APPLE) |
| 171 | + |
| 172 | +set(cef-bootstrap_SOURCES |
| 173 | + cef-bootstrap/main.cpp |
| 174 | + shared/browser-app.cpp) |
| 175 | + |
| 176 | +set(cef-bootstrap_HEADERS |
| 177 | + shared/browser-app.hpp) |
| 178 | + |
| 179 | +add_executable(cef-bootstrap |
| 180 | + ${cef-bootstrap_SOURCES} |
| 181 | + ${cef-bootstrap_HEADERS}) |
| 182 | + |
| 183 | +if (APPLE) |
| 184 | + if (CEF_ISOLATION_32) |
| 185 | + set_target_properties(cef-bootstrap PROPERTIES |
| 186 | + COMPILE_FLAGS "-m32 -isysroot ${OSX_10_8_SDK}" |
| 187 | + LINK_FLAGS "-m32" |
| 188 | + OSX_ARCHITECTURES "i386") |
| 189 | + else(CEF_ISOLATION_32) |
| 190 | + set_target_properties(cef-bootstrap PROPERTIES |
| 191 | + COMPILE_FLAGS "-isysroot ${OSX_10_8_SDK}") |
| 192 | + endif(CEF_ISOLATION_32) |
| 193 | + |
| 194 | + set_target_properties(cef-bootstrap PROPERTIES |
| 195 | + XCODE_ATTRIBUTE_SDKROOT macosx10.8) |
| 196 | +endif(APPLE) |
| 197 | + |
| 198 | +if (APPLE) |
| 199 | + set_xcode_property(cef-bootstrap CLANG_CXX_LIBRARY "libc++") |
| 200 | +endif(APPLE) |
| 201 | + |
| 202 | +target_include_directories(cef-bootstrap PRIVATE "shared") |
| 203 | +target_include_directories_system(cef-bootstrap PUBLIC ${CEF_INCLUDE_DIR}) |
| 204 | + |
| 205 | +target_link_libraries(cef-bootstrap |
| 206 | + ${CEF_LIBRARIES}) |
| 207 | + |
| 208 | + |
| 209 | +if (APPLE) |
| 210 | + |
| 211 | + set_target_properties(cef-isolation PROPERTIES |
| 212 | + OUTPUT_NAME "CEF" |
| 213 | + MACOSX_BUNDLE TRUE |
| 214 | + BUILD_WITH_INSTALL_RPATH TRUE |
| 215 | + INSTALL_RPATH "@loader_path/../Frameworks" |
| 216 | + MACOSX_BUNDLE_BUNDLE_NAME "CEF Helper" |
| 217 | + MACOSX_BUNDLE_GUI_IDENTIFIER "org.catchexception.cef.cef-isolation") |
| 218 | + |
| 219 | + set_target_properties(cef-bootstrap PROPERTIES |
| 220 | + OUTPUT_NAME "CEF Helper" |
| 221 | + MACOSX_BUNDLE TRUE |
| 222 | + BUILD_WITH_INSTALL_RPATH TRUE |
| 223 | + INSTALL_RPATH "@loader_path/../../../" |
| 224 | + MACOSX_BUNDLE_BUNDLE_NAME "CEF Helper" |
| 225 | + MACOSX_BUNDLE_GUI_IDENTIFIER "org.catchexception.cef.cef-bootstrap") |
| 226 | + |
| 227 | + |
| 228 | + add_custom_command(TARGET cef-isolation |
| 229 | + # Disable taskbar visibility |
| 230 | + COMMAND defaults write "$<TARGET_FILE_DIR:cef-isolation>/../Info.plist" "LSUIElement" true) |
| 231 | + |
| 232 | + add_custom_command(TARGET cef-bootstrap POST_BUILD |
| 233 | + # Remember if you change this but don't cause a recompile it will not rename it successfully |
| 234 | + COMMAND install_name_tool -change "@executable_path/Chromium Embedded Framework" "@rpath/Chromium Embedded Framework.framework/Chromium Embedded Framework" "$<TARGET_FILE:cef-bootstrap>" |
| 235 | + |
| 236 | + # Disable taskbar visibility |
| 237 | + COMMAND defaults write "$<TARGET_FILE_DIR:cef-bootstrap>/../Info.plist" "LSUIElement" true) |
| 238 | + |
| 239 | + add_custom_command(TARGET cef-isolation POST_BUILD |
| 240 | + # Remember if you change this but don't cause a recompile in the shared object it will not rename it successfully |
| 241 | + COMMAND install_name_tool -change "@executable_path/Chromium Embedded Framework" "@rpath/Chromium Embedded Framework.framework/Chromium Embedded Framework" "$<TARGET_FILE:cef-isolation>" |
| 242 | + |
| 243 | + # Make a Frameworks directory |
| 244 | + COMMAND mkdir -p "$<TARGET_FILE_DIR:cef-isolation>/../Frameworks" |
| 245 | + |
| 246 | + # Copy the CEF and support frameworks |
| 247 | + COMMAND cp -Rf "${CEF_ROOT_DIR}/Release/Chromium Embedded Framework.framework" "$<TARGET_FILE_DIR:cef-isolation>/../Frameworks/" |
| 248 | + |
| 249 | + # Setup the helper apps |
| 250 | + COMMAND rm -rf "$<TARGET_FILE_DIR:cef-isolation>/../Frameworks/CEF Helper.app" |
| 251 | + COMMAND cp -Rf "$<TARGET_FILE_DIR:cef-bootstrap>/../../../CEF Helper.app" "$<TARGET_FILE_DIR:cef-isolation>/../Frameworks" |
| 252 | + COMMAND "BUILT_PRODUCTS_DIR=$<TARGET_FILE_DIR:cef-isolation>/../../.." "CONTENTS_FOLDER_PATH=CEF.app/Contents" "${CEF_ROOT_DIR}/tools/make_more_helpers.sh" "Frameworks" "CEF") |
| 253 | + |
| 254 | +endif(APPLE) |
| 255 | + |
| 256 | +install_obs_plugin_with_data(obs-browser data) |
| 257 | + |
| 258 | +if(APPLE) |
| 259 | + install_obs_plugin_bundle(cef-isolation "CEF.app") |
| 260 | +else(APPLE) |
| 261 | + install_obs_plugin(obs-bootstrap) |
| 262 | +endif(APPLE) |
| 263 | + |
0 commit comments