You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
SCons: Explicitly define our C (C11) and C++ (C++14) standards
On GCC and Clang, we use C11 and C++14 with GNU extensions (`std=gnu11`
and `std=gnu++14`). Those are the defaults for current GCC and Clang,
and also match the feature sets we want to use in Godot.
On MSVC, we require C++14 support explicitly with `/std:c++14`, and
make it strict with the use of `/permissive-` (so features of C++17 or
later can't be used).
Moves the definition before querying environment flags and platform
config so that it can be overridden when necessary.
(cherry picked from commit 342f127362)
This commit is contained in:
18
SConstruct
18
SConstruct
@@ -291,6 +291,7 @@ if selected_platform in platform_list:
|
|||||||
if env["extra_suffix"] != '':
|
if env["extra_suffix"] != '':
|
||||||
env.extra_suffix += '.' + env["extra_suffix"]
|
env.extra_suffix += '.' + env["extra_suffix"]
|
||||||
|
|
||||||
|
# Environment flags
|
||||||
CCFLAGS = env.get('CCFLAGS', '')
|
CCFLAGS = env.get('CCFLAGS', '')
|
||||||
env['CCFLAGS'] = ''
|
env['CCFLAGS'] = ''
|
||||||
env.Append(CCFLAGS=str(CCFLAGS).split())
|
env.Append(CCFLAGS=str(CCFLAGS).split())
|
||||||
@@ -307,17 +308,28 @@ if selected_platform in platform_list:
|
|||||||
env['LINKFLAGS'] = ''
|
env['LINKFLAGS'] = ''
|
||||||
env.Append(LINKFLAGS=str(LINKFLAGS).split())
|
env.Append(LINKFLAGS=str(LINKFLAGS).split())
|
||||||
|
|
||||||
|
# Platform specific flags
|
||||||
flag_list = platform_flags[selected_platform]
|
flag_list = platform_flags[selected_platform]
|
||||||
for f in flag_list:
|
for f in flag_list:
|
||||||
if not (f[0] in ARGUMENTS): # allow command line to override platform flags
|
if not (f[0] in ARGUMENTS): # allow command line to override platform flags
|
||||||
env[f[0]] = f[1]
|
env[f[0]] = f[1]
|
||||||
|
|
||||||
# must happen after the flags, so when flags are used by configure, stuff happens (ie, ssl on x11)
|
# Must happen after the flags definition, so that they can be used by platform detect
|
||||||
detect.configure(env)
|
detect.configure(env)
|
||||||
|
|
||||||
# Enable C++11 support
|
# Set our C and C++ standard requirements.
|
||||||
|
# Prepending to make it possible to override
|
||||||
|
# This needs to come after `configure`, otherwise we don't have env.msvc.
|
||||||
if not env.msvc:
|
if not env.msvc:
|
||||||
env.Append(CXXFLAGS=['-std=c++11'])
|
# Specifying GNU extensions support explicitly, which are supported by
|
||||||
|
# both GCC and Clang. This mirrors GCC and Clang's current default
|
||||||
|
# compile flags if no -std is specified.
|
||||||
|
env.Prepend(CFLAGS=['-std=gnu11'])
|
||||||
|
env.Prepend(CXXFLAGS=['-std=gnu++14'])
|
||||||
|
else:
|
||||||
|
# MSVC doesn't have clear C standard support, /std only covers C++.
|
||||||
|
# We apply it to CCFLAGS (both C and C++ code) in case it impacts C features.
|
||||||
|
env.Prepend(CCFLAGS=['/std:c++14'])
|
||||||
|
|
||||||
# Configure compiler warnings
|
# Configure compiler warnings
|
||||||
if env.msvc:
|
if env.msvc:
|
||||||
|
|||||||
@@ -205,7 +205,6 @@ def configure(env):
|
|||||||
|
|
||||||
env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/include"])
|
env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++/include"])
|
||||||
env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++abi/include"])
|
env.Append(CPPFLAGS=["-isystem", env["ANDROID_NDK_ROOT"] + "/sources/cxx-stl/llvm-libc++abi/include"])
|
||||||
env.Append(CXXFLAGS=["-std=gnu++14"])
|
|
||||||
|
|
||||||
# Disable exceptions and rtti on non-tools (template) builds
|
# Disable exceptions and rtti on non-tools (template) builds
|
||||||
if env['tools']:
|
if env['tools']:
|
||||||
|
|||||||
Reference in New Issue
Block a user