Itk: BUILD_SHARED_LIBS forced to off on Win32 causing wrong system hdf5 libs to be selected

Created on 26 Feb 2020  路  5Comments  路  Source: InsightSoftwareConsortium/ITK

Description

When building shared libraries for ITK and using system hdf5, static hdf5 libraries are selected under Windows.

Steps to Reproduce

  1. Install HDF5 manually with cmake (in my case 1.10.3)
  2. With CMake, select BUILD_SHARED_LIBS=ON and ITK_USE_SYSTEM_HDF5
  3. Configure

You will see that BUILD_SHARED_LIBS is forced to OFF in ITKSetStandardCompilerFlags on Windows. Then, in Modules/ThirdParty/HDF5/itk-module-init.cmake and Modules/ThirdParty/HDF5/CMakeLists.txt:29, the wrong libraries are searched and selected.

Expected behavior

Selection of the HDF5 shared libraries when BUILD_SHARED_LIBS=ON.

Actual behavior

Selection of the HDF static libraries.

Reproducibility

100%

Versions

ITK version 5.0.1

Environment

Windows 10 64 bits
Visual Studio 2019
CMake 3.15

Bug

All 5 comments

I attached a possible patch here (note that other third parties could suffer the same problem).

diff --git a/Modules/ThirdParty/HDF5/CMakeLists.txt b/Modules/ThirdParty/HDF5/CMakeLists.txt
index a700ecdfbf..e9f5a2f6bb 100644
--- a/Modules/ThirdParty/HDF5/CMakeLists.txt
+++ b/Modules/ThirdParty/HDF5/CMakeLists.txt
@@ -1,6 +1,8 @@
 project(ITKHDF5)
 set(ITKHDF5_THIRD_PARTY 1)

+set(BUILD_SHARED_LIBS ${ITK_BUILD_SHARED_LIBS})
+
 if (BUILD_SHARED_LIBS)
    add_definitions(-DH5_BUILT_AS_DYNAMIC_LIB=1)
 endif()

Do you want to turn this into a PR, or do you want me to do it?

Contribution instructions are here.

OK! I'll do it! Do you want me to check if the same issue lies for other third parties as well?

It would be great if you did that too!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

issakomi picture issakomi  路  3Comments

dzenanz picture dzenanz  路  8Comments

seanm picture seanm  路  5Comments

thewtex picture thewtex  路  4Comments

gdevenyi picture gdevenyi  路  3Comments