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

Handle gracefully the scenario where 'git' is missing on the host system #513

Open
lemire opened this issue Oct 14, 2023 · 0 comments
Open

Comments

@lemire
Copy link
Contributor

lemire commented Oct 14, 2023

As far as I can tell, CPM has currently 'git' as a hard dependency but it does not warn the user if git is missing. Currently, if git is missing, it may fail with could not find git for clone of.

When the dependencies are on github, you can side-step the issue with a backup...

  
find_package(Git QUIET)
if(Git_FOUND)
  # do whatever you do right now
else()
  # try an alternative
  set(zip_url "https://github.com/${GITHUB_REPO}/archive/${COMMIT}.zip")
  set(archive "${dep_root}/archive.zip")
  set(dest "${dep_root}/_extract")

  file(DOWNLOAD "${zip_url}" "${archive}")
  file(MAKE_DIRECTORY "${dest}")
  execute_process(
          WORKING_DIRECTORY "${dest}"
          COMMAND "${CMAKE_COMMAND}" -E tar xf "${archive}")
  file(REMOVE "${archive}")
endif()

This was covered in issue #191 but was proposed as a way to save bandwidth. I am recommending to allow zip downloads to make CPM more robust (more likely to succeed).

If you don't want to offer this option, then, I recommend warning the user:

find_package(Git QUIET)
if(NOT(Git_FOUND))
  message(STATUS "CPM could not find git, it may not work.")
endif()

I am trying to integrate CPM into ada-url/ada and the handling the case where git is not present is not pretty. It would be better if CPM handled it for us.

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

1 participant