Skip to content

[Config] Cmake: Skip dependency re-fetch when already at requested reference#6181

Open
fredroy wants to merge 4 commits into
sofa-framework:masterfrom
fredroy:cmake_speedup_gitprojects
Open

[Config] Cmake: Skip dependency re-fetch when already at requested reference#6181
fredroy wants to merge 4 commits into
sofa-framework:masterfrom
fredroy:cmake_speedup_gitprojects

Conversation

@fredroy

@fredroy fredroy commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

sofa_fetch_dependency now checks the existing checkout's HEAD against the requested GIT_TAG and skips the nested CMake configure+build (used to drive ExternalProject) when they match, re-fetching only when a dependency's reference actually changes. Cuts a warm reconfigure from ~41s to ~13s without relying on FETCHCONTENT_FULLY_DISCONNECTED.

I asked Claude to do it because I always forget that I set FETCHCONTENT_FULLY_DISCONNECTED (off or on) and then having some fetch problems later.
So now it is almost the same speed as with FETCHCONTENT_FULLY_DISCONNECTED but will still update/fetch if needs be.


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@fredroy fredroy added pr: enhancement About a possible enhancement pr: status to review To notify reviewers to review this pull-request pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI labels Jul 13, 2026
@bakpaul

bakpaul commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Ok now this works, but is way more complexe. What do you think ?

@bakpaul

bakpaul commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Ok I simplified it by removing the tag part, if it is not a hash (I also remove the introduced constraint on hash length) then it'll always check the remote tip of the current ref.

Only downside is that now a git ls-remote is always performed when the local ref correspond to what's asked, even for bare hash (this was to avoid forcing hash to be of full 40 digits length, which might not be compatible with all git servers).

A way to avoid this is to check if the tag is only made of hex chars. But this is weak and might lead to false positive (branch name only using hex char and will thus be skipped)

Tell me if this reduces sufficiently your CMake process. In the end this is a good compromise between code readability/maintainability and feature completeness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI pr: enhancement About a possible enhancement pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants