Open stanLec opened 10 months ago
I ran some tests today, and I can confirm that using USE_ITK_GDCM=ON
with vtkDICOM as a VTK remote module causes this error in find_package(ITK)
. Simply adding find_package(ITK)
to any of VTK's cmake files is enough to trigger the error, since this causes ITK to see VTK's zlib target directly instead of as "VTK::zlib". There might be some kind of namespace trick that will allow ITK to be used from VTK.
Things work if VTK is built without enabling the remote module, and then vtkDICOM is externally (since find_package(VTK)
sets up namespaces so that VTK's zlib and ITK's zlib don't collide).
As a follow-up, vtkDICOM builds as a remote module if I edit ITKTargets.cmake
and replace every occurrence of zlib
with ITK::zlib
. So that's a possible fix, but not a pretty one.
Thank you for your really quick answer. Could this behavior be documented, if it is not possible to fix ? I spent some time trying to figure out the issue. Meanwhile I will try to fix the issue by patching the ITKTargets.cmake as you suggested. I suppose that I can patch ITK repository to define ITK::zlib target instead of zlib target. EDIT: I did a dirty patch by renaming the zlib target in Modules/ThirdParty/ZLIB/CMakeLists.txt and in Modules/ThirdParty/ZLIB/src/itkzlib-ng/CMakeLists.txt in the ITK source code. It seems to resolve the conflict with VTK::zlib
Good morning, I tried to build VtkDicom as a VTK 9.0.1 remote module using the option USE_ITK_GDCM activated to avoid rebuilding GDCM since I use it also for ITK 5.3.
This is how i build ITK as an external project of my project
and VTK
I get a CMake error when building vtk Dicom when the find_package(ITK) is done, Zlib seems to be clashing between ITK and VTKDicom. We also build ZLib as an external library in the project. If I use the argument ITK_USE_SYSTEM_ZLIB for ITK I don't have the issue but the ZLib path in the CMake exported target of ITK is absolute and not relative to ITK project.
Do you have any leads about this error ? Thank you