Skip to content

Update to C++20#517

Open
hoshinolina wants to merge 1 commit into
obsproject:masterfrom
hoshinolina:c++20
Open

Update to C++20#517
hoshinolina wants to merge 1 commit into
obsproject:masterfrom
hoshinolina:c++20

Conversation

@hoshinolina

@hoshinolina hoshinolina commented Mar 7, 2026

Copy link
Copy Markdown
Contributor

Description

Current CEF requires compiling as C++20.

Motivation and Context

Fails to build with CEF 145.

How Has This Been Tested?

Tested as local build, testing in Fedora shortly.

Types of changes

  • Code cleanup (non-breaking change which makes code smaller or more readable)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@RytoEX
RytoEX requested review from PatTheMav and RytoEX May 4, 2026 16:19

@RytoEX RytoEX left a comment

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.

Fix the merge conflict caused by #518.

@RytoEX RytoEX left a comment

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.

Super nit, but looks fine otherwise.

Comment thread cmake/os-linux.cmake Outdated

@PatTheMav PatTheMav left a comment

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.

I'm on board with increasing the language level to C++20, however that change should affect all targets (and not just the Linux ones).

obs-browser is not a "standalone module" (I removed CMake code to that end IIRC) and thus should always inherit what the main project sets up as (via CMAKE_CXX_STANDARD).

And moving the project to C++20 is indeed in the works already, so the issue will be solved automatically through that.

@hoshinolina

Copy link
Copy Markdown
Contributor Author

FWIW this patch is needed to build OBS with current CEF today. I'm not a CMake nor C++ expert, but building just the browser bits as C++20 (which is what this PR does) seems to work fine (and this patch is what Fedora is shipping).

Current CEF requires compiling as C++20.

@WizardCM WizardCM left a comment

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.

I can confirm updating obs-browser (or parent) is required for CEF 145+ compatibility, and that this PR on its own works correctly on Linux and Windows.

Approving with the understanding that this change could either be merged via this PR, or via a PR to the obs-studio repository itself (per Pat's comment)

@out

out commented Jul 20, 2026

Copy link
Copy Markdown

This patch is also needed on macOS, but it misses the macOS helper targets.

I hit this building #523 against CEF 147 on macOS arm64. Bumping obs-browser alone isn't enough there: cmake/os-macos.cmake creates four separate helper executables (browser-helper, browser-helper_gpu, browser-helper_plugin, browser-helper_renderer) in a loop, and they compile browser-app.cpp / obs-browser-page-main.cpp — so they pull in the CEF headers too. They set no standard of their own, so they inherit obs-studio's global set(CMAKE_CXX_STANDARD 17) and fail:

In file included from cef/include/cef_base.h:42:
In file included from cef/include/internal/cef_ptr.h:37:
In file included from cef/include/base/cef_ref_counted.h:54:
cef/include/base/cef_scoped_refptr.h:101:16: error: no member named 'same_as' in namespace 'std'
  101 |   return !std::same_as<std::decay_t<decltype(GetRefCountPreference<T>())>,
      |                ^~~~~~~
cef/include/base/cef_scoped_refptr.h:127:22: error: no member named 'derived_from' in namespace 'std'
cef/include/base/cef_scoped_refptr.h:296:19: error: no template named 'convertible_to' in namespace 'std'

The equivalent of the os-linux.cmake change, inside the foreach(helper IN LISTS helper_suffixes) loop:

--- a/cmake/os-macos.cmake
+++ b/cmake/os-macos.cmake
   target_compile_definitions(${target_name} PRIVATE ENABLE_BROWSER_SHARED_TEXTURE)
+
+  target_compile_features(${target_name} PRIVATE cxx_std_20)

With that plus this PR's existing changes, obs-browser builds and runs on macOS against CEF 147 — browser sources render and Chrome Runtime initialises correctly.

For context on why the helpers need explicit opt-in: obs-studio's C++20 groundwork has already landed (obsproject/obs-studio#12630 and obsproject/obs-studio#13320), but cmake/common/compiler_common.cmake still sets CMAKE_CXX_STANDARD 17 globally — so per-target target_compile_features is currently the only thing raising the standard, and any target that doesn't ask for it silently stays on C++17.

One question I can't answer from here: cmake/os-windows.cmake defines obs-browser-helper as its own executable and likewise sets no standard, so it looks like it would need the same line. I have no Windows machine to verify that on, so I may be missing something that covers it there.

Environment

OS macOS 26.5.2, arm64
Toolchain Xcode 26.6 (17F113), Apple clang 21.0.0, CMake 4.1.2
CEF 147.0.14+g76d2442+chromium-147.0.7727.138 (macosarm64)
obs-studio 0218aa658

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants