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

**URL:** https://discourse.slicer.org/t/slicerparcellation-scripted-module-works-via-absolute-path-but-fails-when-added-to-custom-slicer-build-via-cmake/43832
**Category:** Support
**Created:** [July 24, 2025, 9:43am UTC](https://discourse.slicer.org/t/slicerparcellation-scripted-module-works-via-absolute-path-but-fails-when-added-to-custom-slicer-build-via-cmake/43832 "2025-07-24T09:43:25Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![software](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/software/32/79627_2.png) [@software](https://discourse.slicer.org/u/software)
#### Post date: [July 24, 2025, 9:43am UTC](https://discourse.slicer.org/t/slicerparcellation-scripted-module-works-via-absolute-path-but-fails-when-added-to-custom-slicer-build-via-cmake/43832/1 "2025-07-24T09:43:25Z")

</div>

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:  
🔗 [GitHub - fepegar/SlicerParcellation: 3D Slicer modules for brain segmentation using deep learning.](https://github.com/fepegar/SlicerParcellation)

✅ 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.

❌ 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

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/4/b/4b0210d47bc53c110b420b29101cfd3305be0c0c.png)
