Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

netcdf: add v4.9.2 #21656

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions recipes/netcdf/all/conandata.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
sources:
"4.7.4":
url: "https://github.com/Unidata/netcdf-c/archive/v4.7.4.tar.gz"
sha256: "99930ad7b3c4c1a8e8831fb061cb02b2170fc8e5ccaeda733bd99c3b9d31666b"
"4.9.2":
url: "https://github.com/Unidata/netcdf-c/archive/refs/tags/v4.9.2.tar.gz"
sha256: "bc104d101278c68b303359b3dc4192f81592ae8640f1aee486921138f7f88cb7"
"4.8.1":
url: "https://github.com/Unidata/netcdf-c/archive/v4.8.1.tar.gz"
sha256: "bc018cc30d5da402622bf76462480664c6668b55eb16ba205a0dfb8647161dd0"
patches:
"4.7.4":
- patch_file: "patches/4.7.4-0001-fix-cmake.patch"
url: "https://github.com/Unidata/netcdf-c/archive/v4.7.4.tar.gz"
sha256: "99930ad7b3c4c1a8e8831fb061cb02b2170fc8e5ccaeda733bd99c3b9d31666b"
patches:
"4.9.2":
- patch_file: "patches/4.9.2-0001-fix-cmake.patch"
patch_description: "fixes for cmake target_link_libraries and using deps"
patch_type: "conan"
- patch_file: "patches/4.7.4-0002-fix-cross-compile.patch"
- patch_file: "patches/4.9.2-0002-fix-cross-compile.patch"
patch_description: "fixes 'Unable to find the math library' when cross compiling"
patch_type: "conan"
"4.8.1":
Expand All @@ -20,3 +23,10 @@ patches:
- patch_file: "patches/4.8.1-0002-fix-cross-compile.patch"
patch_description: "fixes 'Unable to find the math library' when cross compiling"
patch_type: "conan"
"4.7.4":
- patch_file: "patches/4.7.4-0001-fix-cmake.patch"
patch_description: "fixes for cmake target_link_libraries and using deps"
patch_type: "conan"
- patch_file: "patches/4.7.4-0002-fix-cross-compile.patch"
patch_description: "fixes 'Unable to find the math library' when cross compiling"
patch_type: "conan"
37 changes: 30 additions & 7 deletions recipes/netcdf/all/conanfile.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from conan import ConanFile
from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout
from conan.tools.files import apply_conandata_patches, export_conandata_patches, get, copy, rm, rmdir
from conan.tools.scm import Version
import os

required_conan_version = ">=1.54.0"
Expand All @@ -22,25 +23,30 @@ class NetcdfConan(ConanFile):
options = {
"shared": [True, False],
"fPIC": [True, False],
"netcdf4": [True, False],
"with_hdf5": [True, False],
"byterange": [True, False],
"cdf5": [True, False],
"dap": [True, False],
"byterange": [True, False],
"netcdf4": [True, False],
"with_hdf4": [True, False],
"with_hdf5": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"netcdf4": True,
"with_hdf5": True,
"byterange": False,
"cdf5": True,
"dap": True,
"byterange": False,
"netcdf4": True,
"with_hdf4": False,
"with_hdf5": True,
}

def _with_hdf5_base(self, options):
return options.with_hdf5 or options.with_hdf4 or options.netcdf4

@property
def _with_hdf5(self):
return self.options.with_hdf5 or self.options.netcdf4
return self._with_hdf5_base(self.options)

def export_sources(self):
export_conandata_patches(self)
Expand All @@ -55,6 +61,9 @@ def configure(self):
self.settings.rm_safe("compiler.libcxx")
self.settings.rm_safe("compiler.cppstd")

def package_id(self):
self.info.options.with_hdf5 = self._with_hdf5_base(self.info.options)

def layout(self):
cmake_layout(self, src_folder="src")

Expand All @@ -69,6 +78,11 @@ def requirements(self):
self.requires("hdf5/1.12.0")
else:
self.requires("hdf5/1.14.1")
if Version(self.version) >= "4.9.0":
self.requires("zlib/[>=1.2.11 <2]")

if self.options.with_hdf4:
self.requires("hdf4/4.2.16-2")

