Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VTK - ITK - HDF5 Conflicts and are unusable together #15502

Closed
dweckmann opened this issue Jan 7, 2021 · 7 comments
Closed

VTK - ITK - HDF5 Conflicts and are unusable together #15502

dweckmann opened this issue Jan 7, 2021 · 7 comments
Assignees
Labels
category:port-bug The issue is with a library, which is something the port should already support

Comments

@dweckmann
Copy link
Contributor

dweckmann commented Jan 7, 2021

Describe the bug

Using both VTK and ITK in a project leads to strange problem around hdf5 when calling FindPackage(ITK ...):

CMake Error at E:/Work/vcpkg/installed/x64-windows/share/hdf5/hdf5-targets.cmake:37 (message):
  Some (but not all) targets in this export set were already defined.

  Targets Defined: hdf5::hdf5-shared;hdf5::hdf5_hl-shared

  Targets not yet defined: hdf5::hdf5_cpp-shared;hdf5::hdf5_hl_cpp-shared

Call Stack (most recent call first):
  E:/Work/vcpkg/installed/x64-windows/share/hdf5/hdf5-config.cmake:146 (include)
  E:/Work/vcpkg/installed/x64-windows/share/hdf5/vcpkg-cmake-wrapper.cmake:17 (_find_package)
  E:/Work/vcpkg/scripts/buildsystems/vcpkg.cmake:585 (include)
  E:/Work/vcpkg/installed/x64-windows/share/itk/Modules/ITKHDF5.cmake:15 (find_package)
  E:/Work/vcpkg/installed/x64-windows/share/itk/ITKModuleAPI.cmake:76 (include)
  E:/Work/vcpkg/installed/x64-windows/share/itk/ITKModuleAPI.cmake:31 (itk_module_load)
  E:/Work/vcpkg/installed/x64-windows/share/itk/ITKModuleAPI.cmake:129 (_itk_module_config_recurse)
  E:/Work/vcpkg/installed/x64-windows/share/itk/ITKConfig.cmake:81 (itk_module_config)
  E:/Work/vcpkg/scripts/buildsystems/vcpkg.cmake:634 (_find_package)
  libs/registration/itkRegistrationOp/CMakeLists.txt:3 (find_package)

Environment

  • OS: Windows 10
  • Compiler: Microsoft (R) C/C++ Optimizing Compiler Version 19.28.29335 for x64

To Reproduce
Steps to reproduce the behavior:

  1. use cmake
find_package(ITK QUIET COMPONENTS ITKOptimizersv4 ITKTransform REQUIRED)
target_link_libraries(${FWPROJECT_NAME} PUBLIC ITKOptimizersv4 ITKTransform)

Additional context

The error message come from hdf5, but this seems to be linked with VTK, since it provides its own FindHDF5.cmake in which the missing targets (hdf5::hdf5_cpp-shared;hdf5::hdf5_hl_cpp-shared) are not present.

BTW, removing the VTK FindHDF5.cmake 'fixes' the problem as cmake use the right hdf5-config.cmake from hdf5 instead of the one from VTK.

Still, I have also issues with lz4 (already reported in #14978) and also PEGTL:

CMake Error at E:/Work/vcpkg/installed/x64-windows/share/vtk/FindPEGTL.cmake:26 (set_target_properties):
  Attempt to promote imported target "taocpp::pegtl" to global scope (by
  setting IMPORTED_GLOBAL) which is not built in this directory.
Call Stack (most recent call first):
  E:/Work/vcpkg/scripts/buildsystems/vcpkg.cmake:634 (_find_package)
  E:/Work/vcpkg/installed/x64-windows/share/vtk/VTK-vtk-module-find-packages.cmake:538 (find_package)
  E:/Work/vcpkg/installed/x64-windows/share/vtk/vtk-config.cmake:129 (include)
  E:/Work/vcpkg/scripts/buildsystems/vcpkg.cmake:634 (_find_package)
  E:/Work/vcpkg/installed/x64-windows/share/itk/Modules/ITKVtkGlue.cmake:16 (find_package)
  E:/Work/vcpkg/installed/x64-windows/share/itk/ITKModuleAPI.cmake:76 (include)
  E:/Work/vcpkg/installed/x64-windows/share/itk/ITKModuleAPI.cmake:31 (itk_module_load)
  E:/Work/vcpkg/installed/x64-windows/share/itk/ITKModuleAPI.cmake:129 (_itk_module_config_recurse)
  E:/Work/vcpkg/installed/x64-windows/share/itk/ITKConfig.cmake:81 (itk_module_config)
  E:/Work/vcpkg/scripts/buildsystems/vcpkg.cmake:634 (_find_package)
  libs/registration/itkRegistrationOp/CMakeLists.txt:3 (find_package)

Using the same kind of fix as for lz4 should also work...

@dweckmann dweckmann changed the title VTK - ITK - HDF5 Conflicts and make then unusable VTK - ITK - HDF5 Conflicts and are unusable together Jan 7, 2021
@Neumann-A
Copy link
Contributor

Neumann-A commented Jan 7, 2021

add_library(hdf5::hdf5 ALIAS hdf5::hdf5-(static|shared))
needs to be replaced with a
add_library(hdf5::hdf5 INTERFACE IMPORTED)
and setting the INTERFACE_LINK_PROPERTIES to link against one of the hdf5 targets instead of promoting the targets to global scope. Same for LZ4 and PEGTL

fix is described in #14978 (comment)

@dweckmann
Copy link
Contributor Author

Thanks, I will test that. Should I do A PR for that ?

@Neumann-A
Copy link
Contributor

if you have it fixed why not?

@JackBoosY JackBoosY self-assigned this Jan 8, 2021
@JackBoosY JackBoosY added the category:port-bug The issue is with a library, which is something the port should already support label Jan 8, 2021
@drescherjm
Copy link

I believe I have the original issue reported here. I see that the pull request wasn't merged due to a problem.

@qaler
Copy link

qaler commented Nov 22, 2021

I have the same problem here, luckily apply dweckmann's patch works for me.

@Eric-JH
Copy link

Eric-JH commented Apr 8, 2022

I have the same problem on hdf5. And I delete the ports/vtk/FindHDF5.cmake. But it doesn't work. Is there any suggestion?

@LilyWangLL LilyWangLL assigned JonLiu1993 and unassigned JackBoosY Dec 6, 2022
@JonLiu1993
Copy link
Member

Fixed by PR #23352.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants