vcpkg/ports/netcdf-c/fix-dependency-libzip.patch

94 lines
2.7 KiB
Diff
Raw Normal View History

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b93a141..c3763a7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -957,7 +957,14 @@ OPTION(ENABLE_DAP_REMOTE_TESTS "Enable DAP remote tests." ON)
SET(REMOTETESTSERVERS "remotetest.unidata.ucar.edu" CACHE STRING "test servers to use for remote test")
# See if we have libzip
-FIND_PACKAGE(Zip)
+if(ENABLE_NCZARR_ZIP)
+ find_package(libzip CONFIG REQUIRED)
+ set(Zip_LIBRARIES zip)
+ set(Zip_FOUND TRUE)
+else()
+ set(Zip_LIBRARIES "")
+ set(Zip_FOUND FALSE)
+endif()
# Define a test flag for have curl library
IF(Zip_FOUND)
diff --git a/netCDFConfig.cmake.in b/netCDFConfig.cmake.in
index b3be259..72b4b25 100644
--- a/netCDFConfig.cmake.in
+++ b/netCDFConfig.cmake.in
@@ -15,6 +15,9 @@ set(netCDF_LIBRARIES netCDF::netcdf)
include(CMakeFindDependencyMacro)
find_dependency(HDF5 CONFIG)
find_dependency(CURL CONFIG)
+if(@ENABLE_NCZARR_ZIP@)
+ find_dependency(libzip CONFIG)
+endif()
include("${CMAKE_CURRENT_LIST_DIR}/netCDFTargets.cmake")
# Compiling Options
diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt
index 1363d35..31dbbda 100644
--- a/liblib/CMakeLists.txt
+++ b/liblib/CMakeLists.txt
@@ -134,6 +134,10 @@ ENDIF()
TARGET_LINK_LIBRARIES(netcdf ${TLL_LIBS})
+if(ENABLE_NCZARR_ZIP)
+ target_link_libraries(netcdf libzip::zip)
+endif()
+
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${TLL_LIBS})
IF(MSVC)
SET_TARGET_PROPERTIES(netcdf PROPERTIES
diff --git a/libnczarr/CMakeLists.txt b/libnczarr/CMakeLists.txt
index 86e093b..d7edaf6 100644
--- a/libnczarr/CMakeLists.txt
+++ b/libnczarr/CMakeLists.txt
@@ -58,6 +58,10 @@ ENDIF()
add_library(nczarr OBJECT ${libnczarr_SOURCES})
+IF(ENABLE_NCZARR_ZIP)
+ target_link_libraries(nczarr PRIVATE libzip::zip)
+ENDIF()
+
IF(MPI_C_INCLUDE_PATH)
target_include_directories(nczarr PUBLIC ${MPI_C_INCLUDE_PATH})
ENDIF(MPI_C_INCLUDE_PATH)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6357965..3de76cd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2123,6 +2123,10 @@ replace_pkgconfig_module("-lzip" "libzip")
replace_pkgconfig_module("-lCURL[^ ]*" "libcurl")
replace_pkgconfig_module("-lZLIB[^ ]*" "zlib")
+IF(ENABLE_NCZARR_ZIP)
+ string(APPEND NC_REQUIRES_PRIVATE " libzip")
+ENDIF()
+
configure_file(
${netCDF_SOURCE_DIR}/netcdf.pc.in
${netCDF_BINARY_DIR}/netcdf.pc @ONLY)
diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt
index 31dbbda..eb497cc 100644
--- a/liblib/CMakeLists.txt
+++ b/liblib/CMakeLists.txt
@@ -120,9 +120,6 @@ IF(ENABLE_PNETCDF AND PNETCDF)
SET(TLL_LIBS ${TLL_LIBS} ${PNETCDF})
ENDIF()
-IF(ENABLE_NCZARR_ZIP)
- SET(TLL_LIBS ${TLL_LIBS} ${Zip_LIBRARIES})
-ENDIF()
IF(ENABLE_S3_SDK)
TARGET_LINK_DIRECTORIES(netcdf PUBLIC ${AWSSDK_LIB_DIR})