[build2] Constraining the C++ standard

lyrahgames lyrahgames at mailbox.org
Thu Jul 6 14:07:30 UTC 2023


Hello,

for some testing, I have package the cxxopts library.

https://github.com/lyrahgames/build2-cxxopts

The tests for this library are based on the old version 1.5.0 of Catch.
Unfortunately, this version does not compile with the latest C++ 
standard enabled.
Hence, in contrast to the recommendation in the build system manual,
I constrained the standard to C++14 with 'cxx.std = c++14' in the 
'root.build' of the tests package.
The header-only library package itself still sets 'cxx.std = latest' to 
not constrain anything else.
As the tests will never be a dependency of any other project, I thougt 
this should be ok.
And indeed, on my computer as for the GCC- and Clang-based CI builds, 
it works without problems.
However, building on Windows with MSVC the builds fail already in the 
configuration step
with the compiler complaining about an unsupported C++ standard 
'C++c++14':
"error: C++c++14 is not supported by Microsoft (R) C/C++ Optimizing 
Compiler Version 19.36.32534 for x64"

I assume that the specific standards are not mapped to the compilers.
Is there any way for me to constrain the standard consistently for all 
compilers?
Or should I deal with this problem in a completely different manner?

Also, what should I do if a library that is not binless only compiles 
with a specific older standard
but not with the latest one, as it is for ChaiScript:

https://github.com/build2-packaging/chaiscript

As I got it from the manual, there might be ABI-breaking changes 
between standards.
For now, I constrained the standard to C++17 for ChaiScript as it was 
the only thing I could think of,
still, constraining the builds to GCC and Clang and possibly breaking 
ABI across different projects.

Thank you very much in advance for your help.

Greetings
Markus





More information about the users mailing list