Skip to content

Commit

Permalink
Add procedure handler based API
Browse files Browse the repository at this point in the history
  • Loading branch information
tytan652 committed Jan 13, 2024
1 parent e873fb0 commit f948be2
Show file tree
Hide file tree
Showing 11 changed files with 1,003 additions and 6 deletions.
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ legacy_check()

option(ENABLE_BROWSER "Enable browser source plugin (required Chromium Embedded Framework)" OFF)

add_subdirectory(lib)

if(NOT ENABLE_BROWSER)
target_disable(obs-browser)
target_disable_feature(obs-browser "Browser sources are not enabled by default (set CEF_ROOT_DIR and ENABLE_BROWSER)")
Expand Down Expand Up @@ -38,6 +40,8 @@ target_sources(
deps/signal-restore.hpp
deps/wide-string.cpp
deps/wide-string.hpp
obs-browser-api-impl.cpp
obs-browser-api-impl.hpp
obs-browser-plugin.cpp
obs-browser-source-audio.cpp
obs-browser-source.cpp
Expand All @@ -46,7 +50,7 @@ target_sources(
target_include_directories(obs-browser PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/deps")

target_compile_features(obs-browser PRIVATE cxx_std_17)
target_link_libraries(obs-browser PRIVATE OBS::libobs OBS::frontend-api nlohmann_json::nlohmann_json)
target_link_libraries(obs-browser PRIVATE OBS::libobs OBS::frontend-api OBS::browser-api nlohmann_json::nlohmann_json)

if(OS_WINDOWS)
include(cmake/os-windows.cmake)
Expand Down
4 changes: 2 additions & 2 deletions cmake/feature-panels.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ target_compile_definitions(browser-panels INTERFACE BROWSER_AVAILABLE)
target_sources(
obs-browser
PRIVATE # cmake-format: sortable
panel/browser-panel-client.cpp panel/browser-panel-client.hpp panel/browser-panel-internal.hpp
panel/browser-panel.cpp)
obs-browser-api-impl-panel.cpp panel/browser-panel-client.cpp panel/browser-panel-client.hpp
panel/browser-panel-internal.hpp panel/browser-panel.cpp)

target_link_libraries(obs-browser PRIVATE OBS::browser-panels Qt::Widgets)

Expand Down
12 changes: 9 additions & 3 deletions cmake/legacy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(obs-browser)
option(ENABLE_BROWSER "Enable building OBS with browser source plugin (required Chromium Embedded Framework)"
${OS_LINUX})

add_subdirectory(lib)

if(NOT ENABLE_BROWSER OR NOT ENABLE_UI)
message(STATUS "OBS: DISABLED obs-browser")
message(
Expand Down Expand Up @@ -54,6 +56,8 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/browser-config.h.in ${CMAKE_BINARY_DI
target_sources(
obs-browser
PRIVATE obs-browser-plugin.cpp
obs-browser-api-impl.cpp
obs-browser-api-impl.hpp
obs-browser-source.cpp
obs-browser-source.hpp
obs-browser-source-audio.cpp
Expand All @@ -76,13 +80,13 @@ target_sources(

target_include_directories(obs-browser PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/deps ${CMAKE_BINARY_DIR}/config)

target_link_libraries(obs-browser PRIVATE OBS::libobs OBS::frontend-api nlohmann_json::nlohmann_json)
target_link_libraries(obs-browser PRIVATE OBS::libobs OBS::frontend-api OBS::browser-api nlohmann_json::nlohmann_json)

target_compile_features(obs-browser PRIVATE cxx_std_17)

if(ENABLE_BROWSER_PANELS OR ENABLE_BROWSER_QT_LOOP)
find_qt(COMPONENTS Widgets)
find_qt(COMPONENTS Widgets)

if(ENABLE_BROWSER_PANELS OR ENABLE_BROWSER_QT_LOOP)
set_target_properties(
obs-browser
PROPERTIES AUTOMOC ON
Expand Down Expand Up @@ -251,6 +255,8 @@ if(ENABLE_BROWSER_PANELS)

target_compile_definitions(obs-browser-panels INTERFACE BROWSER_AVAILABLE)

target_sources(obs-browser PRIVATE obs-browser-api-impl-panel.cpp obs-browser-api-impl.cpp)

if(ENABLE_BROWSER_QT_LOOP)
target_compile_definitions(obs-browser-panels INTERFACE ENABLE_BROWSER_QT_LOOP)
endif()
Expand Down
24 changes: 24 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 3.22...3.25)

legacy_check()

find_package(Qt6 REQUIRED Widgets)

add_library(obs-browser-api INTERFACE)
add_library(OBS::browser-api ALIAS obs-browser-api)

target_sources(obs-browser-api PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/obs-browser-api.hpp>
$<INSTALL_INTERFACE:${OBS_INCLUDE_DESTINATION}/obs-browser-api.hpp>)

target_link_libraries(obs-browser-api INTERFACE OBS::libobs Qt::Widgets)

target_include_directories(obs-browser-api INTERFACE "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>"
"$<INSTALL_INTERFACE:${OBS_INCLUDE_DESTINATION}>")

set_target_properties(
obs-browser-api
PROPERTIES FOLDER browser
PREFIX ""
PUBLIC_HEADER obs-browser-api.hpp)

target_export(obs-browser-api)
22 changes: 22 additions & 0 deletions lib/cmake/legacy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
if(POLICY CMP0090)
cmake_policy(SET CMP0090 NEW)
endif()

project(obs-browser-api)

find_package(Qt6 REQUIRED Widgets)

add_library(obs-browser-api INTERFACE)
add_library(OBS::browser-api ALIAS obs-browser-api)

target_sources(obs-browser-api PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/obs-browser-api.hpp>
$<INSTALL_INTERFACE:${OBS_INCLUDE_DESTINATION}/obs-browser-api.hpp>)

target_link_libraries(obs-browser-api INTERFACE OBS::libobs Qt::Widgets)

target_include_directories(obs-browser-api INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${OBS_INCLUDE_DESTINATION}>)

set_target_properties(obs-browser-api PROPERTIES FOLDER "browser" PUBLIC_HEADER obs-browser-api.hpp)

export_target(obs-browser-api)
9 changes: 9 additions & 0 deletions lib/cmake/obs-browser-apiConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@PACKAGE_INIT@

include(CMakeFindDependencyMacro)

find_dependency(libobs REQUIRED)
find_package(Qt6 REQUIRED Widgets)

include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
check_required_components("@PROJECT_NAME@")
Loading

0 comments on commit f948be2

Please sign in to comment.