From 2ca347614929463fed9a3075902d455929026fa4 Mon Sep 17 00:00:00 2001 From: Alexander Neumann <30894796+Neumann-A@users.noreply.github.com> Date: Sat, 8 Jun 2019 23:08:59 +0200 Subject: [netcdf-c/hdf5] improve/correct linkage (#6771) * [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 --- ports/hdf5/CONTROL | 2 +- ports/hdf5/portfile.cmake | 2 ++ ports/hdf5/vcpkg-cmake-wrapper.cmake | 2 ++ ports/netcdf-c/CONTROL | 2 +- ports/netcdf-c/fix_curl_linkage.patch | 12 ------------ ports/netcdf-c/hdf5.patch | 27 +++++++++++++++++++++++++++ ports/netcdf-c/hdf5_2.patch | 13 +++++++++++++ ports/netcdf-c/portfile.cmake | 15 ++++++++++++++- ports/netcdf-c/transitive-hdf5.patch | 2 +- 9 files changed, 61 insertions(+), 16 deletions(-) delete mode 100644 ports/netcdf-c/fix_curl_linkage.patch create mode 100644 ports/netcdf-c/hdf5.patch create mode 100644 ports/netcdf-c/hdf5_2.patch diff --git a/ports/hdf5/CONTROL b/ports/hdf5/CONTROL index 6ec2cea9b..19939c95a 100644 --- a/ports/hdf5/CONTROL +++ b/ports/hdf5/CONTROL @@ -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 diff --git a/ports/hdf5/portfile.cmake b/ports/hdf5/portfile.cmake index cb1541fed..593b38abf 100644 --- a/ports/hdf5/portfile.cmake +++ b/ports/hdf5/portfile.cmake @@ -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 @@ -50,6 +51,7 @@ vcpkg_configure_cmake( -DHDF5_INSTALL_CMAKE_DIR=share ) + vcpkg_install_cmake() vcpkg_copy_pdbs() diff --git a/ports/hdf5/vcpkg-cmake-wrapper.cmake b/ports/hdf5/vcpkg-cmake-wrapper.cmake index 96d8a53c9..695befcdc 100644 --- a/ports/hdf5/vcpkg-cmake-wrapper.cmake +++ b/ports/hdf5/vcpkg-cmake-wrapper.cmake @@ -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) diff --git a/ports/netcdf-c/CONTROL b/ports/netcdf-c/CONTROL index 902a166eb..e27c923f8 100644 --- a/ports/netcdf-c/CONTROL +++ b/ports/netcdf-c/CONTROL @@ -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. diff --git a/ports/netcdf-c/fix_curl_linkage.patch b/ports/netcdf-c/fix_curl_linkage.patch deleted file mode 100644 index 09fead1f0..000000000 --- a/ports/netcdf-c/fix_curl_linkage.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index eb0bc26b..f1409fc6 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -783,6 +783,7 @@ IF(ENABLE_DAP) - - ADD_DEFINITIONS(-DCURL_STATICLIB=1) - INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS}) -+ LINK_LIBRARIES(${CURL_LIBRARIES}) - - # Check to see if CURLOPT_USERNAME is defined. - # It is present starting version 7.19.1. diff --git a/ports/netcdf-c/hdf5.patch b/ports/netcdf-c/hdf5.patch new file mode 100644 index 000000000..71f4921ed --- /dev/null +++ b/ports/netcdf-c/hdf5.patch @@ -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) diff --git a/ports/netcdf-c/hdf5_2.patch b/ports/netcdf-c/hdf5_2.patch new file mode 100644 index 000000000..a3a3fb751 --- /dev/null +++ b/ports/netcdf-c/hdf5_2.patch @@ -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() + diff --git a/ports/netcdf-c/portfile.cmake b/ports/netcdf-c/portfile.cmake index a965ce70e..37ed2f04e 100644 --- a/ports/netcdf-c/portfile.cmake +++ b/ports/netcdf-c/portfile.cmake @@ -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 @@ -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 ) diff --git a/ports/netcdf-c/transitive-hdf5.patch b/ports/netcdf-c/transitive-hdf5.patch index 220640366..89773e6d4 100644 --- a/ports/netcdf-c/transitive-hdf5.patch +++ b/ports/netcdf-c/transitive-hdf5.patch @@ -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") -- cgit v1.2.3