Skip to content

Commit

Permalink
[netcdf-c] Update to 4.7.3 and switched to use targets to generate va…
Browse files Browse the repository at this point in the history
…lid targets (#9361)

* fix netcdf configure errors and generated targets

* remove target_path

since cmake searches in name*

* bump control

* netcdf update to 4.7.3 and use targets instead of libraries in cmake

* remove config from the zlib find_dependency call

because there is no config. The target is supplied by a cmake module itself

* move usage of hdf5 target to an further up in the cmakelists.txt and use config also on linux

* fix dynamic builds

* remove code from portfile

* remove commenting from patch and simply delete the lines
  • Loading branch information
Neumann-A authored and dan-shaw committed Jan 10, 2020
1 parent 7dc8ecb commit d400f3d
Show file tree
Hide file tree
Showing 8 changed files with 174 additions and 106 deletions.
2 changes: 1 addition & 1 deletion ports/netcdf-c/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: netcdf-c
Version: 4.7.0-5
Version: 4.7.3
Build-Depends: hdf5, curl
Homepage: https://github.com/Unidata/netcdf-c
Description: a set of self-describing, machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.
28 changes: 0 additions & 28 deletions ports/netcdf-c/fix-build-error-on-linux.patch

This file was deleted.

27 changes: 0 additions & 27 deletions ports/netcdf-c/hdf5.patch

This file was deleted.

13 changes: 0 additions & 13 deletions ports/netcdf-c/hdf5_2.patch

This file was deleted.

14 changes: 0 additions & 14 deletions ports/netcdf-c/hdf5_3.patch

This file was deleted.

15 changes: 5 additions & 10 deletions ports/netcdf-c/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
include(vcpkg_common_functions)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO Unidata/netcdf-c
REF v4.7.0
SHA512 6602799780105c60ac8c873ed4055c1512dc8bebf98de01e1cce572d113ffb3bf3ca522475b93255c415340f672c55dc6785e0bdbcc39055314683da1d02141a
REF b7cd387bee8c661141fabb490f4969587c008c55 # v4.7.3
SHA512 a55391620fac61e4975fe62907ca21049911afce6190fc12d183d24133a32aae8cd223b97a3fe57fc82d8bdca1a7db451046e3be3c379051624d48b1f56c0332
HEAD_REF master
PATCHES
no-install-deps.patch
config-pkg-location.patch
transitive-hdf5.patch
hdf5.patch
hdf5_2.patch
fix-build-error-on-linux.patch
hdf5_3.patch
use_targets.patch
)

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

if(VCPKG_CRT_LINKAGE STREQUAL "static")
set(NC_USE_STATIC_CRT ON)
Expand All @@ -28,7 +23,7 @@ endif()

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
DISABLE_PARALLEL_CONFIGURE
DISABLE_PARALLEL_CONFIGURE # netcdf-c configures in the source!
PREFER_NINJA
OPTIONS
-DBUILD_UTILITIES=OFF
Expand Down
13 changes: 0 additions & 13 deletions ports/netcdf-c/transitive-hdf5.patch

This file was deleted.

168 changes: 168 additions & 0 deletions ports/netcdf-c/use_targets.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1ce05e0fe..7671d7b1e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -431,7 +431,6 @@ IF(NC_EXTRA_DEPS)
SET(EXTRA_DEPS ${EXTRA_DEPS} "${${_LIB}_DEP}")
ENDFOREACH()
MESSAGE("Extra deps: ${EXTRA_DEPS}")
- LIST(REMOVE_DUPLICATES EXTRA_DEPS)
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${EXTRA_DEPS})
ENDIF()
###
@@ -599,15 +599,6 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
# we will use a static library. This can be toggled
# by explicitly modifying NC_FIND_SHARED_LIBS.
##
- 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)
- ENDIF(NC_FIND_SHARED_LIBS)

#####
# First, find the C and HL libraries.
@@ -620,9 +620,9 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
SET(SEARCH_PACKAGE_NAME ${HDF5_PACKAGE_NAME})
FIND_PACKAGE(HDF5 NAMES ${SEARCH_PACKAGE_NAME} COMPONENTS C HL CONFIG REQUIRED ${NC_HDF5_LINK_TYPE})
ELSE(MSVC)
- FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
+ FIND_PACKAGE(HDF5 COMPONENTS C HL CONFIG REQUIRED)
ENDIF(MSVC)
-
+
##
# Next, check the HDF5 version. This will inform which
# HDF5 variables we need to munge.
@@ -695,6 +695,19 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF()
ENDIF(HDF5_C_LIBRARY AND HDF5_HL_LIBRARY AND HDF5_INCLUDE_DIR)

+ if(TARGET hdf5::hdf5-shared)
+ set(HDF5_C_LIBRARY hdf5::hdf5-shared)
+ set(HDF5_C_LIBRARY_hdf5 hdf5::hdf5-shared)
+ set(HDF5_HL_LIBRARIES hdf5::hdf5_hl-shared)
+ ADD_DEFINITIONS(-DH5_BUILT_AS_DYNAMIC_LIB)
+ else()
+ set(HDF5_C_LIBRARY hdf5::hdf5-static)
+ set(HDF5_C_LIBRARY_hdf5 hdf5::hdf5-static)
+ set(HDF5_HL_LIBRARIES hdf5::hdf5_hl-static)
+ ADD_DEFINITIONS(-DH5_BUILT_AS_STATIC_LIB)
+ endif()
+ list(APPEND CMAKE_REQUIRED_LIBRARIES ${HDF5_C_LIBRARY})
+
FIND_PACKAGE(Threads)

