How to bypass the git clone operations during the 3D Slicer build?

Dear Community,

I’m developing an application based on 3D Slicer. And I have locally built 3D Slicer successfully with superbuild set to true. It is known that for the very first build, the git clone operations will be triggered to download the source code remotely for some modules.

However, when I try to rebuild the 3D Slicer or when I change the build folder location, the git clone operations will always be triggered. This makes some troubles to me because the git clone operations are time-consumping or even fail sometimes due to the network situations on my side.

So are there any solutions to bypass the git clone operations during the 3D slicer build, it will really help when the source code is already available locally.

Thanks in advance!

Usually we just build the inner-build project (<Slicer-build-tree>/Slicer-build/Slicer.sln) and not the top-level project (<Slicer-build-tree>/Slicer.sln). The inner-build does not perform any git operation. We only build the top-level project if we want to get updates for dependencies (e.g., if CTK update is needed for some new Slicer features then we run the top-level build once to fetch all those updates).

Hi Andras,
Many thanks for the reply. If I want to build the 3D Slicer in a different folder or on another computer, are there any good ways to directly use the local downloaded packages instead of performing the git operations again? On one hand, this can fix the trouble that I have mentioned in the first post. On the other hand, this can ensure that the build is always performed based on the same source code with different build folders or different computers, which is very important from the version control point of view.

Thanks in advance.

Manual downloading, configuring, and building of all the packages would be very error-prone, that’s why we use CMake to automate these. I would not recommend trying to invest time into this for ensuring consistent build (you can achieve that by using containers, virtual machines, or standardized developer computer images in a much easier way).

If you absolutely have no other choice, for example for fulfilling some security or regulatory requirements then you can give it a try. At a very high level, Slicer_USE_SYSTEM_<project> and <project>_DIR CMake variables can be passed to the superbuild for each project (VTK, ITK, …) to use a prebuilt dependency already on your system, but there are many complicated details. Some people, such as @RafaelPalomar ventured into this field with considerable success, so if you decide to go for it and you get stuck with some issues then you might get some help.

Hi Andras,
Thanks for the information! I will give a try if necessary and ask for help if needed.