Skip to content

Commit

Permalink
[netcdf-c/hdf5] improve/correct linkage (#6771)
Browse files Browse the repository at this point in the history
* [netcdf_c] improve HDF5 linkage

* [hdf5] add required HDF5 definitions not set by findHDF5

* [netcdf-c] Call chain HDF5: -> vcpkg_cmake_wrapper (old behvior)
 -> port supplied FindHDF5 -> includes hdf5Config from HDF5_ROOT

* [hdf5] fix szip linkage...again..
will now double link against szip target but thats better than before
the double link issue does not hurt and should be resolved upstream

* revert find_dependency

requires include(CMakeFindDependencyMacro)

* [netcdf-c] removed unnecessary patch
  • Loading branch information
Neumann-A authored and cbezault committed Jun 8, 2019
1 parent 388d219 commit 2ca3476
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 16 deletions.
2 changes: 1 addition & 1 deletion ports/hdf5/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: hdf5
Version: 1.10.5-5
Version: 1.10.5-6
Description: HDF5 is a data model, library, and file format for storing and managing data
Build-Depends: zlib, szip

Expand Down
2 changes: 2 additions & 0 deletions ports/hdf5/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ endif()
#Note: HDF5 Builds by default static as well as shared libraries. Set BUILD_SHARED_LIBS to OFF to only get static libraries
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED_LIBS)

file(REMOVE ${SOURCE_PATH}/config/cmake_ext_mod/FindSZIP.cmake)#Outdated; does not find debug szip
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
DISABLE_PARALLEL_CONFIGURE
Expand All @@ -50,6 +51,7 @@ vcpkg_configure_cmake(
-DHDF5_INSTALL_CMAKE_DIR=share
)


vcpkg_install_cmake()
vcpkg_copy_pdbs()

Expand Down
2 changes: 2 additions & 0 deletions ports/hdf5/vcpkg-cmake-wrapper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.3)
# The caller hasn't said "CONFIG", so they want the built-in FindHDF5.cmake behavior. Set configurations macros to ensure the built-in script finds us.
if("@VCPKG_LIBRARY_LINKAGE@" STREQUAL "static")
set(HDF5_USE_STATIC_LIBRARIES ON)
add_compile_definitions(H5_BUILT_AS_STATIC_LIB)
else()
set(HDF5_USE_STATIC_LIBRARIES OFF)
add_compile_definitions(H5_BUILT_AS_DYNAMIC_LIB)
endif()
endif()
cmake_policy(POP)
Expand Down
2 changes: 1 addition & 1 deletion ports/netcdf-c/CONTROL
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Source: netcdf-c
Version: 4.7.0
Version: 4.7.0-1
Build-Depends: hdf5, curl
Description: a set of self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.
12 changes: 0 additions & 12 deletions ports/netcdf-c/fix_curl_linkage.patch

This file was deleted.

27 changes: 27 additions & 0 deletions ports/netcdf-c/hdf5.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a3874c13..36f15beb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -599,11 +599,10 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
IF(NC_FIND_SHARED_LIBS)
SET(NC_HDF5_LINK_TYPE "shared")
SET(NC_HDF5_LINK_TYPE_UPPER "SHARED")
- ADD_DEFINITIONS(-DH5_BUILT_AS_DYNAMIC_LIB)
ELSE(NC_FIND_SHARED_LIBS)
SET(NC_HDF5_LINK_TYPE "static")
SET(NC_HDF5_LINK_TYPE_UPPER "STATIC")
- ADD_DEFINITIONS(-DH5_BUILT_AS_STATIC_LIB)
+ SET(HDF5_USE_STATIC_LIBRARIES ON)
ENDIF(NC_FIND_SHARED_LIBS)

#####
@@ -614,8 +615,7 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
# had worked.
#####
IF(MSVC)
- SET(SEARCH_PACKAGE_NAME ${HDF5_PACKAGE_NAME})
- FIND_PACKAGE(HDF5 NAMES ${SEARCH_PACKAGE_NAME} COMPONENTS C HL NO_MODULES REQUIRED ${NC_HDF5_LINK_TYPE})
+ FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
ELSE(MSVC)
FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
ENDIF(MSVC)
13 changes: 13 additions & 0 deletions ports/netcdf-c/hdf5_2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt
index ea9b0294..3c7f427d 100644
--- a/liblib/CMakeLists.txt
+++ b/liblib/CMakeLists.txt
@@ -83,7 +83,7 @@ IF(USE_HDF5 OR USE_NETCDF4)
# HDF5_HL_LIBRARY.
SET(TLL_LIBS ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES} ${TLL_LIBS} ${SZIP_LIBRARY})
ELSE() # Windows CMake defines HDF5_LIBRARIES.
- SET(TLL_LIBS ${HDF5_LIBRARIES} ${TLL_LIBS} ${SZIP_LIBRARY})
+ SET(TLL_LIBS ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES} ${TLL_LIBS} ${SZIP_LIBRARY})
ENDIF()
ENDIF()

15 changes: 14 additions & 1 deletion ports/netcdf-c/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,20 @@ vcpkg_from_github(
no-install-deps.patch
config-pkg-location.patch
transitive-hdf5.patch
fix_curl_linkage.patch
hdf5.patch
hdf5_2.patch
)

#Remove outdated find modules
file(REMOVE "${SOURCE_PATH}/cmake/modules/FindSZIP.cmake")
file(REMOVE "${SOURCE_PATH}/cmake/modules/FindZLIB.cmake")

if(VCPKG_CRT_LINKAGE STREQUAL "static")
set(NC_USE_STATIC_CRT ON)
else()
set(NC_USE_STATIC_CRT OFF)
endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
DISABLE_PARALLEL_CONFIGURE
Expand All @@ -22,9 +33,11 @@ vcpkg_configure_cmake(
-DBUILD_TESTING=OFF
-DENABLE_EXAMPLES=OFF
-DENABLE_TESTS=OFF
-DENABLE_FILTER_TESTING=OFF
-DUSE_HDF5=ON
-DENABLE_DAP_REMOTE_TESTS=OFF
-DDISABLE_INSTALL_DEPENDENCIES=ON
-DNC_USE_STATIC_CRT=${NC_USE_STATIC_CRT}
-DConfigPackageLocation=share/netcdf
)

Expand Down
2 changes: 1 addition & 1 deletion ports/netcdf-c/transitive-hdf5.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ index 6f4ccf8..14a3743 100644

set(netCDF_LIBRARIES netcdf)

+find_package(HDF5 REQUIRED)
+find_package(HDF5 COMPONENTS C HL CONFIG REQUIRED)
+
# include target information
include("${CMAKE_CURRENT_LIST_DIR}/netCDFTargets.cmake")
Expand Down

0 comments on commit 2ca3476

Please sign in to comment.