FindHDF5 INTERFACE_LINK_LIBRARIES failure if both debug and release libraries are found
I've built HDF5 myself and installed both Debug
and RelWithDebInfo
. Now I have problem when trying to use find_package(HDF5)
:
4>CMake Error at C:/Program Files/CMake/share/cmake-3.19/Modules/FindHDF5.cmake:993 (set_target_properties):
4> Property INTERFACE_LINK_LIBRARIES may not contain link-type keyword
4> "optimized". The INTERFACE_LINK_LIBRARIES property may contain
4> configuration-sensitive generator-expressions which may be used to specify
4> per-configuration rules.
4>Call Stack (most recent call first):
4> CMakeLists.txt:113 (find_package)
Debug output of find_package(HDF5)
:
4>-- HDF5_DIR: HDF5_DIR-NOTFOUND
4>-- HDF5_DEFINITIONS: -DH5_BUILT_AS_DYNAMIC_LIB
4>-- HDF5_INCLUDE_DIRS: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/include
4>-- HDF5_LIBRARIES: optimized;C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/lib/hdf5.lib;debug;C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/lib/hdf5_D.lib
4>-- HDF5_HL_LIBRARIES:
4>-- HDF5_C_DEFINITIONS:
4>-- HDF5_C_INCLUDE_DIR: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/include
4>-- HDF5_C_INCLUDE_DIRS: C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/include
4>-- HDF5_C_LIBRARY:
4>-- HDF5_C_LIBRARIES: optimized;C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/lib/hdf5.lib;debug;C:/Users/krisf/Documents/devel/buildVC/SIRF-SuperBuild/INSTALL/lib/hdf5_D.lib
4>-- HDF5_C_HL_LIBRARY:
4>-- HDF5_C_HL_LIBRARIES:
I believe the offending line is at https://gitlab.kitware.com/cmake/cmake/-/blob/v3.19.2/Modules/FindHDF5.cmake#L994 and that instead we should use
target_link_libraries(HDF5::HDF5 INTERFACE "${HDF5_LIBRARIES}")
As you can see from the above, I'm using Visual Studio on Windows 10, with CMake 3.19.2, but the problem is in current master
Edited by Brad King