Include and compile itk, vtk as an ExternalProject or Submodule

weidonglian
Sun, 07 Apr 2024 19:25:40 +0000
Development

In my c++ application, I need to use both itk, vtk and qt. In order to make the development reproducible without build itk/vtk as a seperate cmake project which definitely has a lot overhead.
I have tried so far add itk/vtk as submodule into my third_party/itk and third_party/vtk folder. It ended up the following conflict targets (zlib, h5detect, such), as below. I also tried to use the CMake’s new feature FetchContent instead of ExternalProject_Add, I got the same error as below. I reckon the FetchContent and FetchContent_MakeAvailable works the same as my submodule solution.
Any suggestion to mitigate this limitation? I do not want to hack into vtk and change those target name or CMP0002.
Thanks in advanced,
Weidong

CMake Error at build/_deps/vtk-src/CMake/vtkModule.cmake:3829 (add_library):
  add_library cannot create target "zlib" because another target with the
  same name already exists.  The existing target is a static library created
  in source directory
  "/home/weidong/develop/brain-flow-app/build/_deps/itk-src/Modules/ThirdParty/ZLIB/src/itkzlib-ng".
  See documentation for policy CMP0002 for more details.
Call Stack (most recent call first):
  build/_deps/vtk-src/ThirdParty/zlib/vtkzlib/CMakeLists.txt:118 (vtk_module_add_module)


CMake Warning at build/_deps/vtk-src/Rendering/OpenGL2/CMakeLists.txt:408 (message):
  X11::Xcursor not found; custom cursors will be ignored.


CMake Error at build/_deps/vtk-src/ThirdParty/hdf5/vtkhdf5/src/CMakeLists.txt:1067 (add_executable):
  add_executable cannot create target "H5detect" because another target with
  the same name already exists.  The existing target is an executable created
  in source directory
  "/home/weidong/develop/brain-flow-app/build/_deps/itk-src/Modules/ThirdParty/HDF5/src/itkhdf5/src".
  See documentation for policy CMP0002 for more details.


CMake Error at build/_deps/vtk-src/ThirdParty/hdf5/vtkhdf5/src/CMakeLists.txt:1128 (add_executable):
  add_executable cannot create target "H5make_libsettings" because another
  target with the same name already exists.  The existing target is an
  executable created in source directory
  "/home/weidong/develop/brain-flow-app/build/_deps/itk-src/Modules/ThirdParty/HDF5/src/itkhdf5/src".
  See documentation for policy CMP0002 for more details.

3 posts - 2 participants