Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,8 @@
"ENABLE_AJA": false,
"ENABLE_VLC": true,
"ENABLE_WAYLAND": true,
"ENABLE_WEBRTC": false
"ENABLE_WEBRTC": false,
"ENABLE_FLATPAK": false
Comment on lines -142 to +143

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value should be default-initialised to FALSE inside CMake (otherwise the variable is unintialized for other platforms - see also my recent PR with CMake updates that also addresses uninitialised variable errors).

Conceptually nothing outside of the Flatpak manifest should "know", be concerned, or in any other way interact with this configuration value.

}
},
{
Expand Down
34 changes: 8 additions & 26 deletions build-aux/com.obsproject.Studio.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"runtime": "org.freedesktop.Platform",
"runtime-version": "25.08",
"sdk": "org.freedesktop.Sdk",
"branch": "test",
"separate-locales": false,
"build-options": {
"no-debuginfo": true
},
Comment on lines +6 to +10

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are those changes supposed to be made to the actual Flatpak manifest? This looks like a temporary test setup to me..

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides two specific line change (merge-dirs and in config-opts), nothing else you end up being commited in this file.

"command": "obs",
"finish-args": [
"--socket=wayland",
Expand All @@ -24,7 +29,7 @@
"directory": "plugins",
"subdirectories": true,
"add-ld-path": "lib",
"merge-dirs": "lib/obs-plugins;share/obs/obs-plugins",
"merge-dirs": "lib/obs-modules/plugins;share/obs/obs-modules/plugins;lib/obs-plugins;share/obs/obs-plugins",
"no-autodownload": true,
"autodelete": true
},
Expand Down Expand Up @@ -101,38 +106,15 @@
}
]
},
{
"name": "cef",
"build-options": {
"no-debuginfo": true
},
"buildsystem": "simple",
"build-commands": [
"mkdir -p /app/cef/libcef_dll_wrapper",
"cp -R ./include /app/cef",
"cp -R ./Release /app/cef",
"cp -R ./Resources /app/cef",
"cp -R ./build/libcef_dll_wrapper/libcef_dll_wrapper.a /app/cef/libcef_dll_wrapper"
],
"cleanup": [
"*"
],
"sources": [
{
"type": "archive",
"url": "https://cdn-fastly.obsproject.com/downloads/cef_binary_6533_linux_x86_64_v6.tar.xz",
"sha256": "7963335519a19ccdc5233f7334c5ab023026e2f3e9a0cc417007c09d86608146"
}
]
},
{
"name": "obs",
"buildsystem": "cmake-ninja",
"builddir": true,
"config-opts": [
"-DCMAKE_BUILD_TYPE=RelWithDebInfo",
"-DENABLE_FLATPAK=ON",
"-DENABLE_WAYLAND=ON",
"-DENABLE_BROWSER=ON",
"-DENABLE_BROWSER=OFF",
"-DCEF_ROOT_DIR=/app/cef",
"-DENABLE_ALSA=OFF",
"-DENABLE_PULSEAUDIO=ON",
Expand Down
48 changes: 43 additions & 5 deletions cmake/common/helpers_common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function(message_configuration)
endforeach()
endif()

if(ENABLE_PLUGINS)
if(ENABLE_CORE_MODULES)
get_property(OBS_MODULES_ENABLED GLOBAL PROPERTY OBS_MODULES_ENABLED)
list(SORT OBS_MODULES_ENABLED COMPARE NATURAL CASE SENSITIVE ORDER ASCENDING)

Expand Down Expand Up @@ -82,6 +82,11 @@ function(target_disable_feature target feature_description)
endif()
endfunction()

# target_enable: Adds target to list of enabled modules
function(target_enable target)
set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target})
endfunction()

# target_disable: Adds target to list of disabled modules
function(target_disable target)
set_property(GLOBAL APPEND PROPERTY OBS_MODULES_DISABLED ${target})
Expand Down Expand Up @@ -451,13 +456,17 @@ function(check_uuid uuid_string return_value)
return(PROPAGATE ${return_value})
endfunction()

# add_obs_plugin: Add plugin subdirectory if host platform is in specified list of supported platforms and architectures
function(add_obs_plugin target)
# add_core_module: Add module subdirectory if host platform is in specified list of supported platforms and architectures
function(add_core_module target)
set(options WITH_MESSAGE)
set(oneValueArgs "")
set(multiValueArgs PLATFORMS ARCHITECTURES)
cmake_parse_arguments(PARSE_ARGV 0 _AOP "${options}" "${oneValueArgs}" "${multiValueArgs}")

