Skip to content

Commit

Permalink
[hdf5] Use cmake wrapper to ensure consuming libraries link to szip (m…
Browse files Browse the repository at this point in the history
…icrosoft#5467)

* [hdf5] Use cmake wrapper to ensure consuming libraries link to szip in static build

* [hdf5] Move hdf5 cmake code from vcpkg.cmake to vcpkg-cmake-wrapper

* [hdf5] Do not force search in config mode

* [hdf5] balance needs of vtk and kealib
  • Loading branch information
Sean Warren authored and Rastaban committed Mar 5, 2019
1 parent a51c0f4 commit a9f8430
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
6 changes: 6 additions & 0 deletions ports/hdf5/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,11 @@ file(RENAME ${CURRENT_PACKAGES_DIR}/share/hdf5/data/COPYING ${CURRENT_PACKAGES_D

vcpkg_fixup_cmake_targets(CONFIG_PATH share/hdf5)

configure_file(
${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake
${CURRENT_PACKAGES_DIR}/share/hdf5
@ONLY
)

file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
29 changes: 29 additions & 0 deletions ports/hdf5/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
if (NOT PROJECT_NAME STREQUAL "VTK")
_find_package(${ARGS} 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()
else ()
_find_package(${ARGS})
endif()

if("static" STREQUAL "static")
find_package(SZIP CONFIG REQUIRED)
foreach(HDF5TARGET hdf5 hdf5_hl hdf5_cpp hdf5_hl_cpp)
if(TARGET hdf5::${HDF5TARGET}-static)
if (TARGET szip-shared)
set_property(TARGET hdf5::${HDF5TARGET}-static APPEND PROPERTY INTERFACE_LINK_LIBRARIES szip-shared)
else ()
set_property(TARGET hdf5::${HDF5TARGET}-static APPEND PROPERTY INTERFACE_LINK_LIBRARIES szip-static)
endif ()
endif()
endforeach()
endif()

13 changes: 0 additions & 13 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,6 @@ macro(find_package name)
if(TIFF_LIBRARIES)
list(APPEND TIFF_LIBRARIES ${LIBLZMA_LIBRARIES})
endif()
elseif(("${name}" STREQUAL "HDF5" OR "${name}" STREQUAL "hdf5") AND NOT PROJECT_NAME STREQUAL "VTK" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/hdf5.h")
# 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 "GSL" AND EXISTS "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include/gsl")
_find_package(${ARGV})
if(GSL_FOUND AND TARGET GSL::gsl)
Expand Down

0 comments on commit a9f8430

Please sign in to comment.