2022-07-25 15:30:34 +00:00
|
|
|
project(obs-websocket VERSION 5.0.1)
|
2021-04-27 21:52:48 +00:00
|
|
|
set(OBS_WEBSOCKET_RPC_VERSION 1)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2022-05-14 03:23:03 +00:00
|
|
|
if(NOT ENABLE_UI)
|
|
|
|
message(STATUS "OBS: DISABLED obs-websocket")
|
|
|
|
return()
|
2021-04-26 15:46:11 +00:00
|
|
|
endif()
|
|
|
|
|
2021-12-15 10:06:31 +00:00
|
|
|
# Plugin tests flag
|
|
|
|
option(PLUGIN_TESTS "Enable plugin runtime tests" OFF)
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# Qt build stuff
|
2021-03-08 11:56:43 +00:00
|
|
|
set(CMAKE_PREFIX_PATH "${QTDIR}")
|
|
|
|
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
|
|
|
set(CMAKE_AUTOMOC ON)
|
|
|
|
set(CMAKE_AUTOUIC ON)
|
2021-06-06 06:06:36 +00:00
|
|
|
set(CMAKE_AUTORCC ON) # For resources.qrc
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
# Find Qt
|
2022-07-28 18:46:32 +00:00
|
|
|
if(NOT COMMAND find_qt)
|
2022-07-26 20:13:01 +00:00
|
|
|
if(NOT QT_VERSION)
|
|
|
|
set(QT_VERSION
|
|
|
|
AUTO
|
|
|
|
CACHE STRING "obs-websocket Qt version [AUTO, 5, 6]" FORCE)
|
|
|
|
set_property(CACHE QT_VERSION PROPERTY STRINGS AUTO 5 6)
|
|
|
|
endif()
|
2022-07-28 18:46:32 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
macro(find_qt)
|
2022-07-28 18:46:32 +00:00
|
|
|
set(multiValueArgs COMPONENTS COMPONENTS_WIN COMPONENTS_MAC
|
|
|
|
COMPONENTS_LINUX)
|
2022-07-26 20:13:01 +00:00
|
|
|
cmake_parse_arguments(FIND_QT "" "${oneValueArgs}" "${multiValueArgs}"
|
|
|
|
${ARGN})
|
|
|
|
set(QT_NO_CREATE_VERSIONLESS_TARGETS ON)
|
|
|
|
find_package(
|
|
|
|
Qt5
|
|
|
|
COMPONENTS Core
|
|
|
|
QUIET)
|
|
|
|
find_package(
|
|
|
|
Qt6
|
|
|
|
COMPONENTS Core
|
|
|
|
QUIET)
|
2022-07-28 18:46:32 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
if(NOT _QT_VERSION AND QT_VERSION STREQUAL AUTO)
|
|
|
|
if(TARGET Qt5::Core)
|
|
|
|
set(_QT_VERSION
|
|
|
|
5
|
|
|
|
CACHE INTERNAL "")
|
|
|
|
elseif(TARGET Qt6::Core)
|
|
|
|
set(_QT_VERSION
|
|
|
|
6
|
|
|
|
CACHE INTERNAL "")
|
|
|
|
endif()
|
|
|
|
elseif(NOT _QT_VERSION)
|
|
|
|
if(TARGET Qt${QT_VERSION}::Core)
|
|
|
|
set(_QT_VERSION
|
|
|
|
${QT_VERSION}
|
|
|
|
CACHE INTERNAL "")
|
|
|
|
else()
|
|
|
|
if(QT_VERSION EQUAL 6)
|
|
|
|
set(FALLBACK_QT_VERSION 5)
|
|
|
|
else()
|
|
|
|
set(FALLBACK_QT_VERSION 6)
|
|
|
|
endif()
|
|
|
|
message(
|
|
|
|
WARNING
|
|
|
|
"Qt${QT_VERSION} was not found, falling back to Qt${FALLBACK_QT_VERSION}"
|
|
|
|
)
|
2022-07-28 18:46:32 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
if(TARGET Qt${FALLBACK_QT_VERSION}::Core)
|
|
|
|
set(_QT_VERSION
|
|
|
|
${FALLBACK_QT_VERSION}
|
|
|
|
CACHE INTERNAL "")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
2022-07-28 18:46:32 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
set(QT_NO_CREATE_VERSIONLESS_TARGETS OFF)
|
2022-07-28 18:46:32 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
if(NOT _QT_VERSION)
|
|
|
|
message(FATAL_ERROR "Neither Qt5 or Qt6 were found")
|
|
|
|
endif()
|
2022-07-28 18:46:32 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
if(OS_WINDOWS)
|
|
|
|
find_package(
|
|
|
|
Qt${_QT_VERSION}
|
|
|
|
COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_WIN}
|
|
|
|
REQUIRED)
|
|
|
|
elseif(OS_MACOS)
|
|
|
|
find_package(
|
|
|
|
Qt${_QT_VERSION}
|
|
|
|
COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_MAC}
|
|
|
|
REQUIRED)
|
|
|
|
else()
|
|
|
|
find_package(
|
|
|
|
Qt${_QT_VERSION}
|
|
|
|
COMPONENTS ${FIND_QT_COMPONENTS} ${FIND_QT_COMPONENTS_LINUX}
|
|
|
|
REQUIRED)
|
|
|
|
endif()
|
2022-07-28 18:46:32 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
list(APPEND FIND_QT_COMPONENTS "Core")
|
2022-07-28 18:46:32 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
if("Gui" IN_LIST FIND_QT_COMPONENTS_LINUX)
|
|
|
|
list(APPEND FIND_QT_COMPONENTS_LINUX "GuiPrivate")
|
|
|
|
endif()
|
2022-07-28 18:46:32 +00:00
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
foreach(_COMPONENT IN LISTS FIND_QT_COMPONENTS FIND_QT_COMPONENTS_WIN
|
|
|
|
FIND_QT_COMPONENTS_MAC FIND_QT_COMPONENTS_LINUX)
|
2022-07-28 18:46:32 +00:00
|
|
|
if(NOT TARGET Qt::${_COMPONENT} AND TARGET
|
|
|
|
Qt${_QT_VERSION}::${_COMPONENT})
|
|
|
|
|
2022-07-26 20:13:01 +00:00
|
|
|
add_library(Qt::${_COMPONENT} INTERFACE IMPORTED)
|
|
|
|
set_target_properties(
|
|
|
|
Qt::${_COMPONENT} PROPERTIES INTERFACE_LINK_LIBRARIES
|
|
|
|
"Qt${_QT_VERSION}::${_COMPONENT}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endmacro()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_qt(COMPONENTS Core Widgets Svg Network)
|
2021-04-26 15:46:11 +00:00
|
|
|
|
2021-04-27 16:46:00 +00:00
|
|
|
# Find nlohmann
|
2022-07-25 14:48:06 +00:00
|
|
|
set(JSON_BuildTests
|
|
|
|
OFF
|
|
|
|
CACHE INTERNAL "")
|
2021-04-27 16:46:00 +00:00
|
|
|
add_subdirectory(deps/json)
|
|
|
|
|
2022-05-14 03:23:03 +00:00
|
|
|
# Tell websocketpp not to use system boost
|
|
|
|
add_definitions(-DASIO_STANDALONE)
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# Configure files
|
2022-07-25 14:48:06 +00:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-macros.h.in
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/plugin-macros.generated.h)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2022-05-14 03:23:03 +00:00
|
|
|
# Setup target
|
|
|
|
add_library(obs-websocket MODULE)
|
|
|
|
add_library(OBS::websocket ALIAS obs-websocket)
|
|
|
|
|
|
|
|
target_sources(
|
2022-07-25 14:48:06 +00:00
|
|
|
obs-websocket
|
|
|
|
PRIVATE src/obs-websocket.cpp
|
|
|
|
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
|
|
|
|
src/forms/ConnectInfo.h
|
|
|
|
src/forms/resources.qrc
|
|
|
|
src/WebSocketApi.cpp
|
|
|
|
src/WebSocketApi.h
|
|
|
|
src/websocketserver/WebSocketServer.cpp
|
|
|
|
src/websocketserver/WebSocketServer_Protocol.cpp
|
|
|
|
src/websocketserver/WebSocketServer.h
|
|
|
|
src/websocketserver/rpc/WebSocketSession.cpp
|
|
|
|
src/websocketserver/rpc/WebSocketSession.h
|
|
|
|
src/websocketserver/types/WebSocketCloseCode.h
|
|
|
|
src/websocketserver/types/WebSocketOpCode.h
|
|
|
|
src/eventhandler/EventHandler.cpp
|
|
|
|
src/eventhandler/EventHandler_General.cpp
|
|
|
|
src/eventhandler/EventHandler_Config.cpp
|
|
|
|
src/eventhandler/EventHandler_Scenes.cpp
|
|
|
|
src/eventhandler/EventHandler_Inputs.cpp
|
|
|
|
src/eventhandler/EventHandler_Transitions.cpp
|
|
|
|
src/eventhandler/EventHandler_Filters.cpp
|
|
|
|
src/eventhandler/EventHandler_Outputs.cpp
|
|
|
|
src/eventhandler/EventHandler_SceneItems.cpp
|
|
|
|
src/eventhandler/EventHandler_MediaInputs.cpp
|
|
|
|
src/eventhandler/EventHandler_Ui.cpp
|
|
|
|
src/eventhandler/EventHandler.h
|
|
|
|
src/eventhandler/types/EventSubscription.h
|
|
|
|
src/requesthandler/RequestHandler.cpp
|
|
|
|
src/requesthandler/RequestHandler_General.cpp
|
|
|
|
src/requesthandler/RequestHandler_Config.cpp
|
|
|
|
src/requesthandler/RequestHandler_Sources.cpp
|
|
|
|
src/requesthandler/RequestHandler_Scenes.cpp
|
|
|
|
src/requesthandler/RequestHandler_Inputs.cpp
|
|
|
|
src/requesthandler/RequestHandler_Transitions.cpp
|
|
|
|
src/requesthandler/RequestHandler_Filters.cpp
|
|
|
|
src/requesthandler/RequestHandler_SceneItems.cpp
|
|
|
|
src/requesthandler/RequestHandler_Outputs.cpp
|
|
|
|
src/requesthandler/RequestHandler_Stream.cpp
|
|
|
|
src/requesthandler/RequestHandler_Record.cpp
|
|
|
|
src/requesthandler/RequestHandler_MediaInputs.cpp
|
|
|
|
src/requesthandler/RequestHandler_Ui.cpp
|
|
|
|
src/requesthandler/RequestHandler.h
|
|
|
|
src/requesthandler/RequestBatchHandler.cpp
|
|
|
|
src/requesthandler/RequestBatchHandler.h
|
|
|
|
src/requesthandler/rpc/Request.cpp
|
|
|
|
src/requesthandler/rpc/Request.h
|
|
|
|
src/requesthandler/rpc/RequestBatchRequest.cpp
|
|
|
|
src/requesthandler/rpc/RequestBatchRequest.h
|
|
|
|
src/requesthandler/rpc/RequestResult.cpp
|
|
|
|
src/requesthandler/rpc/RequestResult.h
|
|
|
|
src/requesthandler/types/RequestStatus.h
|
|
|
|
src/requesthandler/types/RequestBatchExecutionType.h
|
|
|
|
src/utils/Crypto.cpp
|
|
|
|
src/utils/Crypto.h
|
|
|
|
src/utils/Json.cpp
|
|
|
|
src/utils/Json.h
|
|
|
|
src/utils/Obs.cpp
|
|
|
|
src/utils/Obs_StringHelper.cpp
|
|
|
|
src/utils/Obs_NumberHelper.cpp
|
|
|
|
src/utils/Obs_ArrayHelper.cpp
|
|
|
|
src/utils/Obs_ObjectHelper.cpp
|
|
|
|
src/utils/Obs_SearchHelper.cpp
|
|
|
|
src/utils/Obs_ActionHelper.cpp
|
|
|
|
src/utils/Obs.h
|
|
|
|
src/utils/Obs_VolumeMeter.cpp
|
|
|
|
src/utils/Obs_VolumeMeter.h
|
|
|
|
src/utils/Obs_VolumeMeter_Helpers.h
|
|
|
|
src/utils/Platform.cpp
|
|
|
|
src/utils/Platform.h
|
|
|
|
src/utils/Compat.cpp
|
|
|
|
src/utils/Compat.h
|
|
|
|
src/utils/Utils.h
|
|
|
|
deps/qr/cpp/QrCode.cpp
|
|
|
|
deps/qr/cpp/QrCode.hpp)
|
|
|
|
|
|
|
|
target_include_directories(
|
|
|
|
obs-websocket
|
|
|
|
PRIVATE ${Qt5Core_INCLUDES} ${Qt5Widgets_INCLUDES} ${Qt5Svg_INCLUDES}
|
|
|
|
${Qt5Network_INCLUDES} "deps/asio/asio/include" "deps/websocketpp")
|
|
|
|
|
|
|
|
target_link_libraries(
|
|
|
|
obs-websocket
|
|
|
|
PRIVATE OBS::libobs
|
|
|
|
OBS::frontend-api
|
2022-07-26 20:13:01 +00:00
|
|
|
Qt::Core
|
|
|
|
Qt::Widgets
|
|
|
|
Qt::Svg
|
|
|
|
Qt::Network
|
2022-07-25 14:48:06 +00:00
|
|
|
nlohmann_json::nlohmann_json)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2022-05-14 03:23:03 +00:00
|
|
|
target_compile_features(obs-websocket PRIVATE cxx_std_17)
|
|
|
|
|
|
|
|
set_target_properties(obs-websocket PROPERTIES FOLDER "plugins/obs-websocket")
|
|
|
|
|
2021-12-15 10:06:31 +00:00
|
|
|
if(PLUGIN_TESTS)
|
|
|
|
target_compile_definitions(obs-websocket PRIVATE PLUGIN_TESTS)
|
|
|
|
endif()
|
|
|
|
|
2022-05-14 03:23:03 +00:00
|
|
|
# Random other things
|
2021-03-08 11:56:43 +00:00
|
|
|
if(WIN32)
|
2022-07-25 14:48:06 +00:00
|
|
|
add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
|
2022-07-26 19:53:04 +00:00
|
|
|
target_compile_options(obs-websocket PRIVATE /wd4267)
|
2022-05-14 03:23:03 +00:00
|
|
|
elseif(UNIX AND NOT APPLE)
|
2022-07-25 14:48:06 +00:00
|
|
|
target_compile_options(
|
|
|
|
obs-websocket PRIVATE -Wall -Wextra -Wno-missing-field-initializers
|
2022-07-26 19:53:04 +00:00
|
|
|
-Wno-variadic-macros -Wno-error=format-overflow)
|
|
|
|
elseif(APPLE)
|
|
|
|
target_compile_options(
|
2022-07-28 18:46:32 +00:00
|
|
|
obs-websocket PRIVATE -Wno-error=null-pointer-subtraction
|
|
|
|
-Wno-error=deprecated-declarations)
|
2021-03-08 11:56:43 +00:00
|
|
|
endif()
|
|
|
|
|
2022-05-14 03:23:03 +00:00
|
|
|
# Final CMake helpers
|
|
|
|
setup_plugin_target(obs-websocket)
|
|
|
|
setup_target_resources(obs-websocket "obs-plugins/obs-websocket")
|