-
Notifications
You must be signed in to change notification settings - Fork 945
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
Use target_compile_features to set c++ standard flags #2211
base: master
Are you sure you want to change the base?
Conversation
Directly setting the compiler flags can break downstream compilation, particularly with nvcc
Without setting CXX_EXTENSIONS to OFF, clang and gcc will use the gnu extension versions of the c++ standard flags which caused a compile error on linux in CI
I've said this a couple of times now: I don't think cinder should try to automagically set the standard version. That should be left to the user. At most, it should tell cmake the minimal required standard version ( |
Just to be clear: This is still better than the status quo |
using cmakes compile features (like I've kept the logic that was in the |
My point is, cinder should not set the standard to c++17/20/23 just because the compiler supports it. But as you said, it is whats currently there and the change is certainly an improvment. One thing you could do while changing that code is to remove the c++11 fallback, as IIRC cinder no longer supports c++11 on any platform.
The imho proper method to specify the standard is setting |
Agreed, but changing that risks breaking peoples builds so should probably be the subject of a different PR with input from people who have some authority on what standards Cinder supports for various platforms (ie not me!)
I think you might have that backwards, CMAKE_CXX_STANDARD silently decays to a lower standard whereas using |
Not when you set CMAKE_CXX_STANDARD_REQUIRED to ON. And the reason, why I prefer CMAKE_CXX_STANDARD over cxx_std_XX is because the latter easily introduces unexpected standard version mismatches between different parts of your project: Let's say lib A needs 11, and the executable B that uses it needs 14. As a result lib A will be compiled with 11, but when the headers are used in B, they are interpreted in 14 which may or may not be compatible with the binary of A. Also, in older cmake versions (I don't remember which) cxx_std_XX would actually downgrade the standard version to XX, even if e.g. the compiler default is newer, which can also be annoying when the lib only requires 11, but adds features when compiled with 14. Anyway all this has little to do with the PR at hand. It is an incremental improvement that should get merged, even if I don't like the section as a whole. |
Directly setting the compiler flags can break downstream compilation, particularly with nvcc
Fixes an item in list 2 from #2189