-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Push policy stack in InstallDependencies module #6878
Conversation
Thanks for the detailed explanation. I spent quite a while researching your comments from #6780 and reading the PR and what wasn't immediately obvious is that (from what I'm reading ) the install script comes before the main |
The main |
Right, because it's interpreted at I realize this may cause a slight overhead when NOT installing since the scripts will need to be included/interpreted in advance, but it would also mean that any changes to scripts we call from The reason I ask is because the |
There's no global state shared between configuration and installation scripts. Functions can't be shared, nor can policies or minimum required versions. It's a different script running in a different process. The code in As for why we do this, I'm not sure of the exact details. It looks like it was mostly written by Lukas-W and Reflexe, who aren't around much these days. Ideally we would specify dependencies well enough in the configuration script that CMake's automatically generated installation script does the right thing without any custom code. However, that's probably far from trivial to fix up, and isn't the intent of this pull request.
This is true, but the policy doesn't retroactively apply to files that have already been included. Setting policy CMP0011 in a file will not introduce a scope for that file, only for future inclusions. |
This is hard documentation to find. I found a question on StackOverflow confirming it: https://stackoverflow.com/a/62023303/3196753.
Agreed.
Right, I was referring to the former (stared state) scenario, which doesn't exist. So now that I understand the behavior better, this
But in your own words, there's no shared state, right? So isn't this superfluous either way? Lastly, and just asking here because documentation on this is sparse... is |
It can't pollute the configuration script, no, but that wasn't a concern, given that the configuration script already has that policy set anyway. It can still affect the rest of the installation script, however. My concern is that the vast majority of the installation script is automatically generated, and not under our control. I have no idea if it is compatible with all settings of all policies, or, even if it is right now, whether it is guaranteed to remain so.
It is allowed, yes. We could replace the
I admit that one motivating factor for this PR is to reduce terminal spam when running the install script, but warnings still exist for a reason. Policies that are set by one of our files for the benefit of that file shouldn't affect the script globally, as that's not our responsibility to control, and we can't predict what impact it will have. We also don't want to risk relying on it implicitly, and have things break if CMake enables CMP0011 by default (or we remove the file current under discussion, etc.). |
Ok, you're referring to the built-in cmake installation script here, not our own. This is the part that I was missing. I agree, better not to poke the bear here. |
Since #6780, we get this warning when running the install script:
That module previously set CMP0011, presumably to silence this error, but as I mentioned in #6780 (comment), this fix is incorrect. It only silences the warning, doing nothing to create the intended policy scope. (This is a deliberate choice by CMake - it silences the warning to support the use case where a helper module is included in order to set policies.) To create a policy scope for a file that has already been included without one, the
cmake_policy(PUSH)
andcmake_policy(POP)
commands can be used.(Apologies to @tresf - I should have thought of this when reviewing that PR.)