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

Expand CPM_SOURCE_CACHE path provided as a configure argument #186

Merged
merged 1 commit into from
Jan 21, 2021

Conversation

iboB
Copy link
Member

@iboB iboB commented Jan 21, 2021

Long story:

If one relies on get_cpm.cmake instead of a manual copy of CPM.cmake, and configures with -DCPM_SOURCE_CACHE=~/some/path (with a tilde which they expect to be expanded to $HOME), this CMake issue hits and thus the EXISTS check always fails, and file(DOWNLOAD always fails (one would expect that it would create the directory \~ (literal tilde) but it doesn't... anyway)

Further when CPM.cmake gets included CPM_SOURCE_CACHE is cached as CACHE PATH which does the expansion and subsequent code is not affected by the tilde. That's why nothing special needs to be done for the actual CPM.cmake code. It works even if used by a manual copy and not through get_cpm.

Otherwise if one configures with -DCPM_SOURCE_CACHE=~/something (tilde to be expanded to $HOME), https://gitlab.kitware.com/cmake/cmake/-/issues/21729 hits, EXISTS always fails, and file(DOWNLOAD fails
@TheLartians
Copy link
Member

Interesting. Probably we should also expand ENV{CPM_SOURCE_CACHE} as I suppose environmental variables like export CPM_SOURCE_CACHE=~/some/path cmake are effected similarly?

@iboB
Copy link
Member Author

iboB commented Jan 21, 2021

It's pretty hard to add a tilde in an env var. Your export example will expand it and the environment variable will contain what's expected

@iboB
Copy link
Member Author

iboB commented Jan 21, 2021

One would need to make special effort to confuse the environment variable check... and I suppose if they do, then for some reason they do want the literal tilde

@TheLartians
Copy link
Member

It's pretty hard to add a tilde in an env var. Your export example will expand it and the environment variable will contain what's expected

Huh, you're right, who would have thought that shell expansion can be that confusing 😅

@TheLartians TheLartians merged commit fe8d15b into cpm-cmake:master Jan 21, 2021
@TheLartians
Copy link
Member

FYI: the feature is live in 0.28.1 🎉

@iboB iboB deleted the get-cpm-expand branch January 29, 2022 04:16
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.

None yet

2 participants