conan
conan copied to clipboard
[feature] current "check_min_cppstd" is not enough
When using the tool check_min_cppstd could have 3 different meanings and the current implementation is not enough.
These are the use cases, let`s use cppstd=17 for the examples and a proposal:
- This package cannot be built with a cppstd < 17. Meaning the flags for the compiler (and the current user compiler) should support and set cppstd=17. This use case is very common.
Proposal: In a validate_build() method we can call a new check_user_min_cppstd that would use the self.settings instead of the self.info.settings (In this case, conan should check the self.settings.compiler.cppstd to know the specified cppstd version from the profile). If the cppstd doesn't match it can raise ConanErrorConfiguration.
- This package is not going to work if the users' compiler is not prepared to build cppstd 17 code (headers with c++ 17 code). This use case is very common too.
Proposal: In a validate() method we can call a new check_user_min_cppstd that would use the self.settings instead of the self.info.settings (In this case, conan should check the self.settings.compiler.cppstd to know the specified cppstd version from the profile). If the cppstd doesn't match it can raise ConanErrorConfiguration.
- We need that the binary package that is going to be reused had been compiled with cppstd >=17. This affects the compatible packages, meaning that, in case of a missing package, the replacement had to be compiled with cppstd >=17. I would say this use case is less common but possible.
Proposal: In a validate() method call the current check_min_cppstd that checks against self.info.settings.compiler.cppstd and raises an InvalidConfiguration so the compatibles mechanism can iterate the alternatives and choose the correct binary from the ones available.
PD: Naming: check_user_min_cppstd is not great. Maybe keep the check_min_cppstd for the two first points (I would say most used) and name different the third one?
PD: Are there other use cases?
Related https://github.com/conan-io/conan/pull/12070
This PR could be related: https://github.com/conan-io/conan-center-index/pull/12928/files#diff-a7c543f8c546c2ddde45684244bbbbecbc7bb8148a5a5fba2f9e8a500096bcbe
A header-only package needs c++17, but as we are using self.info.clear() we can't validate the cppstd, since it's removed. When testing it with conan create, the test package does not validate it too, so we only see the error when building the example. We have the same behavior when using validate_build().
@uilianries In develop (Conan 1.X) we have a known different behavior with the settings and the info. We want, by looking into this issue, the different use cases, and possibly more, and introduce tests in develop2 modeling them. Once we get something that works, we will work in how to migrate the same behavior to Conan 1.X and help in the migration of the recipes.
WIll be closed by https://github.com/conan-io/conan/pull/12555
Closed by https://github.com/conan-io/conan/pull/12555, will be in beta.6
And for 1.55 the approach is: use self.settings in validate(), not self.info.settings