SlicerParcellation Scripted Module Works via Absolute Path but Fails When Added to Custom Slicer Build via CMake

Hi Slicer community,

I’ve been customizing my own Slicer build and integrating several external modules. Most of them, including other scripted modules, have been successfully added and built using CMake.

Now I’m trying to integrate this repository:
:link: GitHub - fepegar/SlicerParcellation: 3D Slicer modules for brain segmentation using deep learning.

:white_check_mark: When I manually set its absolute path in Application Settings > Modules, the module loads and runs correctly in my custom Slicer build — so the code itself is functional.

:cross_mark: However, when I try to add it to my custom Slicer build via CMake, even after creating a CMakeLists.txt inside the module and setting it up like other scripted modules, I get build errors during the configuration or compilation step.

This issue only happens during the build process. Other scripted modules I’ve added are building fine.

What I’ve done:

  • Cloned the repo into the Slicer source tree (e.g., Modules/Scripted/SlicerParcellation).
  • Created a CMakeLists.txt for the module.
  • Registered it like other modules in my custom build’s CMakeLists.txt.
  • Confirmed it works when loaded manually.

##cmake.txt

#-----------------------------------------------------------------------------

set(MODULE_GROUP_NAME SlicerParcellation)

#-----------------------------------------------------------------------------

set(MODULE_PYTHON_SCRIPTS
BrainParcellation.py
BrainResectionCavitySegmentation.py
InferenceUtils.py
PyTorchUtils.py
TorchIOUtils.py
)

#-----------------------------------------------------------------------------

set(MODULE_PYTHON_LIBS
lib/GeneralUtils.py
lib/sitkUtils.py
lib/init.py
)

#-----------------------------------------------------------------------------

set(MODULE_PYTHON_RESOURCES
Resources/Icons/BrainParcellation.png
Resources/Icons/BrainResectionCavitySegmentation.png
GIFNiftyNet.ctbl
)

#-----------------------------------------------------------------------------

slicerMacroBuildScriptedModule(
NAME ${MODULE_GROUP_NAME}
SCRIPTS ${MODULE_PYTHON_SCRIPTS}
LIBS ${MODULE_PYTHON_LIBS}
RESOURCES ${MODULE_PYTHON_RESOURCES}
WITH_GENERIC_TESTS
)

Module in my scripted Modules folder