if self.options.dap or self.options.byterange:
self.requires("libcurl/[>=7.78.0 <9]")
Expand All @@ -90,6 +104,11 @@ def generate(self):
tc.variables["ENABLE_BYTERANGE"] = self.options.byterange
tc.variables["USE_HDF5"] = self.options.with_hdf5
tc.variables["NC_FIND_SHARED_LIBS"] = self.options.with_hdf5 and self.dependencies["hdf5"].options.shared

tc.variables["CMAKE_TRY_COMPILE_CONFIGURATION"] = self.settings.build_type
# The compilation check incorrectly fails on MSVC otherwise:
# error C2168: 'memmove': too few actual parameters for intrinsic function
tc.variables["HAVE_MEMMOVE"] = True
tc.generate()

tc = CMakeDeps(self)
Expand Down Expand Up @@ -125,6 +144,10 @@ def package_info(self):
self.cpp_info.components["libnetcdf"].libs = ["netcdf"]
if self._with_hdf5:
self.cpp_info.components["libnetcdf"].requires.append("hdf5::hdf5")
if Version(self.version) >= "4.9.0":
self.cpp_info.components["libnetcdf"].requires.append("zlib::zlib")
if self.options.with_hdf4:
self.cpp_info.components["libnetcdf"].requires.append("hdf4::hdf4")
if self.options.dap or self.options.byterange:
self.cpp_info.components["libnetcdf"].requires.append("libcurl::libcurl")
if self.settings.os in ["Linux", "FreeBSD"]:
Expand Down
121 changes: 121 additions & 0 deletions recipes/netcdf/all/patches/4.9.2-0001-fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6b39f0e4..76f69653 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -109,8 +109,7 @@
ENDIF()

#Add custom CMake Module
-SET(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/"
- CACHE INTERNAL "Location of our custom CMake modules.")
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/")

# auto-configure style checks, other CMake modules.
INCLUDE(CheckLibraryExists)
@@ -681,10 +680,10 @@
# This script will attempt to determine the version of the HDF5 library programatically.
##
IF(HDF5_C_LIBRARY AND HDF5_HL_LIBRARY AND HDF5_INCLUDE_DIR)
- SET(HDF5_LIBRARIES ${HDF5_C_LIBRARY} ${HDF5_HL_LIBRARY})
- SET(HDF5_C_LIBRARIES ${HDF5_C_LIBRARY})
- SET(HDF5_C_LIBRARY_hdf5 ${HDF5_C_LIBRARY})
- SET(HDF5_HL_LIBRARIES ${HDF5_HL_LIBRARY})
+ SET(HDF5_LIBRARIES hdf5::hdf_c hdf5::hdf_hl)
+ SET(HDF5_C_LIBRARIES hdf5::hdf_c)
+ SET(HDF5_C_LIBRARY_hdf5 hdf5::hdf_c)
+ SET(HDF5_HL_LIBRARIES hdf5::hdf_hl)
INCLUDE_DIRECTORIES(${HDF5_INCLUDE_DIR})
MESSAGE(STATUS "Using HDF5 C Library: ${HDF5_C_LIBRARY}")
MESSAGE(STATUS "Using HDF5 HL LIbrary: ${HDF5_HL_LIBRARY}")
@@ -738,7 +737,7 @@
# examples, even though the previous version of what we
# had worked.
#####
- IF(MSVC)
+ IF(0)
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)
@@ -985,11 +984,10 @@

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

# Define a test flag for have curl library
-IF(CURL_LIBRARIES OR CURL_LIBRARY)
+IF(CURL_LIBRARIES OR CURL_LIBRARIES)
SET(FOUND_CURL TRUE)
ELSE()
SET(FOUND_CURL FALSE)
@@ -2277,6 +2275,8 @@
#####
SET(netCDF_LIB_CORENAME "netcdf")

+add_subdirectory(liblib)
+
#####
# Set the true names of all the libraries, if customized by external project
#####
@@ -2334,8 +2334,6 @@
DESTINATION ${netCDF_BINARY_DIR}/nczarr_test/)
ENDIF()

