diff options
author | Bruce Dawson <randomascii@users.noreply.github.com> | 2022-06-16 07:47:21 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-16 07:47:21 (GMT) |
commit | a4c24a33c1ed32d9d51c8df763ec6ad574587d02 (patch) | |
tree | 1568dbd06c9a927018e23191581f57c771aff1aa /configure.py | |
parent | 1d4034f0ac2b5cfb809b5ab983d47c3cb2c78415 (diff) | |
download | Ninja-a4c24a33c1ed32d9d51c8df763ec6ad574587d02.zip Ninja-a4c24a33c1ed32d9d51c8df763ec6ad574587d02.tar.gz Ninja-a4c24a33c1ed32d9d51c8df763ec6ad574587d02.tar.bz2 |
Build ninja with C++11 (#2089)
* Build ninja with C++11
In order to allow future use of std::chrono to make the stats code
portable it is desirable to compile with C++11. Doing so also allows use
of std::unordered_map, and reduces the number of #ifdefs in the ninja
source code.
Switching to C++11 requires modifying both CMakeLists.txt and
configure.py, for MSVC and for other build systems. For MSVC the
required change is adding /Zc:__cplusplus to tell the compiler to
give a more accurate value for the __cplusplus macro. For other
platforms the change is to add -std=c++11 or the CMake equivalent.
This change makes some progress towards resolving issue #2004.
* Delete code and instructions
C++11 guarantees that string::data() gives null-terminated pointers, so
explicitly adding a null terminator is no longer needed.
The Google C++ Style Guide already recommends avoiding unnecessary use
of C++14 and C++17 so repeating this in CONTRIBUTING.md is not critical.
These changes both came from PR-review suggestions.
* Only set cxx_std_11 if standard is 98
* Return to unconditional target_compile_features use
After much discussion it sounds like using target_compile_features
unconditionally is best.
Diffstat (limited to 'configure.py')
-rwxr-xr-x | configure.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/configure.py b/configure.py index 4390434..99a2c86 100755 --- a/configure.py +++ b/configure.py @@ -305,6 +305,8 @@ if platform.is_msvc(): else: n.variable('ar', configure_env.get('AR', 'ar')) +# Note that build settings are separately specified in CMakeLists.txt and +# these lists should be kept in sync. if platform.is_msvc(): cflags = ['/showIncludes', '/nologo', # Don't print startup banner. @@ -320,6 +322,7 @@ if platform.is_msvc(): # Disable warnings about ignored typedef in DbgHelp.h '/wd4091', '/GR-', # Disable RTTI. + '/Zc:__cplusplus', # Disable size_t -> int truncation warning. # We never have strings or arrays larger than 2**31. '/wd4267', @@ -339,6 +342,7 @@ else: '-Wno-unused-parameter', '-fno-rtti', '-fno-exceptions', + '-std=c++11', '-fvisibility=hidden', '-pipe', '-DNINJA_PYTHON="%s"' % options.with_python] if options.debug: |