Update to C++20 #517
Labels
No labels
area/accessibility
area/dependency
Confirmed
Crash Report
Delayed
Design Issue
Duplicate
Feedback required
Good first issue
kind/bug
kind/cleanup
kind/enhancement
platform/linux
platform/macos
platform/windows
priority/high
Question
Request for Comments
Seeking Other Contributors
Seeking Testers
Won't Fix / By Design
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-obsproject/obs-browser!517
Loading…
Reference in a new issue
No description provided.
Delete branch "c++20"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
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
Checklist:
Fix the merge conflict caused by https://github.com/obsproject/obs-browser/pull/518.
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")Super nit, but swap the order of these lines:
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-browseris not a "standalone module" (I removed CMake code to that end IIRC) and thus should always inherit what the main project sets up as (viaCMAKE_CXX_STANDARD).And moving the project to C++20 is indeed in the works already, so the issue will be solved automatically through that.
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).
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)
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-browseralone isn't enough there:cmake/os-macos.cmakecreates four separate helper executables (browser-helper,browser-helper_gpu,browser-helper_plugin,browser-helper_renderer) in a loop, and they compilebrowser-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 globalset(CMAKE_CXX_STANDARD 17)and fail:The equivalent of the
os-linux.cmakechange, inside theforeach(helper IN LISTS helper_suffixes)loop: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.cmakestill setsCMAKE_CXX_STANDARD 17globally — so per-targettarget_compile_featuresis 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.cmakedefinesobs-browser-helperas 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
147.0.14+g76d2442+chromium-147.0.7727.138(macosarm64)0218aa658I'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.