# Adding support for customizing ITK namespace

**URL:** <https://discourse.itk.org/t/adding-support-for-customizing-itk-namespace/5170>\
**Category:** Uncategorized\
**Created:** [July 8, 2022, 6:02pm UTC](https://discourse.itk.org/t/adding-support-for-customizing-itk-namespace/5170 "2022-07-08T18:02:51Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![jcfr](https://discourse.itk.org/user_avatar/discourse.itk.org/jcfr/32/2526_2.png) [@jcfr](https://discourse.itk.org/u/jcfr)\
**Post date:** [October 11, 2022, 4:52am UTC](https://discourse.itk.org/t/adding-support-for-customizing-itk-namespace/5170/9 "2022-10-11T04:52:42Z")

</div>

## Updates

- The Slicer pull request [#6564](https://github.com/Slicer/Slicer/pull/6564) adding support for ITK custom namespace has been integrated into Slicer.

- Use of functionality relying on either ITK C++ or SimpleITK python package built within Slicer and against the customer ITK are working on macOS/Linux/Windows.

- Use of filter like `discrete_gaussian_image_filter` provided by the ITK Python package [itk 5.3rc4.post3](https://pypi.org/project/itk/5.3rc4.post3/#files) installed from PyPI is working on Linux and Windows. An issue has been identified on macOS and is been discussed under a different topic [here](https://discourse.itk.org/t/itk-5-3rc4-post3-failure-to-load-libtbb-library-observed-on-macos-10-13/5405).

## Implementation

`Slicer/ITK` has been updated in [Slicer/ITK@69e52f05c](https://github.com/Slicer/ITK/commit/69e52f05c482012b95228c3fe46f299b1735ca99). In a nutshell, the `itkNamespace.h` header was introduced. It provides the logic for redefining “itk” only if a custom namespace has been provided. This ensures that the default behavior remains unchanged.

To minimize the number of files to update, the `itkNamespace.h` may be included  
through three mechanisms:

(1) Through `itkConfigure.h`: included either directly or indirectly by most files

(2) Through Export header: support case of header like `itkFEMSolution.h` only including the export header

(3) Through explicit include: support case of header without any includes (e.g `itkMakeFilled.h`)

cc: @dzenanz @matt.mccormick

Similarly, `Slicer/SimpleITK` has also been updated introducing `sitkNamespace.h`. See [Slicer/SimpleITK@c7f151412](https://github.com/Slicer/SimpleITK/commit/c7f151412205e086a47bfa5d521ec6beec481218).

cc: @blowekamp

## Next steps

The implementation associated with `Slicer/ITK` and `Slicer/SimpleITK` unconditionally define:

- `ITK_NAMESPACE_IS_NOT_ITK` and `ITK_NAMESPACE` as `slicer_itk` (see [Modules/Core/Common/src/itkNamespace.h.in](https://github.com/Slicer/ITK/commit/69e52f05c482012b95228c3fe46f299b1735ca99#diff-1e36d3fc7e859d4435e48c6c9cc16a4c6944d74e2e426c7fe9233fb62a80942c))
- `SITK_ITK_NAMESPACE_IS_NOT_ITK` and `SITK_ITK_NAMESPACE` as `slicer_itk` (see [Code/Common/src/sitkNamespace.h.in](https://github.com/Slicer/SimpleITK/commit/c7f151412205e086a47bfa5d521ec6beec481218#diff-bafa95498da66a1a80d0bab703aa8d54d88185d4dcff539396fccf6b3b916183) )

Logic should be generalized by introducing the CMake options `ITK_NAMESPACE` and `SITK_ITK_NAMESPACE`, if associated value is `itk` … no re-definition should happen.

Within ITK, mangling logic should be applied to remaining third party (zlib, gdcm, …) (thanks @dzenanz for the suggestion)

---

_[View the full topic](https://discourse.itk.org/t/adding-support-for-customizing-itk-namespace/5170)._
