google / or-tools

Google's Operations Research tools:
https://developers.google.com/optimization/
Apache License 2.0
10.97k stars 2.1k forks source link

Make shallow clone when fetching dependencies #4272

Closed SYury closed 3 weeks ago

SYury commented 2 months ago

What language and solver does this apply to? CMake build

Describe the problem you are trying to solve. I tried building OR-Tools with all dependencies on a machine with slow and unreliable internet access (very strict corporate proxy) and git clone couldn't fetch some of the largest dependencies (e. g. protobuf) because of their size. The problem went away when I forced CMake to reduce the size by making shallow clone. Describe the solution you'd like Add GIT_SHALLOW 1 to FetchContent_Declare for large dependencies in dependencies CMakeLists. It shouldn't break anything because CMake only needs the latest commit to build a dependency.

Mizux commented 2 months ago

GIT_SHALLOW <bool> New in version 3.6. When this option is enabled, the git clone operation will be given the --depth 1 option. This performs a shallow clone, which avoids downloading the whole history and instead retrieves just the commit denoted by the GIT_TAG option.

ref: https://cmake.org/cmake/help/latest/module/ExternalProject.html#command:externalproject_add

Since we target at least CMake 3.18, it should be safe, on my way to test it...

Mizux commented 3 weeks ago

Done with https://github.com/google/or-tools/commit/f5d9ea77be10a8d33f1e1afbcd9201fcdc9828f3

note: GIT_SHALLOW do not work when using commit sha1