Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions CMake/ITKModuleRemote.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Function to fetch remote modules.

#-----------------------------------------------------------------------------
# Freeze remote module revisions to prevent git updates. This is useful
# during development when working with modified remote modules to prevent
# losing local changes during reconfiguration.
#
option(
ITK_FREEZE_REMOTE_MODULES
"Do not update remote modules to new revisions during reconfiguration"
OFF
)
mark_as_advanced(ITK_FREEZE_REMOTE_MODULES)

# Helper to perform the initial git clone and checkout.
function(_git_clone git_executable git_repository git_tag module_dir)
execute_process(
Expand Down Expand Up @@ -194,6 +206,10 @@ endfunction()
# facilitate testing of remote module branch behaviors without
# requiring changes to the ITK code base. If Module_${name}_GIT_TAG is
# "" then no git fetch or update will be performed.
#
# Alternatively, set ITK_FREEZE_REMOTE_MODULES=ON to prevent all remote
# modules from being updated during reconfiguration. This is useful when
# working with modified remote modules to avoid losing local changes.
function(itk_fetch_module _name _description)
include(CMakeParseArguments)
cmake_parse_arguments(
Expand Down Expand Up @@ -261,6 +277,7 @@ function(itk_fetch_module _name _description)
if(ITK_FORBID_DOWNLOADS)
return()
endif()

itk_download_attempt_check(Module_${_name})
find_package(Git)
if(NOT GIT_EXECUTABLE)
Expand Down Expand Up @@ -296,6 +313,27 @@ function(itk_fetch_module _name _description)
" specified in file ${ITK_SOURCE_DIR}/Modules/Remote/${_name}.remote.cmake'"
)
endif()

# Check if we should freeze remote modules (skip updates for already-downloaded modules)
# This check comes after Module_${_name}_GIT_TAG override to allow per-module precedence
if(
ITK_FREEZE_REMOTE_MODULES
AND
EXISTS
"${ITK_SOURCE_DIR}/Modules/Remote/${_name}"
AND
NOT
REMOTE_GIT_TAG
STREQUAL
""
)
message(
STATUS
"ITK_FREEZE_REMOTE_MODULES is ON: Skipping update of remote module ${_name}"
)
return()
endif()

set(
Module_${_name}_GIT_TAG
"${REMOTE_GIT_TAG}"
Expand Down
22 changes: 22 additions & 0 deletions Modules/Remote/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,28 @@ of the remote modules should **not** contain the "ITK" string prefix in them.
Git hashes should be used to reference a given module revision. If a tagged version is
required then the equivalent hash should be used in place of the tag string.

## Working with Modified Remote Modules

When working on remote modules locally, you may want to prevent CMake from updating
them to the upstream versions during reconfiguration. There are two approaches:

1. **Freeze all remote modules**: Set `ITK_FREEZE_REMOTE_MODULES=ON` to prevent all
remote modules from being updated. This is the simplest approach when working with
multiple modified remote modules.

```bash
cmake -DITK_FREEZE_REMOTE_MODULES=ON /path/to/ITK
```

2. **Freeze individual modules**: Set `Module_<ModuleName>_GIT_TAG` to a specific
commit hash or empty string to control updates for individual modules.

```bash
cmake -DModule_MinimalPathExtraction_GIT_TAG=e43a18f43272bea8c9de5ded7846efbffc81f0ad \
-DModule_Montage_GIT_TAG=9aafc48520b2cac963f0f1dfad97b32ed9ab89cf \
/path/to/ITK
```


[ITK Software Guide]: https://itk.org/ItkSoftwareGuide.pdf

Expand Down
Loading