From e70250ca199f9e55c88c242ee980313b8acb45e5 Mon Sep 17 00:00:00 2001 From: Robert Schumacher Date: Thu, 1 Mar 2018 10:36:13 -0800 Subject: [PATCH] [vcpkg] Improve handling of HDF5 targets --- scripts/buildsystems/vcpkg.cmake | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/buildsystems/vcpkg.cmake b/scripts/buildsystems/vcpkg.cmake index d5108471fb..7b738bd5ea 100644 --- a/scripts/buildsystems/vcpkg.cmake +++ b/scripts/buildsystems/vcpkg.cmake @@ -233,12 +233,22 @@ macro(find_package name) elseif("${name}" STREQUAL "tinyxml2") _find_package(${ARGV}) if(TARGET tinyxml2_static AND NOT TARGET tinyxml2) - add_library(tinyxml2 INTERFACE IMPORTED) + _add_library(tinyxml2 INTERFACE IMPORTED) set_target_properties(tinyxml2 PROPERTIES INTERFACE_LINK_LIBRARIES "tinyxml2_static") endif() - elseif("${name}" STREQUAL "HDF5" AND NOT PROJECT_NAME STREQUAL "VTK") + elseif(("${name}" STREQUAL "HDF5" OR "${name}" STREQUAL "hdf5") AND NOT PROJECT_NAME STREQUAL "VTK") # This is a hack to make VTK work. TODO: find another way to suppress the built-in find module. _find_package(${ARGV} CONFIG) + # Fill in missing static/shared targets + foreach(HDF5TARGET hdf5 hdf5_hl hdf5_cpp hdf5_hl_cpp) + if(TARGET hdf5::${HDF5TARGET}-static AND NOT TARGET hdf5::${HDF5TARGET}-shared) + _add_library(hdf5::${HDF5TARGET}-shared INTERFACE IMPORTED) + set_target_properties(hdf5::${HDF5TARGET}-shared PROPERTIES INTERFACE_LINK_LIBRARIES "hdf5::${HDF5TARGET}-static") + elseif(TARGET hdf5::${HDF5TARGET}-shared AND NOT TARGET hdf5::${HDF5TARGET}-static) + _add_library(hdf5::${HDF5TARGET}-static INTERFACE IMPORTED) + set_target_properties(hdf5::${HDF5TARGET}-static PROPERTIES INTERFACE_LINK_LIBRARIES "hdf5::${HDF5TARGET}-shared") + endif() + endforeach() elseif("${name}" STREQUAL "CURL") _find_package(${ARGV}) if(CURL_FOUND)