[ITK] How to avoid NIFTI header files from being installed?

Niels Dekker niels-xtk at xs4all.nl
Mon Sep 18 09:32:51 EDT 2017


>> However, when doing an INSTALL, nifti1.h and nifti1_io.h (as well as
>> itk_nifti_mangle.h) are still copied to the user's install directory

Matt McCormick replied:
> To avoid this, a CMake option, ITK_USE_SYSTEM_NIFTI could be set up
> similar to other third party modules. The CMake configuration code
> needs to be added to the module so it can find the system NIFTI and
> export the required build information to other modules.

Thanks for your reply, Matt! ITK_USE_SYSTEM_NIFTI might be interesting 
option.

However, I was thinking of a different problem: Suppose my application 
MyApp depends on both ITK (installed at the ITK_INSTALL_PREFIX 
directory), and "my own version" of niftilib. In this case, I want ITK 
to internally still use the ITK version of niftilib. MyApp has 
ITK_INSTALL_PREFIX/include/ITK-4.12 as one of its include directories. 
However, when a CXX file of MyApp does #include <nifti1.h>, it should 
#include the niftilib file from "my own version" of niftilib, not the 
one internally used by ITK!

Now I see there already exists a CMake option to stop ITK niftilib 
header files from being installed: NIFTI_INSTALL_NO_DEVELOPMENT  It's 
being used in the CMakeLists.txt files at 
ThirdParty\NIFTI\src\nifti\znzlib and 
ThirdParty\NIFTI\src\nifti\niftilib:
https://github.com/Kitware/ITK/blob/v4.12.2/Modules/ThirdParty/NIFTI/src/nifti/niftilib/CMakeLists.txt#L29

I was about to suggest to set NIFTI_INSTALL_NO_DEVELOPMENT ON by 
default. But now I see, "gifti_io.h" does #include <nifti1_io.h>:
https://github.com/Kitware/ITK/blob/v4.12.2/Modules/ThirdParty/GIFTI/src/gifticlib/gifti_io.h#L6

"gifti_io.h" is also copied to ITK_INSTALL_PREFIX, during an ITK 
install. So ITK users can only set NIFTI_INSTALL_NO_DEVELOPMENT ON when 
they do not need to #include this header file. And actually, 
"itkGiftiMeshIO.h" does #include "gifti_io.h":
https://github.com/Kitware/ITK/blob/v4.12.2/Modules/IO/Mesh/include/itkGiftiMeshIO.h#L27

This #include "gifti_io.h" could be hidden by moving the include 
statement from "itkGiftiMeshIO.h" to "itkGiftiMeshIO.cxx". That could be 
done by adding a "proxy mechanism" to itk::GiftiMeshIO, similar to what 
we added to itk::NiftiIO. Do you think that would be a good idea?


Kind regards, also on behalf of my colleague Floris Berendsen,

Niels
-- 
Niels Dekker
Scientific programmer
LKEB, Leiden University Medical Center, Netherlands


More information about the Community mailing list