-add_subdirectory(liblib)
-
IF(ENABLE_PLUGINS)
add_subdirectory(plugins)
ENDIF()
@@ -2403,7 +2401,7 @@
# install them in the binary dir. Grab all of the .libs, put them
# in the libdir.
##
-IF(MSVC)
+IF(0)
FILE(GLOB COPY_FILES ${CMAKE_PREFIX_PATH}/lib/*.lib)
INSTALL(FILES ${COPY_FILES}
DESTINATION ${CMAKE_INSTALL_LIBDIR}

diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt
index be72612c..e0edb4ca 100644
--- a/liblib/CMakeLists.txt
+++ b/liblib/CMakeLists.txt
@@ -116,7 +116,7 @@
# builds:
# Make sure that HDF5_C_LIBRARY appears *after*
# HDF5_HL_LIBRARY.
- SET(TLL_LIBS ${HDF5_HL_LIBRARIES} ${HDF5_C_LIBRARIES} ${HDF5_LIBRARIES} ${TLL_LIBS} ${SZIP_LIBRARY})
+ SET(TLL_LIBS ${HDF5_HL_LIBRARIES} ${HDF5_LIBRARIES} ${TLL_LIBS} ${SZIP_LIBRARY})
ELSE() # Windows CMake defines HDF5_LIBRARIES.
SET(TLL_LIBS ${HDF5_LIBRARIES} ${TLL_LIBS} ${SZIP_LIBRARY})
ENDIF()
@@ -208,3 +208,5 @@
FILE(GLOB CUR_EXTRA_DIST RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.h ${CMAKE_CURRENT_SOURCE_DIR}/*.c)
SET(CUR_EXTRA_DIST ${CUR_EXTRA_DIST} CMakeLists.txt Makefile.am)
ADD_EXTRA_DIST("${CUR_EXTRA_DIST}")
+
+SET(TLL_LIBS ${TLL_LIBS} PARENT_SCOPE)
diff -ru a/libdap4/CMakeLists.txt b/libdap4/CMakeLists.txt
--- a/libdap4/CMakeLists.txt 2021-08-19 01:49:05.000000000 +0800
+++ b/libdap4/CMakeLists.txt 2022-12-14 15:03:47.416608700 +0800
@@ -7,6 +7,7 @@
SET(dap4_SOURCES d4curlfunctions.c d4fix.c d4data.c d4file.c d4parser.c d4meta.c d4varx.c d4dump.c d4swap.c d4chunk.c d4printer.c d4read.c d4http.c d4util.c d4odom.c d4cvt.c d4debug.c ncd4dispatch.c)

add_library(dap4 OBJECT ${dap4_SOURCES})
+target_link_libraries(dap4 ${TLL_LIBS})

###
# Options related to the man page generation.

diff -ru a/oc2/CMakeLists.txt b/oc2/CMakeLists.txt
--- a/oc2/CMakeLists.txt 2021-08-19 01:49:05.000000000 +0800
+++ b/oc2/CMakeLists.txt 2022-12-14 15:05:29.788474600 +0800
@@ -8,6 +8,7 @@


add_library(oc2 OBJECT ${oc_SOURCES})
+target_link_libraries(oc2 ${TLL_LIBS})

# Apparently fails under cmake
#set(ocprint_FILES ocprint.c )
17 changes: 17 additions & 0 deletions recipes/netcdf/all/patches/4.9.2-0002-fix-cross-compile.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fd6713d..c6312b2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1079,7 +1079,11 @@

# Check for the math library so it can be explicitly linked.
IF(NOT WIN32)
- FIND_LIBRARY(HAVE_LIBM NAMES math m libm)
+ INCLUDE(CheckLibraryExists)
+ CHECK_LIBRARY_EXISTS(m log "" CAN_LINK_LIBM)
+ IF(CAN_LINK_LIBM)
+ SET(HAVE_LIBM m)
+ ENDIF()
IF(NOT HAVE_LIBM)
CHECK_FUNCTION_EXISTS(exp HAVE_LIBM_FUNC)
IF(NOT HAVE_LIBM_FUNC)
4 changes: 3 additions & 1 deletion recipes/netcdf/config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
versions:
"4.7.4":
"4.9.2":
folder: "all"
"4.8.1":
folder: "all"
"4.7.4":
folder: "all"
Loading