if(NOT TARGET libobs)
message(FATAL_ERROR "Cannot add libobs core module without existing 'libobs' target")
endif()

set(found_platform FALSE)
list(LENGTH _AOP_PLATFORMS _AOP_NUM_PLATFORMS)

Expand Down Expand Up @@ -499,8 +508,37 @@ function(add_obs_plugin target)

if(found_platform AND found_architecture)
add_subdirectory(${target})
elseif(_AOP_WITH_MESSAGE)
add_custom_target(${target} COMMENT "Dummy target for unavailable module ${target}")
endif()

if(TARGET ${target})
target_enable(${target})
else()
if(_AOP_WITH_MESSAGE)
add_custom_target(${target} COMMENT "Dummy target for unavailable module ${target}")
endif()
target_disable(${target})
endif()
endfunction()

function(set_obs_core_modules)
if(NOT TARGET libobs OR NOT TARGET libobs-core-modules)
message(FATAL_ERROR "Unable to set up OBS Core Modules without 'libobs' target")
endif()

# get_target_property(core_modules_list libobs CORE_MODULE_TARGETS)
get_property(OBS_MODULES_ENABLED GLOBAL PROPERTY OBS_MODULES_ENABLED)
get_target_property(libobs_source_directory libobs SOURCE_DIR)
get_target_property(libobs_binary_directory libobs BINARY_DIR)

list(LENGTH OBS_MODULES_ENABLED core_modules_count)
string(REPLACE ";" "\",\n\t\"" core_modules_array_content "${OBS_MODULES_ENABLED}")

set(OBS_CORE_MODULE_COUNT "${core_modules_count}")
set(OBS_CORE_MODULE_LIST "\t\"${core_modules_array_content}\"")

configure_file(
"${libobs_source_directory}/obs-core-modules.c.in"
"${libobs_binary_directory}/obs-core-modules.c"
@ONLY
)
endfunction()
9 changes: 9 additions & 0 deletions cmake/common/osconfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,13 @@ elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD|OpenBSD")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux")
string(TOUPPER "${CMAKE_HOST_SYSTEM_NAME}" _SYSTEM_NAME_U)
set(OS_${_SYSTEM_NAME_U} TRUE)

option(ENABLE_FLATPAK "Enable Flatpak-specific implementations." OFF)
mark_as_advanced(ENABLE_FLATPAK)
Comment on lines +21 to +22

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not 100% sold on using ENABLE_ for naming that option but it's not a major issue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW I'm fine with giving it a different name, it's just what I came up with to present how/where that variable comes into play in the build setup.