# There is a missing case in the above code so default it
@@ -721,16 +733,11 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_all_coll_metadata_ops "" HDF5_HAS_COLL_METADATA_OPS)

#Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip.
- CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Z_SZIP "" USE_SZIP)
+ set(USE_SZIP ${HDF5_ENABLE_SZIP_SUPPORT})
IF(USE_SZIP)
- FIND_LIBRARY(SZIP NAMES szip sz)
- IF(SZIP)
+ #FIND_LIBRARY(SZIP NAMES szip sz)
+ #IF(SZIP)
SET(HAVE_H5Z_SZIP 1)
- SET(SZIP_LIBRARY ${SZIP})
- SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${SZIP})
- ELSE()
- MESSAGE(FATAL_ERROR "HDF5 Requires SZIP, but cannot find libszip or libsz.")
- ENDIF()
ENDIF()

CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5Pset_libver_bounds "" HAVE_H5PSET_LIBVER_BOUNDS)
@@ -764,8 +776,7 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4)
ENDIF(USE_HDF5 OR ENABLE_NETCDF_4)

# See if we have libcurl
-FIND_PACKAGE(CURL)
-ADD_DEFINITIONS(-DCURL_STATICLIB=1)
+FIND_PACKAGE(CURL CONFIG)
INCLUDE_DIRECTORIES(${CURL_INCLUDE_DIRS})

# Check to see if CURLOPT_USERNAME is defined.
@@ -1890,7 +1902,6 @@ ENDIF()

STRING(REPLACE ";" " " LINKFLAGS "${LINKFLAGS}")

-LIST(REMOVE_DUPLICATES NC_LIBS)
LIST(REMOVE_DUPLICATES LINKFLAGS)

SET(LIBS ${NC_LIBS})
diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt
index ea9b02949..ec7851f37 100644
--- a/liblib/CMakeLists.txt
+++ b/liblib/CMakeLists.txt
@@ -58,7 +58,7 @@ ENDIF()

SET(TLL_LIBS "")

-SET(TLL_LIBS ${TLL_LIBS} ${HAVE_LIBM} ${ZLIB_LIBRARY})
+SET(TLL_LIBS ${TLL_LIBS} ${HAVE_LIBM} ZLIB::ZLIB)

# Add extra dependencies specified via NC_EXTRA_DEPS
SET(TLL_LIBS ${TLL_LIBS} ${EXTRA_DEPS})
@@ -68,27 +68,15 @@ IF(HAVE_LIBDL)
ENDIF()

IF(USE_HDF5 OR USE_NETCDF4)
- IF(NOT MSVC)
- # Some version of cmake define HDF5_hdf5_LIBRARY instead of
- # HDF5_LIBRARY. Same with HDF5_HL_LIBRARIES
- IF(HDF5_hdf5_LIBRARY AND NOT HDF5_C_LIBRARIES)
- SET(HDF5_C_LIBRARIES ${HDF5_hdf5_LIBRARY})
- ENDIF()
- IF(HDF5_hdf5_hl_LIBRARY AND NOT HDF5_HL_LIBRARIES)
- SET(HDF5_HL_LIBRARIES ${HDF5_hdf5_hl_LIBRARY})
- ENDIF()
- # The order of the libraries is important here for static
- # builds:
- # Make sure that HDF5_C_LIBRARY appears *after*
- # 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})
- ENDIF()
+ if(TARGET hdf5::hdf5-shared)
+ SET(TLL_LIBS ${TLL_LIBS} hdf5::hdf5-shared hdf5::hdf5_hl-shared)
+ else()
+ SET(TLL_LIBS ${TLL_LIBS} hdf5::hdf5-static hdf5::hdf5_hl-static)
+ endif()
ENDIF()

IF(USE_DAP)
- SET(TLL_LIBS ${TLL_LIBS} ${CURL_LIBRARY})
+ SET(TLL_LIBS ${TLL_LIBS} CURL::libcurl)
ENDIF()

IF(USE_HDF4)
@@ -100,7 +88,6 @@ IF(ENABLE_PNETCDF AND PNETCDF)
ENDIF()

IF(TLL_LIBS)
- LIST(REMOVE_DUPLICATES TLL_LIBS)
ENDIF()

TARGET_LINK_LIBRARIES(netcdf ${TLL_LIBS})
diff --git a/netCDFConfig.cmake.in b/netCDFConfig.cmake.in
index c89cf3e67..b81f35a1b 100644
--- a/netCDFConfig.cmake.in
+++ b/netCDFConfig.cmake.in
@@ -12,6 +12,10 @@ set_and_check(netCDF_LIB_DIR "@PACKAGE_CMAKE_INSTALL_LIBDIR@")
set(netCDF_LIBRARIES netcdf)

# include target information
+include(CMakeFindDependencyMacro)
+find_dependency(ZLIB)
+find_dependency(HDF5 CONFIG)
+find_dependency(CURL CONFIG)
include("${CMAKE_CURRENT_LIST_DIR}/netCDFTargets.cmake")

# Compiling Options

0 comments on commit d400f3d

Please sign in to comment.