-
Notifications
You must be signed in to change notification settings - Fork 190
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
Don't unconditionally download in get_cpm.cmake #554
Comments
In my opinion, adding the |
Thank you for the feedback! I'm not very experienced with CMake, which is why I didn't file this as a PR, but if you have a suggestion for a better way (all that is really necessary here is some way of preventing the download) I'd be happy to test it and create a PR. |
Hey, thanks for the issue! For sandboxed environments, I recommend vendoring dependencies (and CPM itself) by setting the |
Thank you for the suggestion! Unfortunately, even with CPM vendored under CPM_SOURCE_CACHE, I was experiencing build failures due to attempted downloads. |
@genevieve-me that's unexpected, as one of the goal of this project is to make it simple to work with sandboxed / offline environments. Can you please try if the following works for you? # while connected to the internet we clone a test project
git clone https://github.com/TheLartians/ModernCppStarter
cd ModernCppStarter
# define the source cache to a local directory or leave as-is if it's already defined
export CPM_SOURCE_CACHE=$(pwd)/cache
# configure the project (this should populate the cache with CPM and some dependencies of the starter)
cmake -S test -B build
# once finished, delete the build directory to simulate a clean environment
rm -rf build Now the cache is populated, and we should be able to configure the project without internet connection. With the same # should work offline if the cache is populated
cmake -S test -B build
# we should also be able to build the project
cmake --build build This works fine on my computer, so I assume that working in sandboxed environments with populated caches should work too. If you encounter issues can you share the full error message together with information about your system, like OS, CMake version etc? |
The provided get_cpm.cmake template will always try to download from github:
CPM.cmake/cmake/get_cpm.cmake
Line 19 in 0370507
This causes builds to fail when run by a sandboxed builder. For example, I was hoping to package ada-url for nixpkgs, which uses your template verbatim, and had to patch it to not download if
CPM_DOWNLOAD_LOCATION
was set, eg:Would you be open to making such a change upstream? Thanks!
The text was updated successfully, but these errors were encountered: