SConstruct - require c++14

This commit is contained in:
artemp 2016-12-08 10:43:25 +01:00
parent fe7e9a7dc5
commit 1372ca48ef

View file

@ -41,8 +41,8 @@ ICU_LIBS_DEFAULT='/usr/'
DEFAULT_CC = "cc"
DEFAULT_CXX = "c++"
DEFAULT_CXX11_CXXFLAGS = " -std=c++14"
DEFAULT_CXX11_LINKFLAGS = ""
DEFAULT_CXX14_CXXFLAGS = " -std=c++14"
DEFAULT_CXX14_LINKFLAGS = ""
if sys.platform == 'darwin':
# homebrew default
ICU_INCLUDES_DEFAULT='/usr/local/opt/icu4c/include/'
@ -1037,12 +1037,12 @@ int main()
return True
return False
def supports_cxx11(context,silent=False):
def supports_cxx14(context,silent=False):
ret = context.TryRun("""
int main()
{
#if __cplusplus >= 201103
#if __cplusplus >= 201402L
return 0;
#else
return -1;
@ -1051,7 +1051,7 @@ int main()
""", '.cpp')
if not silent:
context.Message('Checking if compiler (%s) supports -std=c++11 flag... ' % context.env.get('CXX','CXX'))
context.Message('Checking if compiler (%s) supports -std=c++14 flag... ' % context.env.get('CXX','CXX'))
if silent:
context.did_show_result=1
context.Result(ret[0])
@ -1080,7 +1080,7 @@ conf_tests = { 'prioritize_paths' : prioritize_paths,
'harfbuzz_with_freetype_support': harfbuzz_with_freetype_support,
'boost_regex_has_icu' : boost_regex_has_icu,
'sqlite_has_rtree' : sqlite_has_rtree,
'supports_cxx11' : supports_cxx11,
'supports_cxx14' : supports_cxx14,
'CheckBoostScopedEnum' : CheckBoostScopedEnum,
}
@ -1213,13 +1213,13 @@ if not preconfigured:
# set any custom cxxflags and ldflags to come first
if sys.platform == 'darwin' and not env['HOST']:
DEFAULT_CXX11_CXXFLAGS += ' -stdlib=libc++'
DEFAULT_CXX11_LINKFLAGS = ' -stdlib=libc++'
DEFAULT_CXX14_CXXFLAGS += ' -stdlib=libc++'
DEFAULT_CXX14_LINKFLAGS = ' -stdlib=libc++'
env.Append(CPPDEFINES = env['CUSTOM_DEFINES'])
env.Append(CXXFLAGS = DEFAULT_CXX11_CXXFLAGS)
env.Append(CXXFLAGS = DEFAULT_CXX14_CXXFLAGS)
env.Append(CXXFLAGS = env['CUSTOM_CXXFLAGS'])
env.Append(CFLAGS = env['CUSTOM_CFLAGS'])
env.Append(LINKFLAGS = DEFAULT_CXX11_LINKFLAGS)
env.Append(LINKFLAGS = DEFAULT_CXX14_LINKFLAGS)
env.Append(LINKFLAGS = env['CUSTOM_LDFLAGS'])
### platform specific bits
@ -1353,9 +1353,9 @@ if not preconfigured:
if env['PRIORITIZE_LINKING']:
conf.prioritize_paths(silent=True)
# test for C++11 support, which is required
if not env['HOST'] and not conf.supports_cxx11():
color_print(1,"C++ compiler does not support C++11 standard (-std=c++11), which is required. Please upgrade your compiler")
# test for C++14 support, which is required
if not env['HOST'] and not conf.supports_cxx14():
color_print(1,"C++ compiler does not support C++14 standard (-std=c++14), which is required. Please upgrade your compiler")
Exit(1)
if not env['HOST']: