I found I couldn't install ITK on Windows 10 if VTK has already been installed. Seems to be down to the hdf5 dependency, it's mentioned in the comments of the ITK portfile.
Windows 10, Version 1709.
The steps to reproduce: vcpkg install vtk, add disable_parallel_configure vcpkg install itk
OR more specifically: vcpkg install hdf5[cpp], add disable_parallel_configure vcpkg install itk
The outcome you expected: Install successful
The actual outcome: BUILD_FAILED
-- Building x64-windows-dbg
CMake Error at scripts/cmake/vcpkg_build_cmake.cmake:170 (message):
Command failed: C:/vcpkg/downloads/tools/cmake-3.11.4-windows/cmake-3.11.4-win32-x86/bin/cmake.exe;--build;.;--config;Debug;--target;install;--;-v;-j1
Working Directory: C:/vcpkg/buildtrees/itk/x64-windows-dbg
See logs for more information:
C:\vcpkg\buildtrees\itk\install-x64-windows-dbg-out.log
install-x64-windows-dbg-out.log
C:\vcpkg\installed\x64-windows\include\H5Tpkg.h(23): fatal error C1189: #error: "Do not include this file outside the H5T package!"
I tried specifying HDF5[cpp] as a build dependency for ITK. BUILD_FAILED, problems with the hdf5-static target. install-x64-windows-dbg-out.log. Adding a patch to help find the targets seemed to work for me, but only occasionally.
I am having better luck by ensuring that ITK/VTK build HDF5 on their own. I have no idea whether or not this is the right way to go, though.
@sarthakpati
The preferred way is to consume HDF5 (and generally any dependencies) from vcpkg. This ensures that any dependency is consistent across all libraries consuming it.
@alexkaratarakis of course I agree with this, but I haven't found a way to get the builds working that way, for whatever reason.
Setting VCPKG_LIBRARY_LINKAGEto staticleads to a successful build for me. I'm assuming thats not ideal for a portfile, and more custom triplet territory?
I also tried to configure ITK to BUILD_SHARED_LIBS, as expected, I still get a hdf5-static target error. If I force the shared lib with a patch, it fails with unresolved external symbols. install-x64-windows-dbg-out.log
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
list(APPEND ADDITIONAL_OPTIONS -DBUILD_SHARED_LIBS=OFF)
else()
list(APPEND ADDITIONAL_OPTIONS -DBUILD_SHARED_LIBS=ON)
endif()
I wonder if this isn't due to bugs in FindHDF5.cmake in older CMake versions which I helped fixing. Try CMake 3.11 or later.
@MarkIanHolland static linkage is unfortunately not an option for me since I am trying to use this in a project that needs Qt. Until now, I have been simply linking against Qt built dynamically but compiling static version of ITK and VTK but with vcpkg this is not possible.
@KrisThielemans I have CMake 3.11.4 and still no dice.
@MarkIanHolland I used the mixed type linkage to solve my issue. In essence, ensuring static linkage works fine! Thanks.
Looks ITK's Modules/ThirdParty/HDF5/CMakeLists.txt has confusion with config mode and module mode of find_package().
I modified it only for config mode, then CMake works with hdf5::hdf5-shared
if(ITK_BUILD_SHARED_LIBS)
set(ITKHDF5_LIBRARIES hdf5::hdf5-shared hdf5::hdf5_cpp-shared)
else()
set(ITKHDF5_LIBRARIES hdf5::hdf5-static hdf5::hdf5_cpp-static)
endif()
I successfully build itk:x64-windows with -DITK_USE_SYSTEM_HDF5=ON
https://github.com/tetsuh/vcpkg/commits/itk-hdf5-config_mode-find_package
@tetsuh Great! Any chance of a PR?
Sure, I make PR. I confirmed itk:x86-windows. I'll check x64-static and x86-static also. thnx.
I just rebased PR #4472 based on latest master branch.
It may or may not merged because ad-hoc patch to ITK build.
I know ports/vtk contain similar patches to fix cmake find modules.
but I would not like such changes which makes maintain harder.
I will consider improvements that ITK itself can support both configuration mode and module mode.
Most helpful comment
Looks ITK's Modules/ThirdParty/HDF5/CMakeLists.txt has confusion with config mode and module mode of find_package().
I modified it only for config mode, then CMake works with hdf5::hdf5-shared
I successfully build itk:x64-windows with -DITK_USE_SYSTEM_HDF5=ON
https://github.com/tetsuh/vcpkg/commits/itk-hdf5-config_mode-find_package