if(OS_LINUX AND ENABLE_FLATPAK)
set(OS_FLATPAK TRUE)
else()
set(OS_FLATPAK FALSE)
endif()
endif()
4 changes: 2 additions & 2 deletions cmake/linux/defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ set(OBS_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/rundir")
set(OBS_EXECUTABLE_DESTINATION "${CMAKE_INSTALL_BINDIR}")
set(OBS_INCLUDE_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/obs")
set(OBS_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}")
set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins")
set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-modules")
set(OBS_SCRIPT_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-scripting")
set(OBS_DATA_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/obs")
set(OBS_CMAKE_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake")

# Set additional paths used by OBS for self-discovery
set(OBS_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-plugins")
set(OBS_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-modules/core")
set(OBS_SCRIPT_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-scripting")
set(OBS_DATA_PATH "${OBS_DATA_DESTINATION}")
set(OBS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
Expand Down
35 changes: 19 additions & 16 deletions cmake/linux/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ function(set_target_properties_obs target)
set(OBS_SOVERSION 30)

if(target_type STREQUAL EXECUTABLE)
if(target STREQUAL browser-helper)
set(OBS_EXECUTABLE_DESTINATION "${OBS_PLUGIN_DESTINATION}/core")
endif()

install(TARGETS ${target} RUNTIME DESTINATION "${OBS_EXECUTABLE_DESTINATION}" COMPONENT Runtime)

add_custom_command(
Expand Down Expand Up @@ -124,7 +128,7 @@ function(set_target_properties_obs target)
set(plugin_destination "${OBS_SCRIPT_PLUGIN_DESTINATION}")
set_property(TARGET ${target} PROPERTY INSTALL_RPATH "$ORIGIN/;$ORIGIN/..")
else()
set(plugin_destination "${OBS_PLUGIN_DESTINATION}")
set(plugin_destination "${OBS_PLUGIN_DESTINATION}/core")
endif()

install(
Expand Down Expand Up @@ -170,20 +174,21 @@ function(set_target_properties_obs target)
add_custom_command(
TARGET ${target}
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/"
COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/core"
COMMAND
"${CMAKE_COMMAND}" -E copy_if_different "${imported_location}" "${cef_location}/chrome-sandbox"
"${cef_location}/libEGL.so" "${cef_location}/libGLESv2.so" "${cef_location}/libvk_swiftshader.so"
"${cef_location}/libvulkan.so.1" "${cef_location}/v8_context_snapshot.bin"
"${cef_location}/vk_swiftshader_icd.json" "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/"
"${cef_location}/vk_swiftshader_icd.json" "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/core"
COMMAND
"${CMAKE_COMMAND}" -E copy_if_different "${cef_root_location}/Resources/chrome_100_percent.pak"
"${cef_root_location}/Resources/chrome_200_percent.pak" "${cef_root_location}/Resources/icudtl.dat"
"${cef_root_location}/Resources/resources.pak" "${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/"
"${cef_root_location}/Resources/resources.pak"
"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/core"
COMMAND
"${CMAKE_COMMAND}" -E copy_directory "${cef_root_location}/Resources/locales"
"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/locales"
COMMENT "Add Chromium Embedded Framework to library directory"
"${OBS_OUTPUT_DIR}/$<CONFIG>/${OBS_PLUGIN_DESTINATION}/core/locales"
COMMENT "Add Chromium Embedded Framwork to library directory"
)

install(
Expand All @@ -200,21 +205,19 @@ function(set_target_properties_obs target)
"${cef_root_location}/Resources/chrome_200_percent.pak"
"${cef_root_location}/Resources/icudtl.dat"
"${cef_root_location}/Resources/resources.pak"
DESTINATION "${OBS_PLUGIN_DESTINATION}"
DESTINATION "${OBS_PLUGIN_DESTINATION}/core"
COMPONENT Runtime
)

install(
DIRECTORY "${cef_root_location}/Resources/locales"
DESTINATION "${OBS_PLUGIN_DESTINATION}"
DESTINATION "${OBS_PLUGIN_DESTINATION}/core"
USE_SOURCE_PERMISSIONS
COMPONENT Runtime
)
endif()
endif()
endif()

set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target})
endif()

target_install_resources(${target})
Expand All @@ -236,9 +239,9 @@ function(target_install_resources target)
source_group("Resources/${relative_path}" FILES "${data_file}")
endforeach()

get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
if(target IN_LIST obs_module_list)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}")
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL MODULE_LIBRARY)
set(target_destination "${OBS_DATA_DESTINATION}/obs-modules/core/${target}")
elseif(target STREQUAL obs)
set(target_destination "${OBS_DATA_DESTINATION}/obs-studio")
else()
Expand Down Expand Up @@ -267,11 +270,11 @@ endfunction()

# Helper function to add a specific resource to a bundle
function(target_add_resource target resource)
get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
get_target_property(target_type ${target} TYPE)
if(ARGN)
set(target_destination "${ARGN}")
elseif(${target} IN_LIST obs_module_list)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}")
elseif(target_type STREQUAL MODULE_LIBRARY)
set(target_destination "${OBS_DATA_DESTINATION}/obs-modules/core/${target}")
elseif(target STREQUAL obs)
set(target_destination "${OBS_DATA_DESTINATION}/obs-studio")
else()
Expand Down
1 change: 0 additions & 1 deletion cmake/macos/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ function(set_target_properties_obs target)
endif()
endif()

set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target})
set_property(GLOBAL APPEND PROPERTY _OBS_DEPENDENCIES ${target})
endif()

Expand Down
4 changes: 2 additions & 2 deletions cmake/windows/defaults.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include_guard(GLOBAL)
set(OBS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(OBS_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/rundir")

set(OBS_PLUGIN_DESTINATION obs-plugins/64bit)
set(OBS_PLUGIN_DESTINATION core)
set(OBS_DATA_DESTINATION data)
set(OBS_CMAKE_DESTINATION cmake)
set(OBS_SCRIPT_PLUGIN_DESTINATION "${OBS_DATA_DESTINATION}/obs-scripting/64bit")
Expand All @@ -14,7 +14,7 @@ set(OBS_EXECUTABLE_DESTINATION bin/64bit)
set(OBS_LIBRARY_DESTINATION lib)
set(OBS_INCLUDE_DESTINATION include)
# Set relative paths used by OBS for self-discovery
set(OBS_PLUGIN_PATH "../../${CMAKE_INSTALL_LIBDIR}/obs-plugins/64bit")
set(OBS_PLUGIN_PATH "../../${CMAKE_INSTALL_LIBDIR}/core")
set(OBS_SCRIPT_PLUGIN_PATH "../../${OBS_DATA_DESTINATION}/obs-scripting/64bit")
set(OBS_DATA_PATH "../../${OBS_DATA_DESTINATION}")

Expand Down
26 changes: 12 additions & 14 deletions cmake/windows/helpers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ function(set_target_properties_obs target)

if(target_type STREQUAL EXECUTABLE)
if(target STREQUAL obs-browser-helper)
set(OBS_EXECUTABLE_DESTINATION "${OBS_PLUGIN_DESTINATION}")
set(OBS_EXECUTABLE_DESTINATION "${OBS_PLUGIN_DESTINATION}/obs-browser")
elseif(target STREQUAL inject-helper OR target STREQUAL get-graphics-offsets)
set(OBS_EXECUTABLE_DESTINATION "${OBS_DATA_DESTINATION}/obs-plugins/win-capture")
set(OBS_EXECUTABLE_DESTINATION "${OBS_PLUGIN_DESTINATION}/win-capture/data")

_target_install_obs(${target} DESTINATION ${OBS_EXECUTABLE_DESTINATION} x86)

Expand Down Expand Up @@ -66,7 +66,7 @@ function(set_target_properties_obs target)
elseif(target STREQUAL "obspython" OR target STREQUAL "obslua")
set(target_destination "${OBS_SCRIPT_PLUGIN_DESTINATION}")
elseif(target STREQUAL graphics-hook)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/win-capture")
set(target_destination "${OBS_PLUGIN_DESTINATION}/win-capture/data")
target_add_resource(graphics-hook "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan64.json" "${target_destination}")
target_add_resource(graphics-hook "${CMAKE_CURRENT_SOURCE_DIR}/obs-vulkan32.json" "${target_destination}")

Expand All @@ -76,15 +76,15 @@ function(set_target_properties_obs target)
_target_install_obs(${target} DESTINATION ${target_destination} x64)
endif()
elseif(target STREQUAL obs-virtualcam-module)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/win-dshow")
set(target_destination "${OBS_PLUGIN_DESTINATION}/win-dshow/data")

_target_install_obs(${target} DESTINATION ${target_destination} x86)

if(CMAKE_VS_PLATFORM_NAME STREQUAL ARM64)
_target_install_obs(${target} DESTINATION ${target_destination} x64)
endif()
else()
set(target_destination "${OBS_PLUGIN_DESTINATION}")
set(target_destination "${OBS_PLUGIN_DESTINATION}/${target}")
endif()

_target_install_obs(${target} DESTINATION ${target_destination})
Expand Down Expand Up @@ -157,8 +157,6 @@ function(set_target_properties_obs target)
endif()
endif()
endif()

set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target})
endif()

target_link_options(${target} PRIVATE "/PDBALTPATH:$<TARGET_PDB_FILE_NAME:${target}>")
Expand Down Expand Up @@ -314,9 +312,9 @@ function(target_install_resources target)
source_group("Resources/${relative_path}" FILES "${data_file}")
endforeach()

get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
if(target IN_LIST obs_module_list)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}")
get_target_property(target_type ${target} TYPE)
if(target_type STREQUAL MODULE_LIBRARY)
set(target_destination "${OBS_PLUGIN_DESTINATION}/${target}/data")
elseif(target STREQUAL obs-studio)
set(target_destination "${OBS_DATA_DESTINATION}/obs-studio")
else()
Expand Down Expand Up @@ -346,11 +344,11 @@ endfunction()

# Helper function to add a specific resource to a bundle
function(target_add_resource target resource)
get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED)
get_target_property(target_type ${target} TYPE)
if(ARGN)
set(target_destination "${ARGN}")
elseif(${target} IN_LIST obs_module_list)
set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}")
elseif(target_type STREQUAL MODULE_LIBRARY)
set(target_destination "${OBS_PLUGIN_DESTINATION}/${target}/data")
elseif(target STREQUAL obs-studio)
set(target_destination "${OBS_DATA_DESTINATION}/obs-studio")
else()
Expand Down Expand Up @@ -397,7 +395,7 @@ function(_bundle_dependencies target)
set(plugins_list)

foreach(library IN LISTS found_dependencies)
# CEF needs to be placed in obs-plugins directory on Windows, which is handled already
# CEF needs to be placed in core directory on Windows, which is handled already
if(${library} STREQUAL CEF::Library)
continue()
endif()
Expand Down
Loading
Loading