diff options
author | Andrew Morrow <acm@mongodb.com> | 2016-04-18 15:12:34 -0400 |
---|---|---|
committer | Andrew Morrow <acm@mongodb.com> | 2016-04-18 15:12:34 -0400 |
commit | a0c60da29313848e6b4207a8d301d2facdf3fd7c (patch) | |
tree | a0458d11ff1ae7bdd869cb5c8ee5d4b1a262dd06 /SConstruct | |
parent | a5fd4769aaebcb1af2427601b2e0ab8a52ae9971 (diff) | |
download | mongo-a0c60da29313848e6b4207a8d301d2facdf3fd7c.tar.gz |
SERVER-23520 Add a C++14 canary builder
Diffstat (limited to 'SConstruct')
-rw-r--r-- | SConstruct | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/SConstruct b/SConstruct index 89ac8da26b3..bdbe8124a8c 100644 --- a/SConstruct +++ b/SConstruct @@ -445,6 +445,12 @@ add_option("experimental-decimal-support", nargs='?', ) +add_option("cxx-std", + choices=["11", "14"], + default="11", + help="Select the C++ langauge standard to build with", +) + def find_mongo_custom_variables(): files = [] for path in sys.path: @@ -1854,13 +1860,17 @@ def doConfigure(myenv): conf.Finish() if not myenv.ToolchainIs('msvc'): - if not AddToCXXFLAGSIfSupported(myenv, '-std=c++11'): - myenv.ConfError('Compiler does not honor -std=c++11') + if get_option('cxx-std') == "11": + if not AddToCXXFLAGSIfSupported(myenv, '-std=c++11'): + myenv.ConfError('Compiler does not honor -std=c++11') + elif get_option('cxx-std') == "14": + if not AddToCXXFLAGSIfSupported(myenv, '-std=c++14'): + myenv.ConfError('Compiler does not honor -std=c++14') if not AddToCFLAGSIfSupported(myenv, '-std=c99'): myenv.ConfError("C++11 mode selected for C++ files, but can't enable C99 for C files") if using_system_version_of_cxx_libraries(): - print( 'WARNING: System versions of C++ libraries must be compiled with C++11 support' ) + print( 'WARNING: System versions of C++ libraries must be compiled with C++11/14 support' ) # We appear to have C++11, or at least a flag to enable it. Check that the declared C++ # language level is not less than C++11, and that we can at least compile an 'auto' @@ -1883,13 +1893,35 @@ def doConfigure(myenv): context.Result(ret) return ret + def CheckCxx14(context): + test_body = """ + #ifndef _MSC_VER + #if __cplusplus < 201402L + #error + #endif + #endif + auto DeducedReturnTypesAreACXX14Feature() { + return 0; + } + """ + + context.Message('Checking for C++14... ') + ret = context.TryCompile(textwrap.dedent(test_body), ".cpp") + context.Result(ret) + return ret + conf = Configure(myenv, help=False, custom_tests = { 'CheckCxx11' : CheckCxx11, + 'CheckCxx14' : CheckCxx14, }) if not conf.CheckCxx11(): myenv.ConfError('C++11 support is required to build MongoDB') + if get_option('cxx-std') == "14": + if not conf.CheckCxx14(): + myenv.ConfError('C++14 does not appear to work with the current toolchain') + conf.Finish() def CheckMemset_s(context): |