ITK patches are not always used
Mantis Issue 1039, reported by gpasero, assigned to gpasero, created: 2015-04-30
The way ITK patches are used is imperfect because in some cases, the original ITK sources are used instead. Here is what I understood.
I will take the class itkUnaryFunctorImageFilter as an example. The directory containing patched header appears before the ITK include dir (I have checked this in the generated cmake build scripts). When the #include to itkUnaryFunctorImageFilter.h is located in a OTB source file, the good header is used (the patched header in OTB). When the #include to itkUnaryFunctorImageFilter.h is located in an ITK source file, the wrong header is used (the original ITK one).
The explanation is provided here : https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html. Basically, when using the syntax #include "file" , the directory containing the current source file is searched FIRST. Then, the directories specified with -I options are searched. Since all ITK headers are in the same location, the original itkUnaryFunctorImageFilter is found first.
1430415089 - gpaseroMy first guess to solve this is to add the include to the patched header (for instance : #include "itkUnaryFunctorImageFilter.h") in every OTB source file using it indirectly (and putting this include before other ITK includes).
This fix is not final because in future OTB code, the developers will have to remember : "ok, I indirectly used an ITK patched class, so I have to put a specific include first...".
However, it is possible to detect wrong includes on a test platform (just adding "#error" in the original ITK headers will do the job).
1430728024 - gpaseroFix to compile OTB without including original UnaryFunctorImageFilter : http://hg.orfeo-toolbox.org/OTB/rev/b7d3df26ed59
139 files affected ...