conflict in Nifti library when building with ITK>=5.3
Building with system ITK (installed via conda, currently ITK 5.3), NiftyReg and ITK both use the nifti library and are not careful about conflicts, leading to
In file included from /home/kris/devel/install/include/nifti1_io.h:18,
from /home/kris/devel/install/include/_reg_maths.h:22,
from /home/kris/devel/install/include/_reg_tools.h:20,
from /home/kris/devel/buildConda/sources/SIRF/src/Registration/cReg/include/sirf/Reg/NiftiImageData.h:40,
from /home/kris/devel/buildConda/sources/SIRF/src/Registration/cReg/include/sirf/Reg/NiftiImageData3D.h:32,
from /home/kris/devel/buildConda/sources/SIRF/src/Synergistic/cSyn/utilities.cpp:34:
/home/kris/devel/install/include/nifti1.h:144:11: error: redefinition of 'struct nifti_1_header'
144 | struct nifti_1_header
| ^~~~~~~~~~~~~~
In file included from /home/kris/miniconda3/envs/cilsirfbuild/include/ITK-5.3/nifti1_io.h:18,
from /home/kris/devel/buildConda/sources/SIRF/src/Registration/cReg/include/sirf/Reg/NiftiImageData.h:32:
/home/kris/miniconda3/envs/cilsirfbuild/include/ITK-5.3/nifti1.h:148:8: note: previous definition of 'struct nifti_1_header'
148 | struct nifti_1_header { /* NIFTI-1 usage */ /* ANALYZE 7.5 field(s) */
| ^~~~~~~~~~~~~~
I'm not sure though why ITK is in the include path here.
More investigation shows that
- ITK updated its nifti version here https://github.com/InsightSoftwareConsortium/ITK/commit/9c2c9fa9b8e8c83fd60fc09f7695990b33df4bb6, which was first incorporated in ITK 5.3
- ITK is in the include path because STIR uses
include(${ITK_USE_FILE}), and that usesinclude_directories, which is an ITK issue https://github.com/InsightSoftwareConsortium/ITK/issues/1450 (flagged by @rijobro !).
Some more info in https://github.com/KCL-BMEIS/niftyreg/issues/117.
We currently are limited to ITK<=5.2 therefore, until either NiftyReg updates, https://github.com/InsightSoftwareConsortium/ITK/issues/1450 gets fixed, or https://github.com/UCL/STIR/pull/1518 gets merged (and we require it). Luckily, the latter seems simple...
https://github.com/UCL/STIR/pull/1518 is merged, so I think this problem will disappear (for us). STIR 6.3 should be released soon I hope. We could possibly come up with some complicated check that if STIR < 6.3 and ITK >= 5.3, we issue a warning. Not so sure where/how though.
@paskino what about adding a test-case where we install as much stuff as we can via conda, based on https://github.com/SyneRBI/SIRF/wiki/Building-SIRF-and-CIL-with-conda. This would have shown this problem, and of course it'd also be a good way to finally start moving on a conda install for SIRF.
Likely we'll have some problems with Gadgetron of course.