2021-04-26 15:46:11 +00:00
|
|
|
cmake_minimum_required(VERSION 3.16...3.20)
|
2021-03-08 11:56:43 +00:00
|
|
|
project(obs-websocket VERSION 5.0.0)
|
2021-04-27 21:52:48 +00:00
|
|
|
set(OBS_WEBSOCKET_RPC_VERSION 1)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
|
|
|
|
|
|
|
# Prohibit in-source builds
|
|
|
|
file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" _LOC_PATH)
|
|
|
|
if(EXISTS "${LOC_PATH}")
|
|
|
|
message(FATAL_ERROR "obs-websocket: You cannot build in a source directory (or any directory with "
|
|
|
|
"CMakeLists.txt file). Please make a build subdirectory. Feel free to "
|
|
|
|
"remove CMakeCache.txt and CMakeFiles.")
|
|
|
|
endif()
|
|
|
|
unset(_LOC_PATH)
|
|
|
|
|
|
|
|
|
|
|
|
# Allow selection of common build types via UI
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
|
|
|
"OBS build type [Release, RelWithDebInfo, Debug, MinSizeRel]" FORCE)
|
|
|
|
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Release RelWithDebInfo Debug MinSizeRel)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
|
|
|
# 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-04-26 15:46:11 +00:00
|
|
|
# Tell websocketpp not to use system boost
|
2021-03-08 11:56:43 +00:00
|
|
|
add_definitions(-DASIO_STANDALONE)
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
|
|
|
|
# Arm build fixes
|
2021-03-08 11:56:43 +00:00
|
|
|
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
2021-04-26 15:46:11 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "-mfpu=neon")
|
2021-03-08 11:56:43 +00:00
|
|
|
endif()
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
|
|
|
|
# Find libobs
|
2021-03-08 11:56:43 +00:00
|
|
|
if (WIN32 OR APPLE)
|
2021-04-26 15:46:11 +00:00
|
|
|
include(cmake/FindLibObs.cmake)
|
2021-03-08 11:56:43 +00:00
|
|
|
endif()
|
|
|
|
find_package(LibObs REQUIRED)
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
|
|
|
|
# Find Qt5
|
|
|
|
find_package(Qt5 REQUIRED COMPONENTS Core Widgets Concurrent)
|
|
|
|
|
|
|
|
|
2021-04-27 16:46:00 +00:00
|
|
|
# Find nlohmann
|
|
|
|
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
|
|
|
add_subdirectory(deps/json)
|
|
|
|
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# Configure files
|
|
|
|
configure_file(
|
|
|
|
src/plugin-macros.h.in
|
|
|
|
../src/plugin-macros.generated.h
|
|
|
|
)
|
|
|
|
configure_file(
|
|
|
|
installer/installer-windows.iss.in
|
|
|
|
../installer/installer-windows.generated.iss
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
# Inlude sources
|
2021-03-08 11:56:43 +00:00
|
|
|
set(obs-websocket_SOURCES
|
2021-04-27 02:59:50 +00:00
|
|
|
src/obs-websocket.cpp
|
2021-04-27 19:51:58 +00:00
|
|
|
src/Config.cpp
|
|
|
|
src/WebSocketServer.cpp
|
2021-04-27 21:52:48 +00:00
|
|
|
src/WebSocketSession.cpp
|
2021-04-27 19:51:58 +00:00
|
|
|
src/requesthandler/RequestHandler.cpp
|
|
|
|
src/requesthandler/rpc/Request.cpp
|
|
|
|
src/requesthandler/rpc/RequestResult.cpp
|
|
|
|
src/forms/SettingsDialog.cpp
|
|
|
|
src/utils/JsonUtils.cpp)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
|
|
|
set(obs-websocket_HEADERS
|
2021-04-27 02:59:50 +00:00
|
|
|
src/obs-websocket.h
|
2021-04-27 19:51:58 +00:00
|
|
|
src/Config.h
|
|
|
|
src/WebSocketServer.h
|
2021-04-27 21:52:48 +00:00
|
|
|
src/WebSocketSession.h
|
2021-04-27 19:51:58 +00:00
|
|
|
src/requesthandler/RequestHandler.h
|
|
|
|
src/requesthandler/rpc/Request.h
|
|
|
|
src/requesthandler/rpc/RequestResult.h
|
|
|
|
src/forms/SettingsDialog.h
|
2021-04-27 23:33:47 +00:00
|
|
|
src/utils/Utils.h)
|
2021-04-26 15:46:11 +00:00
|
|
|
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# Platform-independent build settings
|
2021-03-08 11:56:43 +00:00
|
|
|
add_library(obs-websocket MODULE
|
|
|
|
${obs-websocket_SOURCES}
|
|
|
|
${obs-websocket_HEADERS})
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
"${LIBOBS_INCLUDE_DIR}/../UI/obs-frontend-api"
|
|
|
|
${Qt5Core_INCLUDES}
|
|
|
|
${Qt5Widgets_INCLUDES}
|
2021-04-26 15:46:11 +00:00
|
|
|
${Qt5Concurrent_INCLUDES}
|
2021-03-08 11:56:43 +00:00
|
|
|
"${CMAKE_SOURCE_DIR}/deps/asio/asio/include"
|
|
|
|
"${CMAKE_SOURCE_DIR}/deps/websocketpp")
|
|
|
|
|
|
|
|
target_link_libraries(obs-websocket
|
|
|
|
libobs
|
|
|
|
Qt5::Core
|
2021-04-26 15:46:11 +00:00
|
|
|
Qt5::Widgets
|
2021-04-27 16:46:00 +00:00
|
|
|
Qt5::Concurrent
|
2021-04-27 19:51:58 +00:00
|
|
|
nlohmann_json::nlohmann_json)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# Windows-specific build settings and tasks
|
2021-03-08 11:56:43 +00:00
|
|
|
if(WIN32)
|
|
|
|
if(NOT DEFINED OBS_FRONTEND_LIB)
|
|
|
|
set(OBS_FRONTEND_LIB "OBS_FRONTEND_LIB-NOTFOUND" CACHE FILEPATH "OBS frontend library")
|
2021-04-26 15:46:11 +00:00
|
|
|
message(FATAL_ERROR "Could not find OBS Frontend API's library!")
|
2021-03-08 11:56:43 +00:00
|
|
|
endif()
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
if(MSVC)
|
|
|
|
# Enable Multicore Builds and disable FH4 (to not depend on VCRUNTIME140_1.DLL)
|
|
|
|
add_definitions(/MP /d2FH4-)
|
|
|
|
endif()
|
2021-03-08 11:56:43 +00:00
|
|
|
|
|
|
|
add_definitions(-D_WEBSOCKETPP_CPP11_STL_)
|
|
|
|
|
|
|
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
|
|
|
set(ARCH_NAME "64bit")
|
|
|
|
set(OBS_BUILDDIR_ARCH "build64")
|
|
|
|
else()
|
|
|
|
set(ARCH_NAME "32bit")
|
|
|
|
set(OBS_BUILDDIR_ARCH "build32")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
include_directories(
|
|
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/UI"
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(obs-websocket
|
|
|
|
"${OBS_FRONTEND_LIB}")
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# Release package helper
|
2021-03-08 11:56:43 +00:00
|
|
|
# The "release" folder has a structure similar OBS' one on Windows
|
|
|
|
set(RELEASE_DIR "${PROJECT_SOURCE_DIR}/release")
|
|
|
|
|
|
|
|
add_custom_command(TARGET obs-websocket POST_BUILD
|
2021-04-26 15:46:11 +00:00
|
|
|
# If config is Release or RelWithDebInfo, package release files
|
|
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
2021-03-08 11:56:43 +00:00
|
|
|
"${CMAKE_COMMAND}" -E make_directory
|
2021-04-26 15:46:11 +00:00
|
|
|
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
|
|
|
|
)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
|
|
|
"${CMAKE_COMMAND}" -E copy_directory
|
2021-03-08 11:56:43 +00:00
|
|
|
"${PROJECT_SOURCE_DIR}/data"
|
2021-04-26 15:46:11 +00:00
|
|
|
"${RELEASE_DIR}/data/obs-plugins/obs-websocket"
|
|
|
|
)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
|
|
|
"${CMAKE_COMMAND}" -E copy
|
2021-03-08 11:56:43 +00:00
|
|
|
"$<TARGET_FILE:obs-websocket>"
|
2021-04-26 15:46:11 +00:00
|
|
|
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
|
|
|
|
)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# In Release or RelWithDebInfo mode, copy Qt image format plugins
|
|
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
|
|
|
"${CMAKE_COMMAND}" -E make_directory
|
|
|
|
"${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats"
|
|
|
|
)
|
|
|
|
COMMAND if $<OR:$<CONFIG:Release>,$<CONFIG:RelWithDebInfo>>==1 (
|
2021-03-08 11:56:43 +00:00
|
|
|
"${CMAKE_COMMAND}" -E copy
|
2021-04-26 15:46:11 +00:00
|
|
|
"${QTDIR}/plugins/imageformats/qicns.dll"
|
|
|
|
"${QTDIR}/plugins/imageformats/qico.dll"
|
2021-03-08 11:56:43 +00:00
|
|
|
"${QTDIR}/plugins/imageformats/qjpeg.dll"
|
2021-04-26 15:46:11 +00:00
|
|
|
"${QTDIR}/plugins/imageformats/qtiff.dll"
|
|
|
|
"${QTDIR}/plugins/imageformats/qwbmp.dll"
|
|
|
|
"${QTDIR}/plugins/imageformats/qwebp.dll"
|
|
|
|
"${RELEASE_DIR}/bin/${ARCH_NAME}/imageformats"
|
|
|
|
)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# If config is RelWithDebInfo, package PDB file for target
|
2021-03-08 11:56:43 +00:00
|
|
|
COMMAND if $<CONFIG:RelWithDebInfo>==1 (
|
2021-04-26 15:46:11 +00:00
|
|
|
"${CMAKE_COMMAND}" -E copy
|
2021-03-08 11:56:43 +00:00
|
|
|
"$<TARGET_PDB_FILE:obs-websocket>"
|
2021-04-26 15:46:11 +00:00
|
|
|
"${RELEASE_DIR}/obs-plugins/${ARCH_NAME}"
|
|
|
|
)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# In the Debug configuration, copy to obs-studio dev environment for immediate testing
|
2021-03-08 11:56:43 +00:00
|
|
|
COMMAND if $<CONFIG:Debug>==1 (
|
|
|
|
"${CMAKE_COMMAND}" -E copy
|
|
|
|
"$<TARGET_FILE:obs-websocket>"
|
2021-04-26 15:46:11 +00:00
|
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${ARCH_NAME}"
|
|
|
|
)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
|
|
|
COMMAND if $<CONFIG:Debug>==1 (
|
|
|
|
"${CMAKE_COMMAND}" -E copy
|
2021-04-26 15:46:11 +00:00
|
|
|
"$<TARGET_PDB_FILE:obs-websocket>"
|
|
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/obs-plugins/${ARCH_NAME}"
|
|
|
|
)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
|
|
|
COMMAND if $<CONFIG:Debug>==1 (
|
|
|
|
"${CMAKE_COMMAND}" -E make_directory
|
2021-04-26 15:46:11 +00:00
|
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-websocket"
|
|
|
|
)
|
2021-03-08 11:56:43 +00:00
|
|
|
|
|
|
|
COMMAND if $<CONFIG:Debug>==1 (
|
|
|
|
"${CMAKE_COMMAND}" -E copy_directory
|
2021-04-26 15:46:11 +00:00
|
|
|
"${PROJECT_SOURCE_DIR}/data"
|
|
|
|
"${LIBOBS_INCLUDE_DIR}/../${OBS_BUILDDIR_ARCH}/rundir/$<CONFIG>/data/obs-plugins/obs-websocket"
|
|
|
|
)
|
2021-03-08 11:56:43 +00:00
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
|
|
|
|
# Linux-specific build settings and tasks
|
2021-03-08 11:56:43 +00:00
|
|
|
if(UNIX AND NOT APPLE)
|
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
set_target_properties(obs-websocket PROPERTIES PREFIX "")
|
|
|
|
target_link_libraries(obs-websocket obs-frontend-api)
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# Manually set permissions for locales
|
2021-03-08 11:56:43 +00:00
|
|
|
file(GLOB locale_files data/locale/*.ini)
|
2021-04-26 15:46:11 +00:00
|
|
|
set(CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS
|
2021-03-08 11:56:43 +00:00
|
|
|
OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# Manually set file permissions for binary
|
|
|
|
install(TARGETS obs-websocket LIBRARY
|
|
|
|
DESTINATION "${CMAKE_INSTALL_FULL_LIBDIR}/obs-plugins"
|
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
|
|
|
|
|
|
|
|
# OBS on Ubuntu installs into a different directory than most linux distros
|
2021-03-08 11:56:43 +00:00
|
|
|
if(${USE_UBUNTU_FIX})
|
|
|
|
install(TARGETS obs-websocket LIBRARY
|
|
|
|
DESTINATION "/usr/lib/obs-plugins"
|
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
install(FILES ${locale_files}
|
|
|
|
DESTINATION "${CMAKE_INSTALL_FULL_DATAROOTDIR}/obs/obs-plugins/obs-websocket/locale")
|
|
|
|
endif()
|
|
|
|
|
2021-04-26 15:46:11 +00:00
|
|
|
# MacOS-specific build settings and tasks
|
2021-03-08 11:56:43 +00:00
|
|
|
if(APPLE)
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -fvisibility=default")
|
|
|
|
|
|
|
|
set(CMAKE_SKIP_RPATH TRUE)
|
|
|
|
set_target_properties(obs-websocket PROPERTIES PREFIX "")
|
|
|
|
target_link_libraries(obs-websocket "${OBS_FRONTEND_LIB}")
|
|
|
|
endif()
|