Skip to content
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

[question] ability to call cppstd helpers in conan.tools.build within a package_id() method #16147

Open
1 task
jcar87 opened this issue Apr 25, 2024 · 1 comment
Assignees

Comments

@jcar87
Copy link
Contributor

jcar87 commented Apr 25, 2024

What is your question?

example use case

from conan.tools.build import valid_max_cppstd

def package_id():
    if self.info.settings.get_safe("compiler.cppstd") and not valid_max_cppstd(self, "14"):
        self.info.settings.compiler.cppstd = "14"

def generate():
        cppstd = self.settings.get_safe("compiler.cppstd")
        if cppstd and not valid_max_cppstd(self, "14"):
            tc.cache_variables["CMAKE_CXX_STANDARD"] = "14"

This fails because the implementation of valid_max_cppstd() accessses self.settings which is not allowed within a package_id()

Have you read the CONTRIBUTING guide?

  • I've read the CONTRIBUTING guide
@valgur
Copy link
Contributor

valgur commented Apr 25, 2024

YES, PLEASE. This is quite a headache when trying to re-use the same checks in package_id and elsewhere. self.settings and self.options should not be modifiable in package_id(), but it would be great to be able to do read-only access to these values as mentioned in the issue.

Doing valid_max_cppstd(self.info, "14") can be used in the above snippet as a workaround, though.

@memsharded memsharded self-assigned this Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants