Update to C++20 #517

Merged
hoshinolina merged 1 commit from c++20 into master 2026-08-20 13:38:02 -05:00
hoshinolina commented 2026-03-07 05:45:04 -06:00 (Migrated from github.com)

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.
### 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 <!--- What types of changes does your PR introduce? Uncomment all that apply --> <!--- - Bug fix (non-breaking change which fixes an issue) --> <!--- - New feature (non-breaking change which adds functionality) --> <!--- - Tweak (non-breaking change to improve existing functionality) --> <!--- - Performance enhancement (non-breaking change which improves efficiency) --> - Code cleanup (non-breaking change which makes code smaller or more readable) <!--- - Breaking change (fix or feature that would cause existing functionality to change) --> <!--- - Documentation (a change to documentation pages) --> ### Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [x] My code has been run through [clang-format](https://github.com/obsproject/obs-studio/blob/master/.clang-format). - [x] I have read the [**contributing** document](https://github.com/obsproject/obs-studio/blob/master/CONTRIBUTING.rst). - [x] My code is not on the master branch. - [x] The code has been tested. - [x] All commit messages are properly formatted and commits squashed where appropriate. - [ ] I have included updates to all appropriate documentation.
RytoEX (Migrated from github.com) requested changes 2026-05-04 11:20:11 -05:00
RytoEX (Migrated from github.com) left a comment

Fix the merge conflict caused by https://github.com/obsproject/obs-browser/pull/518.

Fix the merge conflict caused by https://github.com/obsproject/obs-browser/pull/518.
RytoEX (Migrated from github.com) requested changes 2026-05-05 10:17:29 -05:00
RytoEX (Migrated from github.com) left a comment

Super nit, but looks fine otherwise.

Super nit, but looks fine otherwise.
@ -19,6 +19,7 @@ target_sources(
target_include_directories(browser-helper PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/deps"
"${CMAKE_CURRENT_SOURCE_DIR}/obs-browser-page")
RytoEX (Migrated from github.com) commented 2026-05-05 10:16:50 -05:00

Super nit, but swap the order of these lines:

target_compile_features(browser-helper PRIVATE cxx_std_20)
target_link_libraries(browser-helper PRIVATE CEF::Wrapper CEF::Library)
Super nit, but swap the order of these lines: ```suggestion target_compile_features(browser-helper PRIVATE cxx_std_20) target_link_libraries(browser-helper PRIVATE CEF::Wrapper CEF::Library) ```
PatTheMav (Migrated from github.com) reviewed 2026-05-06 16:11:49 -05:00
PatTheMav (Migrated from github.com) left a comment

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.

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 commented 2026-05-07 04:31:31 -05:00 (Migrated from github.com)

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).

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).
WizardCM (Migrated from github.com) approved these changes 2026-05-22 20:31:05 -05:00
WizardCM (Migrated from github.com) left a comment

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)

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 commented 2026-07-19 20:51:08 -05:00 (Migrated from github.com)

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
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: ```diff --- 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` |
RytoEX (Migrated from github.com) approved these changes 2026-08-20 13:36:26 -05:00
RytoEX (Migrated from github.com) left a comment

I've added additional changes to get this to build with CEF 148/7778 on macOS and Windows. We're going to go with this until we can fully update obs-studio to C++20.

I've added additional changes to get this to build with CEF 148/7778 on macOS and Windows. We're going to go with this until we can fully update obs-studio to C++20.
Sign in to join this conversation.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-obsproject/obs-browser!517
No description provided.