-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consider making CMAKE_CXX_STANDARD a required user-provided option #6767
Comments
Drive-by opinion. If the primary motivation is telemetry, I feel like there's still a problem. If users have to explicitly specify it and they say copy/paste from the instructions, they might just leave |
Well, I wouldn't say the primary motivation is telemetry. But to the extent that we have telemetry, making it more accurate would be good. Maybe our instructions could say Alternatively, maybe we should simply make our default the newest supported C++ standard, and then users can explicitly set it to anything they want all the way back to 11... but the default would be 20 or 17 or the latest standard supported by the compiler we're testing on. |
Today we default to the oldest C++ standard we support (C++11), as described in the first comment in this issue. I'm now starting to like the idea of defaulting to the newest C++ standard available, while of course still supporting users who explicitly need an older standard (back to C++11). What might this actually look like? Option 1: Default How would we do this? I'm not totally sure, but I suspect we could use Option 2: No default for We would simply require that users specify |
Here is an alternative thought: don't require the setting at all. For all the compilers we support (GCC >= 6.x, Clang >= 6.x, MSCV >= 2017) the default is C++14. If we (or the customer) left the standard undefined, we get what we want. We can check that it is not less than 11, but we do not need to require it. |
I like that option a lot. |
Surfacing this again. I really like Carlos's suggestion in his last post: we stop setting I may work on a PR for this. If someone sees problems w/ this, speak up. |
Fixes: #6767 Rather than us explicitly setting (defaulting) CMAKE_CXX_STANDARD=11, we leave it unset and rely on the compiler's default C++ language standard. This will let customers more easily build w/ the "correct" standard for their platform.
Today our CMake builds set the C++ language standard to 11 by default
google-cloud-cpp/CMakeLists.txt
Lines 37 to 39 in d8eedae
Users can override that with something like
cmake -DCMAKE_CXX_STANDARD=17 ...
, but if they don't specify something, we choose 11. Defaulting to C++11 will bias our telemetry data about C++ standard usage. And 11 may not be the correct default if users are using, say, C++17 in their own code (though it should work correctly in most cases).We should consider not defaulting
CMAKE_CXX_STANDARD
to 11 and instead requiring that users explicitly specify the standard that they want to use.Of course, we should continue to support C++11, and we'd need to have some builds that verify that our code works in a C++11 environment.
The text was updated successfully, but these errors were encountered: