diff --git a/CMake/ITKModuleMacros.cmake b/CMake/ITKModuleMacros.cmake index 2dcf9a264fa..0b3066d4fcd 100644 --- a/CMake/ITKModuleMacros.cmake +++ b/CMake/ITKModuleMacros.cmake @@ -226,6 +226,8 @@ macro(itk_module_impl) set(_export_header_file "${${itk-module}_BINARY_DIR}/include/${itk-module}Export.h") endif() + set(_export_custom_content [=[#include "itkNamespace.h"]=]) + # Generate the export macro header for symbol visibility/Windows DLL declspec generate_export_header( ${itk-module} @@ -236,7 +238,9 @@ macro(itk_module_impl) NO_EXPORT_MACRO_NAME ${itk-module}_HIDDEN STATIC_DEFINE - ITK_STATIC) + ITK_STATIC + CUSTOM_CONTENT_FROM_VARIABLE + _export_custom_content) install( FILES ${_export_header_file} DESTINATION ${${itk-module}_INSTALL_INCLUDE_DIR} diff --git a/Modules/Core/Common/CMakeLists.txt b/Modules/Core/Common/CMakeLists.txt index d249464b0d4..756ecebc007 100644 --- a/Modules/Core/Common/CMakeLists.txt +++ b/Modules/Core/Common/CMakeLists.txt @@ -129,6 +129,7 @@ set(ITK_USE_TBB ${Module_ITKTBB}) configure_file(src/itkConfigure.h.in itkConfigure.h) configure_file(src/itkConfigurePrivate.h.in itkConfigurePrivate.h) +configure_file(src/itkNamespace.h.in itkNamespace.h) set(ITKCommon_INCLUDE_DIRS ${ITKCommon_BINARY_DIR}) set(ITKCommon_LIBRARIES ITKCommon) @@ -137,5 +138,6 @@ itk_module_impl() install( FILES ${ITKCommon_BINARY_DIR}/itkConfigure.h + ${ITKCommon_BINARY_DIR}/itkNamespace.h DESTINATION ${ITKCommon_INSTALL_INCLUDE_DIR} COMPONENT Development) diff --git a/Modules/Core/Common/include/itkBitCast.h b/Modules/Core/Common/include/itkBitCast.h index 32798227df1..c4419f8e9c6 100644 --- a/Modules/Core/Common/include/itkBitCast.h +++ b/Modules/Core/Common/include/itkBitCast.h @@ -19,6 +19,8 @@ #ifndef itkBitCast_h #define itkBitCast_h +#include "itkNamespace.h" + #include // For memcpy. #include // For is_trivially_copyable and remove_const_t. diff --git a/Modules/Core/Common/include/itkBoolean.h b/Modules/Core/Common/include/itkBoolean.h index 9fdb636a0ed..2346ab1f9eb 100644 --- a/Modules/Core/Common/include/itkBoolean.h +++ b/Modules/Core/Common/include/itkBoolean.h @@ -18,6 +18,8 @@ #ifndef itkBoolean_h #define itkBoolean_h +#include "itkNamespace.h" + namespace itk { diff --git a/Modules/Core/Common/include/itkMakeFilled.h b/Modules/Core/Common/include/itkMakeFilled.h index 142f67d4f49..4125592dfc5 100644 --- a/Modules/Core/Common/include/itkMakeFilled.h +++ b/Modules/Core/Common/include/itkMakeFilled.h @@ -18,6 +18,8 @@ #ifndef itkMakeFilled_h #define itkMakeFilled_h +#include "itkNamespace.h" + namespace itk { /** Yields a container of the specified type, filled by the specified value, assigned to each of its elements. diff --git a/Modules/Core/Common/include/itkMakeUniqueForOverwrite.h b/Modules/Core/Common/include/itkMakeUniqueForOverwrite.h index ef6754ebc81..a4e9b78d6ea 100644 --- a/Modules/Core/Common/include/itkMakeUniqueForOverwrite.h +++ b/Modules/Core/Common/include/itkMakeUniqueForOverwrite.h @@ -22,6 +22,8 @@ #include // For unique_ptr. #include // For remove_extent_t, false_type, etc. +#include "itkNamespace.h" + namespace itk { diff --git a/Modules/Core/Common/include/itkPrintHelper.h b/Modules/Core/Common/include/itkPrintHelper.h index bcb37ad5924..00f676e93ba 100644 --- a/Modules/Core/Common/include/itkPrintHelper.h +++ b/Modules/Core/Common/include/itkPrintHelper.h @@ -33,6 +33,8 @@ # undef ITK_CASTXML_GCC_VECTOR_WORKAROUND #endif +#include "itkNamespace.h" + namespace itk { diff --git a/Modules/Core/Common/src/itkConfigure.h.in b/Modules/Core/Common/src/itkConfigure.h.in index a427cddb588..cc5d63033fc 100644 --- a/Modules/Core/Common/src/itkConfigure.h.in +++ b/Modules/Core/Common/src/itkConfigure.h.in @@ -18,6 +18,8 @@ #ifndef itkConfigure_h #define itkConfigure_h +#include "itkNamespace.h" + /* * here is where system computed values get stored these values should only * change when the target compile platform changes diff --git a/Modules/Core/Common/src/itkNamespace.h.in b/Modules/Core/Common/src/itkNamespace.h.in new file mode 100644 index 00000000000..cb4f580add1 --- /dev/null +++ b/Modules/Core/Common/src/itkNamespace.h.in @@ -0,0 +1,28 @@ +/*========================================================================= + * + * Copyright NumFOCUS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + *=========================================================================*/ +#ifndef itkNamespace_h +#define itkNamespace_h + +#define ITK_NAMESPACE_IS_NOT_ITK +#define ITK_NAMESPACE slicer_itk + +#if defined(ITK_NAMESPACE_IS_NOT_ITK) && !defined(itk) +#define itk ITK_NAMESPACE +#endif + +#endif //itkNamespace_h diff --git a/Modules/Core/Common/test/itkRangeGTestUtilities.h b/Modules/Core/Common/test/itkRangeGTestUtilities.h index 13c6029c54c..eb335f39cb4 100644 --- a/Modules/Core/Common/test/itkRangeGTestUtilities.h +++ b/Modules/Core/Common/test/itkRangeGTestUtilities.h @@ -24,6 +24,8 @@ #include // For move. #include // For begin and end. +#include "itkNamespace.h" + namespace itk { // Utilities for GoogleTest unit tests of iterator ranges. diff --git a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshMacro.h b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshMacro.h index 894e54e8a15..1a6002471f3 100644 --- a/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshMacro.h +++ b/Modules/Core/QuadEdgeMesh/include/itkQuadEdgeMeshMacro.h @@ -18,6 +18,8 @@ #ifndef itkQuadEdgeMeshMacro_h #define itkQuadEdgeMeshMacro_h +#include "itkNamespace.h" + namespace itk { ////////////////////////////////////////////////////////////////////////////// diff --git a/Modules/Core/SpatialObjects/include/itkSpatialObjectExport.h b/Modules/Core/SpatialObjects/include/itkSpatialObjectExport.h index 16810a4da81..72a3a8f0c54 100644 --- a/Modules/Core/SpatialObjects/include/itkSpatialObjectExport.h +++ b/Modules/Core/SpatialObjects/include/itkSpatialObjectExport.h @@ -32,4 +32,6 @@ # define ITKSpatialObjectExport #endif +#include "itkNamespace.h" + #endif diff --git a/Modules/Filtering/FastMarching/include/itkNodePair.h b/Modules/Filtering/FastMarching/include/itkNodePair.h index bcc58b03aff..e5937e48c41 100644 --- a/Modules/Filtering/FastMarching/include/itkNodePair.h +++ b/Modules/Filtering/FastMarching/include/itkNodePair.h @@ -21,6 +21,8 @@ #include +#include "itkNamespace.h" + namespace itk { /** diff --git a/Modules/Filtering/LabelMap/include/itkLabelObjectLineComparator.h b/Modules/Filtering/LabelMap/include/itkLabelObjectLineComparator.h index 3b31843237c..d312143bfa3 100644 --- a/Modules/Filtering/LabelMap/include/itkLabelObjectLineComparator.h +++ b/Modules/Filtering/LabelMap/include/itkLabelObjectLineComparator.h @@ -18,6 +18,8 @@ #ifndef itkLabelObjectLineComparator_h #define itkLabelObjectLineComparator_h +#include "itkNamespace.h" + namespace itk { namespace Functor diff --git a/Modules/IO/MRC/src/itkMRCImageIOPrivate.h b/Modules/IO/MRC/src/itkMRCImageIOPrivate.h index ccfb286c701..9e8154d1e9d 100644 --- a/Modules/IO/MRC/src/itkMRCImageIOPrivate.h +++ b/Modules/IO/MRC/src/itkMRCImageIOPrivate.h @@ -20,6 +20,8 @@ #include +#include "itkNamespace.h" + /* * This code was contributed in the Insight Journal paper: * "A Streaming IO Base Class and Support for Streaming the MRC and VTK File Format" diff --git a/Modules/ThirdParty/Expat/src/expat/CMakeLists.txt b/Modules/ThirdParty/Expat/src/expat/CMakeLists.txt index 48c8d745bf6..f49eb08c42a 100644 --- a/Modules/ThirdParty/Expat/src/expat/CMakeLists.txt +++ b/Modules/ThirdParty/Expat/src/expat/CMakeLists.txt @@ -178,7 +178,7 @@ CONFIGURE_FILE(${ITK3P_EXPAT_SOURCE_DIR}/expatDllConfig.h.in configure_file(expat_config.h.cmake "${ITK3P_EXPAT_BINARY_DIR}/expat_config.h") -set(MANGLE_PREFIX itk_expat) +set(MANGLE_PREFIX slicer_itk) configure_file(itk_expat_mangle.h.in "${ITK3P_EXPAT_BINARY_DIR}/itk_expat_mangle.h" @ONLY) diff --git a/Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeLists.txt b/Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeLists.txt index 90b04e1a2e9..83cc9466258 100644 --- a/Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeLists.txt +++ b/Modules/ThirdParty/HDF5/src/itkhdf5/src/CMakeLists.txt @@ -4,7 +4,7 @@ cmake_minimum_required (VERSION 3.12) project (HDF5_SRC C) # ITK --start -set(MANGLE_PREFIX itk) +set(MANGLE_PREFIX slicer_itk) configure_file(${HDF5_SRC_DIR}/itk_hdf5_mangle.h.in ${HDF5_SRC_BINARY_DIR}/itk_hdf5_mangle.h @ONLY) diff --git a/Modules/ThirdParty/JPEG/src/itkjpeg/CMakeLists.txt b/Modules/ThirdParty/JPEG/src/itkjpeg/CMakeLists.txt index a6251376a84..08290657313 100644 --- a/Modules/ThirdParty/JPEG/src/itkjpeg/CMakeLists.txt +++ b/Modules/ThirdParty/JPEG/src/itkjpeg/CMakeLists.txt @@ -50,7 +50,7 @@ endif(WIN32) configure_file(${ITK3P_JPEG_SOURCE_DIR}/jpegDllConfig.h.in ${ITK3P_JPEG_BINARY_DIR}/jpegDllConfig.h) -set(MANGLE_PREFIX itk_jpeg) +set(MANGLE_PREFIX slicer_itk) configure_file(${ITK3P_JPEG_SOURCE_DIR}/itk_jpeg_mangle.h.in ${ITK3P_JPEG_BINARY_DIR}/itk_jpeg_mangle.h @ONLY) diff --git a/Modules/ThirdParty/NrrdIO/src/NrrdIO/CMakeLists.txt b/Modules/ThirdParty/NrrdIO/src/NrrdIO/CMakeLists.txt index c70ca0f7e70..5093cc0bb72 100644 --- a/Modules/ThirdParty/NrrdIO/src/NrrdIO/CMakeLists.txt +++ b/Modules/ThirdParty/NrrdIO/src/NrrdIO/CMakeLists.txt @@ -31,7 +31,7 @@ INCLUDE_DIRECTORIES( ${ITK3P_NrrdIO_BINARY_DIR} ) -set(MANGLE_PREFIX itk) +set(MANGLE_PREFIX slicer_itk) configure_file(${ITK3P_NrrdIO_SOURCE_DIR}/itk_NrrdIO_mangle.h.in ${ITK3P_NrrdIO_BINARY_DIR}/itk_NrrdIO_mangle.h @ONLY) diff --git a/Modules/ThirdParty/OpenJPEG/src/openjpeg/CMakeLists.txt b/Modules/ThirdParty/OpenJPEG/src/openjpeg/CMakeLists.txt index e62e43eda21..78c0b8b9ea9 100644 --- a/Modules/ThirdParty/OpenJPEG/src/openjpeg/CMakeLists.txt +++ b/Modules/ThirdParty/OpenJPEG/src/openjpeg/CMakeLists.txt @@ -68,7 +68,7 @@ CONFIGURE_FILE(${ITK3P_OpenJPEG_SOURCE_DIR}/opj_configure.h.in # configure name mangling to allow multiple libraries to coexist # peacefully if(EXISTS ${ITK3P_OpenJPEG_SOURCE_DIR}/openjpeg_mangle.h.in) -set(MANGLE_PREFIX itk) +set(MANGLE_PREFIX slicer_itk) configure_file(${ITK3P_OpenJPEG_SOURCE_DIR}/openjpeg_mangle.h.in ${ITK3P_OpenJPEG_BINARY_DIR}/openjpeg_mangle.h @ONLY) diff --git a/Modules/ThirdParty/PNG/src/itkpng/CMakeLists.txt b/Modules/ThirdParty/PNG/src/itkpng/CMakeLists.txt index ba064506cac..3daeeed3944 100644 --- a/Modules/ThirdParty/PNG/src/itkpng/CMakeLists.txt +++ b/Modules/ThirdParty/PNG/src/itkpng/CMakeLists.txt @@ -30,7 +30,7 @@ endif(WIN32) configure_file(${ITK3P_PNG_SOURCE_DIR}/pngDllConfig.h.in ${ITK3P_PNG_BINARY_DIR}/pngDllConfig.h) -set(MANGLE_PREFIX itk_png) +set(MANGLE_PREFIX slicer_itk) configure_file(${ITK3P_PNG_SOURCE_DIR}/itk_png_mangle.h.in ${ITK3P_PNG_BINARY_DIR}/itk_png_mangle.h @ONLY) diff --git a/Modules/ThirdParty/TIFF/src/itktiff/CMakeLists.txt b/Modules/ThirdParty/TIFF/src/itktiff/CMakeLists.txt index b41f921cb5c..967d6ce2064 100644 --- a/Modules/ThirdParty/TIFF/src/itktiff/CMakeLists.txt +++ b/Modules/ThirdParty/TIFF/src/itktiff/CMakeLists.txt @@ -109,7 +109,7 @@ configure_file(${ITK3P_TIFF_SOURCE_DIR}/tiffDllConfig.h.in configure_file(${ITK3P_TIFF_SOURCE_DIR}/tif_config.h.in ${ITK3P_TIFF_BINARY_DIR}/itk_tif_config.h) -set(MANGLE_PREFIX itk_tiff) +set(MANGLE_PREFIX slicer_itk) configure_file(${ITK3P_TIFF_SOURCE_DIR}/itk_tiff_mangle.h.in ${ITK3P_TIFF_BINARY_DIR}/itk_tiff_mangle.h @ONLY)