diff --git a/CMakeLists.txt b/CMakeLists.txt index 63b1c9d5..56c837a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ legacy_check() set(obs-websocket_VERSION 5.3.5) set(OBS_WEBSOCKET_RPC_VERSION 1) +add_subdirectory(lib) + option(ENABLE_WEBSOCKET "Enable building OBS with websocket plugin" ON) if(NOT ENABLE_WEBSOCKET) target_disable(obs-websocket) @@ -34,7 +36,6 @@ add_library(OBS::websocket ALIAS obs-websocket) target_sources( obs-websocket PRIVATE # cmake-format: sortable - lib/obs-websocket-api.h src/Config.cpp src/Config.h src/forms/ConnectInfo.cpp @@ -154,6 +155,7 @@ target_link_libraries( obs-websocket PRIVATE OBS::libobs OBS::frontend-api + OBS::websocket-api Qt::Core Qt::Widgets Qt::Svg diff --git a/cmake/legacy.cmake b/cmake/legacy.cmake index 3ee54a20..282913af 100644 --- a/cmake/legacy.cmake +++ b/cmake/legacy.cmake @@ -3,6 +3,8 @@ set(OBS_WEBSOCKET_RPC_VERSION 1) option(ENABLE_WEBSOCKET "Enable building OBS with websocket plugin" ON) +add_subdirectory(lib) + if(NOT ENABLE_WEBSOCKET OR NOT ENABLE_UI) message(STATUS "OBS: DISABLED obs-websocket") return() @@ -56,7 +58,6 @@ target_sources( src/obs-websocket.h src/Config.cpp src/Config.h - lib/obs-websocket-api.h src/forms/SettingsDialog.cpp src/forms/SettingsDialog.h src/forms/ConnectInfo.cpp @@ -133,6 +134,7 @@ target_link_libraries( obs-websocket PRIVATE OBS::libobs OBS::frontend-api + OBS::websocket-api Qt::Core Qt::Widgets Qt::Svg diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 00000000..a094fa54 --- /dev/null +++ b/lib/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.22...3.25) + +legacy_check() + +add_library(obs-websocket-api INTERFACE) +add_library(OBS::websocket-api ALIAS obs-websocket-api) + +target_sources(obs-websocket-api INTERFACE $ + $) + +target_link_libraries(obs-websocket-api INTERFACE OBS::libobs) + +target_include_directories(obs-websocket-api INTERFACE "$" + "$") + +set_target_properties( + obs-websocket-api + PROPERTIES FOLDER websocket + PREFIX "" + PUBLIC_HEADER obs-websocket-api.h) + +target_export(obs-websocket-api) diff --git a/lib/cmake/legacy.cmake b/lib/cmake/legacy.cmake new file mode 100644 index 00000000..62d60793 --- /dev/null +++ b/lib/cmake/legacy.cmake @@ -0,0 +1,20 @@ +if(POLICY CMP0090) + cmake_policy(SET CMP0090 NEW) +endif() + +project(obs-websocket-api) + +add_library(obs-websocket-api INTERFACE) +add_library(OBS::websocket-api ALIAS obs-websocket-api) + +target_sources(obs-websocket-api INTERFACE $ + $) + +target_link_libraries(obs-websocket-api INTERFACE OBS::libobs) + +target_include_directories(obs-websocket-api INTERFACE $ + $) + +set_target_properties(obs-websocket-api PROPERTIES FOLDER "websocket" PUBLIC_HEADER obs-websocket-api.h) + +export_target(obs-websocket-api) diff --git a/lib/cmake/obs-websocket-apiConfig.cmake.in b/lib/cmake/obs-websocket-apiConfig.cmake.in new file mode 100644 index 00000000..fcc2f62a --- /dev/null +++ b/lib/cmake/obs-websocket-apiConfig.cmake.in @@ -0,0 +1,8 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +find_dependency(libobs REQUIRED) + +include("${CMAKE_CURRENT_LIST_DIR}/@TARGETS_EXPORT_NAME@.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/src/WebSocketApi.h b/src/WebSocketApi.h index cb8b9816..35d9ecd5 100644 --- a/src/WebSocketApi.h +++ b/src/WebSocketApi.h @@ -24,8 +24,7 @@ with this program. If not, see #include #include #include - -#include "../lib/obs-websocket-api.h" +#include class WebSocketApi { public: