Update build configuration to C++20 (see #3611)

This commit is contained in:
Marshall Greenblatt committed 2025-12-31 18:22:24 -05:00
1 parent deed57f604
commit 3ada818751
6 files changed
+20 -20

No files matched your search

+6 -6
View File
@@ -17,10 +17,10 @@
#
# > set GN_DEFINES=is_official_build=true
#
# Example B: Generate VS2017 project files in addition to the default Ninja
# Example B: Generate VS2022 project files in addition to the default Ninja
# build files on Windows:
#
# > set GN_ARGUMENTS=--ide=vs2017 --sln=cef --filters=//cef/*
# > set GN_ARGUMENTS=--ide=vs2022 --sln=cef --filters=//cef/*
#
# After completing the "GN Automated Build" or "GN Manual Build" section
# open "out\<build_dir>\cef.sln" for editing and debugging. Building must
@@ -1232,15 +1232,15 @@ config("libcef_dll_wrapper_config") {
# avoid accidental usage of new/unsupported language features in sample apps.
# For Chromium defaults see //build/config/compiler/BUILD.gn.
#
# Mixing C++17 and C++20 leads to build errors with modules enabled. Dependent
# Mixing C++20 and C++23 leads to build errors with modules enabled. Dependent
# targets must therefore also set use_libcxx_modules = false (see issue #3611).
if (is_win) {
cflags_cc = [ "/std:c++17" ]
cflags_cc = [ "/std:c++20" ]
} else {
cflags_cc = [ "-std=c++17" ]
cflags_cc = [ "-std=c++20" ]
}
if (is_mac) {
cflags_objcc = [ "-std=c++17" ]
cflags_objcc = [ "-std=c++20" ]
}
if (cef_api_version != "") {
+4 -4
View File
@@ -62,24 +62,24 @@ def declare_cc_library(copts=[], local_defines=[], **kwargs):
**kwargs
)
def declare_objc_library(copts=[], enable_cxx17=True, **kwargs):
def declare_objc_library(copts=[], enable_cxx20=True, **kwargs):
"""
objc_library wrapper that applies common copts.
Args:
copts: Additional compiler options to add.
enable_cxx17: If True (default), adds -std=c++17 for Objective-C++ (.mm) files.
enable_cxx20: If True (default), adds -std=c++20 for Objective-C++ (.mm) files.
Set to False for pure Objective-C (.m) files that should not use C++ standard.
**kwargs: Additional arguments passed to objc_library.
"""
# NOTE: objc_library does not support local_defines on MacOS, so on
# that platform we put the defines in copts instead.
# Add C++17 standard for Objective-C++ files on macOS (default behavior)
# Add C++20 standard for Objective-C++ files on macOS (default behavior)
# This allows .mm files to properly parse C++ headers while allowing
# pure .m files to opt out when needed.
cxx_standard = select({
"@platforms//os:macos": ["-std=c++17"] if enable_cxx17 else [],
"@platforms//os:macos": ["-std=c++20"] if enable_cxx20 else [],
"//conditions:default": [],
})
+3 -3
View File
@@ -115,7 +115,7 @@ if(OS_LINUX)
-fno-rtti # Disable real-time type information
-fno-threadsafe-statics # Don't generate thread-safe statics
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
-std=c++17 # Use the C++17 language standard
-std=c++20 # Use the C++20 language standard
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
)
list(APPEND CEF_COMPILER_FLAGS_DEBUG
@@ -287,7 +287,7 @@ if(OS_MAC)
-fno-threadsafe-statics # Don't generate thread-safe statics
-fobjc-call-cxx-cdtors # Call the constructor/destructor of C++ instance variables in ObjC objects
-fvisibility-inlines-hidden # Give hidden visibility to inlined class member functions
-std=c++17 # Use the C++17 language standard
-std=c++20 # Use the C++20 language standard
-Wno-narrowing # Don't warn about type narrowing
-Wsign-compare # Warn about mixed signed/unsigned type comparisons
)
@@ -427,7 +427,7 @@ if(OS_WINDOWS)
/GF # Enable string pooling
)
list(APPEND CEF_CXX_COMPILER_FLAGS
/std:c++17 # Use the C++17 language standard
/std:c++20 # Use the C++20 language standard
)
list(APPEND CEF_LINKER_FLAGS_DEBUG
/DEBUG # Generate debug information
+1 -1
View File
@@ -67,7 +67,7 @@ if(OS_WINDOWS)
# Remove C++ standard flag since this is a C-only target.
# The Visual Studio generator sets both <LanguageStandard> and <LanguageStandard_C>
# properties, and <LanguageStandard> takes precedence when compiling C files.
list(REMOVE_ITEM CEF_CXX_COMPILER_FLAGS "/std:c++17")
list(REMOVE_ITEM CEF_CXX_COMPILER_FLAGS "/std:c++20")
endif()
+5 -5
View File
@@ -12,11 +12,11 @@ build --enable_platform_specific_config
# Common configuration.
#
# Build with C++17.
# See also the enable_cxx17 argument to declare_objc_library()
build:linux --cxxopt='-std=c++17'
build:macos --cxxopt='-std=c++17'
build:windows --cxxopt='/std:c++17'
# Build with C++20.
# See also the enable_cxx20 argument to declare_objc_library()
build:linux --cxxopt='-std=c++20'
build:macos --cxxopt='-std=c++20'
build:windows --cxxopt='/std:c++20'
#
# Windows configuration.
@@ -60,7 +60,7 @@ declare_cc_library(
declare_objc_library(
name = "BrowserLibMac_ObjC",
srcs = srcs_browser_mac, # .m files
enable_cxx17 = False, # Pure Objective-C, not Objective-C++
enable_cxx20 = False, # Pure Objective-C, not Objective-C++
target_compatible_with = [
"@platforms//os:macos",
],