# Issue with cmake when building extension for 3D Slicer

**URL:** https://discourse.slicer.org/t/issue-with-cmake-when-building-extension-for-3d-slicer/30803
**Category:** Development
**Tags:** build, python
**Created:** [July 26, 2023, 4:02pm UTC](https://discourse.slicer.org/t/issue-with-cmake-when-building-extension-for-3d-slicer/30803 "2023-07-26T16:02:11Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![haphantran](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/haphantran/32/18446_2.png) [@haphantran](https://discourse.slicer.org/u/haphantran)
#### Post date: [July 26, 2023, 4:02pm UTC](https://discourse.slicer.org/t/issue-with-cmake-when-building-extension-for-3d-slicer/30803/1 "2023-07-26T16:02:11Z")

</div>

Hi guys,  
I’m trying to build the extension using cmake gui on Windows  
[Extensions — 3D Slicer documentation](https://slicer.readthedocs.io/en/latest/developer_guide/extensions.html#windows)  
Here is the error:

> Blockquote  
> CMake Error: The source “C:/Users/hapha/OneDrive/Documents/python/SlicerTrack/CMakeLists.txt” does not match the source “C:/Users/hapha/OneDrive/Documents/python/SlicerTrack/Track/CMakeLists.txt” used to generate cache. Re-run cmake with a different source directory.

The error seems very generic so I have no idea where to fix. Please help me check this. Thank you.

Here is my folder structure

> Blockquote  
> tree -I ‘Data’  
> .  
> ├── CMakeLists.txt  
> ├── LICENSE  
> ├── README.md  
> ├── Track  
> │ ├── CMakeLists.txt  
> │ ├── README.md  
> │ ├── Resources  
> │ │ ├── Icons  
> │ │ │ ├── Track.png  
> │ │ │ └── media-control-icons  
> │ │ │ ├── next.png  
> │ │ │ ├── pause.png  
> │ │ │ ├── play.png  
> │ │ │ ├── previous.png  
> │ │ │ └── stop.png  
> │ │ └── UI  
> │ │ └── Track.ui  
> │ ├── Testing  
> │ │ ├── CMakeLists.txt  
> │ │ └── Python  
> │ │ └── CMakeLists.txt  
> │ ├── Track.py  
> │ ├── **pycache**  
> │ │ ├── Track.cpython-39.pyc  
> │ │ └── test.cpython-39.pyc  
> │ └── requirements.txt  
> ├── Track.png  
> ├── TrackingDataProcessor  
> │ ├── README.md  
> │ ├── TrackingDataProcessor.cpp  
> │ ├── TrackingDataProcessor.sln  
> │ └── TrackingDataProcessor.vcxproj  
> └── original\_UI.png

Here is the CMakeList.txt in main extension folder (SlicerTrack)

> Blockquote  
> cmake\_minimum\_required(VERSION 3.13.4)  
> project(Track)  
> set(EXTENSION\_HOMEPAGE “[https://slicertrack.github.io/](https://slicertrack.github.io/)”)  
> set(EXTENSION\_CATEGORY “Tracking”)  
> set(EXTENSION\_CONTRIBUTORS "HaPhan Tran, Mubariz Afzal ")  
> set(EXTENSION\_DESCRIPTION “Module providing tracking tools and displacement visualizations”)  
> set(EXTENSION\_ICONURL “[http://www.example.com/Slicer/Extensions/Track.png](http://www.example.com/Slicer/Extensions/Track.png)”)  
> set(EXTENSION\_SCREENSHOTURLS “[http://www.example.com/Slicer/Extensions/Track/Screenshots/1.png](http://www.example.com/Slicer/Extensions/Track/Screenshots/1.png)”)  
> set(EXTENSION\_DEPENDS “NA”) # Specified as a list or “NA” if no dependencies  
> find\_package(Slicer REQUIRED)  
> include(${Slicer\_USE\_FILE})  
> add\_subdirectory(Track)  
> include(${Slicer\_EXTENSION\_GENERATE\_CONFIG})  
> include(${Slicer\_EXTENSION\_CPACK})

Here is the cmake in the Track module

> Blockquote  
> #-----------------------------------------------------------------------------  
> set(MODULE\_NAME Track)  
> #-----------------------------------------------------------------------------  
> set(MODULE\_PYTHON\_SCRIPTS  
> ${MODULE\_NAME}.py  
> )  
> set(MODULE\_PYTHON\_RESOURCES  
> Resources/Icons/${MODULE\_NAME}.png  
> Resources/UI/${MODULE\_NAME}.ui  
> )  
> #-----------------------------------------------------------------------------  
> slicerMacroBuildScriptedModule(  
> NAME ${MODULE\_NAME}  
> SCRIPTS ${MODULE\_PYTHON\_SCRIPTS}  
> RESOURCES ${MODULE\_PYTHON\_RESOURCES}  
> WITH\_GENERIC\_TESTS  
> )  
> #-----------------------------------------------------------------------------  
> if(BUILD\_TESTING)  
> slicer\_add\_python\_unittest(SCRIPT ${MODULE\_NAME}.py)  
> add\_subdirectory(Testing)  
> endif()
