I am trying to build SimpleITK ( branch master ) with a system version of HDF5 ( v1.10.5 )
I cloned ITK ( on branch master ), and successfully built it while linking to the system HDF5.
When I try to configure/generate SimpleITK with the system ITK and system HDF5, I get the following error:
CMake Error at Code/IO/src/CMakeLists.txt:21 (add_library):
Target "SimpleITKIO" links to target "hdf5::hdf5_cpp" but the target was
not found. Perhaps a find_package() call is missing for an IMPORTED
target, or an ALIAS target is missing?
CMake Error at Code/IO/src/CMakeLists.txt:21 (add_library):
Target "SimpleITKIO" links to target "hdf5::hdf5" but the target was not
found. Perhaps a find_package() call is missing for an IMPORTED target, or
an ALIAS target is missing?
I have used RelWithDebInfo symbols for HDF5, ITK, and SimpleITK in case that makes a difference.
I am running Centos7 , with gcc 7.3.1
I’ve searched for a few days now, and am unable to get past this. Any help is greatly appreciated.
I added the find_package(Threads) and gtest_disable_pthreads ON to the ITK and SimpleITK CMakeLists.txt. It allows me to get past the Threads::Threads error. More details below.
Please advise if there is a better way to do this.
Using :
CMake v3.19.4
HDF5 1.10.5
ITK v5.1.2
SimpleITK v2.0.2
SWIG 4.1.0
LUA 5.3.5
Cloned ITK ( v5.1.2 ) and modified the ITK/CMakeLists.txt with : #----------------------------------------------------------------------
Generate ITKConfig.cmake for the build tree.
+find_package(Threads)
+set(gtest_disable_pthreads ON CACHE INTERNAL “”)
and installed with the following cmake config:
* CMAKE_BUILD_TYPE RELEASE
* CMAKE_SKIP_INSTALL_RPATH ON
* CMAKE_SKIP_RPATH ON
* Module_ITKIOTransformMINC ON
* Module_ITKReview ON
* Module_SimpleITKFilters ON
* Module_SimpleITKFilters_GIT_TA a2101c137d2c99cf32b2d9600b1e4c3e14722a16
* ITK_USE_SYSTEM_LIBRARIES ON
* ITK_USE_SYSTEM_HDF5 ON
* CMAKE_PREFIX_PATH /opt/ITK-prefix
Install SWIG and LUA. I used versions 4.1.0, and 5.3.5 respectively
Cloned SimpleITK( v2.0.2 ) and modified the CMakeLists.txt :
message(STATUS “Building SimpleITK version "${SimpleITK_VERSION}"”)
+find_package(Threads)
+set(gtest_disable_pthreads ON CACHE INTERNAL “”)
Great job tracking down the problem and following up with posting the solution
Have you checked building if the ITK patch is still needed if you use ITK 5.2rc1?
If you are installing SimpleITK into the system, then it frequently makes since to have CMAKE_SKIP_INSTALL_RPATH=ON.
The initial post reports the error with hdf5::hdf5 missing, but the follow up mentions Threads::Threads and GTest. Have you enabled testing when building SimpleITK?
I suspect that the system HDF5 is not correctly exporting the transitive “Threads::Threads” dependency.
Thanks, thought it might help someone down the road.
I will give ITK 5.2rc1 a shot, as these build instructions will be needed by other devs on my project, and in our CICD system. Hopefully it works as ideally, I don’t want to make any changes to a cloned library, other than it’s CMake config.
No, I had BUILD_TESTING OFF.
Though you bring up a good point about the transitive “Threads::Threads” dependency. We had some issues installing HDF5 1.10.5 with CMake correctly on different platforms (Centos, Ubuntu). We had to install with ./configure for the HDF5 installation to work on both platforms.
The HDF5 CMake information wasn’t clear at the time, but I may need to look into it again. Especially with the updated targets with newer versions of CMake.
For some reason the generated headers required for the SimpleITK build includes the following.
In file: SimpleITK-build/Code/BasicFilters/include/SimpleITKBasicFiltersGeneratedHeaders.i
%include "sitkCoherenceEnhancingDiffusionImageFilter.h"
%include "sitkLabelSetDilateImageFilter.h"
%include "sitkLabelSetErodeImageFilter.h"
From my understanding these headers are generated from the ITK Modules Module_AnisotropicDiffusionLBR and Module_LabelErodeDilate which are not turned ON by default in the SuperBuild. So I didn’t enable it when building a non-SuperBuild ITK.
These are the modules I enabled in ITK:
Module_SimpleITKFilters ON
Module_ITKIOTransformMINC ON
Module_ITKReview ON
When I compare against the SuperBuild’s SimpleITK-build directroy those headers are not included in the SimpleITKBasicFiltersGeneratedHeaders.i.
So, I just deleted the %include lines in SimpleITKBasicFiltersGeneratedHeaders.i and the non-SuperBuild ran to completion. Allowing me to use the libraries in my app.