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

Timestamps for URL downloads match the download time #372

Merged
merged 9 commits into from
Aug 3, 2022

Conversation

robertmaynard
Copy link
Contributor

By enabling CMake policy 135 we ensure that extracted files timestamp match that of the download time, instead of when the archive is created. This makes sure that if the URL changes to an older version we still rebuild everything as the timestamp
stays newer.

By enabling CMake policy 135 we ensure that extracted files
timestamp match that of the download time, instead of when the
archive is created. This makes sure that if the URL changes to
an older version we still rebuild everything as the timestamp
stays newer.
@TheLartians
Copy link
Member

TheLartians commented Jul 23, 2022

Hey, thanks for the PR! That policy change definitely sounds like a good idea. However, I feel a bit uneasy with changing global CMake policies from a utility script like CPM, as it can be unexpected for users. E.g. this lead to different behaviour of the same scripts based on the current CMake version.

Alternatively, how about adding a note to the Readme explaining the issue and suggesting using cmake_minimum_required(VERSION <min>...3.24) (which will auto-set the new policies) in projects, if possible?

@robertmaynard
Copy link
Contributor Author

Hey, thanks for the PR! That policy change definitely sounds like a good idea. However, I feel a bit uneasy with changing global CMake policies from a utility script like CPM, as it can be unexpected for users. E.g. this lead to different behaviour of the same scripts based on the current CMake version.

Alternatively, how about adding a note to the Readme explaining the issue and suggesting using cmake_minimum_required(VERSION <min>...3.24) (which will auto-set the new policies) in projects, if possible?

I think we would need to suggest that the projects set CMAKE_POLICY_DEFAULT_CMP0135 value instead cmake_minimum_version. That way when a nested project calls CPM it uses the correct behavior instead of the behavior being reset by the nested projects cmake_minimum_version call.

@robertmaynard
Copy link
Contributor Author

How about if we do this as a global CPM option? That would be an opt-in behavior change and we would document the flag as only working with CMake 3.24+

@TheLartians
Copy link
Member

TheLartians commented Jul 27, 2022

I think we would need to suggest that the projects set CMAKE_POLICY_DEFAULT_CMP0135 value instead cmake_minimum_version. That way when a nested project calls CPM it uses the correct behavior instead of the behavior being reset by the nested projects cmake_minimum_version call.

I see, that's a good point. Maybe having an option like CPM_SET_RECOMMENDED_CMAKE_POLICIES, that sets the policies and defaults (as available for the current CMake version) on launch, would be a good idea.

Enabling CPM_SET_RECOMMENDED_CMAKE_POLICIES will establish defaults
for all CMake policies so that both CPM and added projects
operate inline with CPM recommended best practices.
@robertmaynard
Copy link
Contributor Author

I think we would need to suggest that the projects set CMAKE_POLICY_DEFAULT_CMP0135 value instead cmake_minimum_version. That way when a nested project calls CPM it uses the correct behavior instead of the behavior being reset by the nested projects cmake_minimum_version call.

I see, that's a good point. Maybe having an option like CPM_SET_RECOMMENDED_CMAKE_POLICIES, that sets the policies and defaults (as available for the current CMake version) on launch, would be a good idea.

I have updated this PR with the introduction of CPM_SET_RECOMMENDED_CMAKE_POLICIES

Copy link
Member

@TheLartians TheLartians left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for updating the PR to add the recommended policy updates!

README.md Outdated Show resolved Hide resolved
cmake/CPM.cmake Outdated Show resolved Hide resolved
cmake/CPM.cmake Outdated Show resolved Hide resolved
@TheLartians
Copy link
Member

TheLartians commented Jul 31, 2022

I also wonder if it would make sense to default CPM_SET_RECOMMENDED_CMAKE_POLICIES to YES, as I can imagine this being much more common than opting out. It's hard to imagine the policy changes in question to introduce bugs. But then again I'm not completely sure about all possible implications and edge-cases.

@iboB do you have any thoughts on this?

robertmaynard and others added 2 commits August 1, 2022 08:48
Co-authored-by: Lars Melchior <[email protected]>
Co-authored-by: Lars Melchior <[email protected]>
@iboB
Copy link
Member

iboB commented Aug 3, 2022

I agree with @TheLartians that setting the policies to new by default is desirable. This is the future, right? :)

I also think that we should set them when CPM.cmake is included.

It should be the responsibility of the users to manually handle policies if they want to depend on the old behavor

IMO the tougher question is what to do with the policies set in cmp_add_subdirectory. We can just delete the code there and assume they're being handled from above (and I favor this), but it should be noted that if we allow opting out of setting the default CPM policies, old working code with options will break. If we do keep the code there, there is no point in setting them to NEW at the point of inclusion. Also in such case CPMAddPackage will set them to NEW in packages added with OPTIONS anyway regardless of the opt-out. We could also do a cmake_policy(PUSH/POP) there to try to save the policy configuration from the scope above, but they will be set to NEW in the package's CMakeLists anyway.

Thinking about it, I find it unpleasant that adding the exact same package with and without OPTIONS will lead to potentially different policy configurations in the package itself.

So... in short I would:

  • set all three policies to NEW when including CPM.cmake without the possibility to opt-out
  • document that these policies are set to NEW and advise authors who want to depend on the old behavior that they should manually take care of it in the appropriate places.

@robertmaynard
Copy link
Contributor Author

robertmaynard commented Aug 3, 2022

Based on the feedback it looks like everyone agrees that the policies should be set on inclusion of CPM.cmake. So I have updated the PR to do exactly that.

The policies are still guarded by CPM_SET_RECOMMENDED_CMAKE_POLICIES, but by default the value is set to ON. Once we have agreed on default behavior I will update this PR.

@TheLartians
Copy link
Member

TheLartians commented Aug 3, 2022

Thanks @iboB for the feedback and @robertmaynard for the changes!

After thinking about it I'm now also convinced that setting the policies initially without option to opt-out is the way to go. Besides the points mentioned above, providing no opt-out also means less options to handle and maintain for us. If setting the policies do lead to an increase in issues, we can still add an opt-out in a future version if deemed necessary.

@robertmaynard
Copy link
Contributor Author

After thinking about it I'm now also convinced that setting the policies initially without option to opt-out is the way to go. Besides the points mentioned above, providing no opt-out also means less options to handle and maintain for us. If setting the policies do lead to an increase in issues, we can still add an opt-out in a future version if deemed necessary.

I have updated the PR to always enable the policies, and dropped the CPM_SET_RECOMMENDED_CMAKE_POLICIES option ( and docs ).

Copy link
Member

@TheLartians TheLartians left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks! Perhaps we can still add a quick note in the readme about the policies , but IMO it's also good as is.

@TheLartians TheLartians merged commit b224ce2 into cpm-cmake:master Aug 3, 2022
@robertmaynard robertmaynard deleted the handle_cmp0135 branch August 4, 2022 12:29
rapids-bot bot pushed a commit to rapidsai/rapids-cmake that referenced this pull request Aug 8, 2022
With cpm-cmake/CPM.cmake#372 merged into CPM we should update our CPM version so that RAPIDS developers don't see CMake policy warnings with CMake 3.24+

Authors:
  - Robert Maynard (https://github.com/robertmaynard)

Approvers:
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #236
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

Successfully merging this pull request may close these issues.

3 participants