diff --git a/ports/netcdf-c/CONTROL b/ports/netcdf-c/CONTROL new file mode 100644 index 000000000..4a9be9132 --- /dev/null +++ b/ports/netcdf-c/CONTROL @@ -0,0 +1,4 @@ +Source: netcdf-c +Version: 4.4.1.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/config-pkg-location.patch b/ports/netcdf-c/config-pkg-location.patch new file mode 100644 index 000000000..532082ccb --- /dev/null +++ b/ports/netcdf-c/config-pkg-location.patch @@ -0,0 +1,15 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 46892ee..803ff46 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1742,7 +1742,9 @@ FILE(COPY ${netCDF_SOURCE_DIR}/include/netcdf_meta.h + # Create CMake package configuration files. With these, other packages using + # cmake should be able to find netcdf using find_package and find_library. + # The EXPORT call is paired with one in liblib. +-set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/netCDF) ++if(NOT DEFINED ConfigPackageLocation) ++ set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/netCDF) ++endif(NOT DEFINED ConfigPackageLocation) + + install(EXPORT netCDFTargets + DESTINATION ${ConfigPackageLocation} diff --git a/ports/netcdf-c/no-install-deps.patch b/ports/netcdf-c/no-install-deps.patch new file mode 100644 index 000000000..3d44b383e --- /dev/null +++ b/ports/netcdf-c/no-install-deps.patch @@ -0,0 +1,13 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index e87f3de..46892ee 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1570,7 +1570,7 @@ ADD_SUBDIRECTORY(docs) + # install them in the binary dir. Grab all of the .libs, put them + # in the libdir. + ## +-IF(MSVC) ++IF(MSVC AND NOT DISABLE_INSTALL_DEPENDENCIES) + FILE(GLOB COPY_FILES ${CMAKE_PREFIX_PATH}/lib/*.lib) + INSTALL(FILES ${COPY_FILES} + DESTINATION ${CMAKE_INSTALL_LIBDIR} diff --git a/ports/netcdf-c/portfile.cmake b/ports/netcdf-c/portfile.cmake new file mode 100644 index 000000000..5b798f266 --- /dev/null +++ b/ports/netcdf-c/portfile.cmake @@ -0,0 +1,52 @@ +# Common Ambient Variables: +# VCPKG_ROOT_DIR = +# TARGET_TRIPLET is the current triplet (x86-windows, etc) +# PORT is the current port name (zlib, etc) +# CURRENT_BUILDTREES_DIR = ${VCPKG_ROOT_DIR}\buildtrees\${PORT} +# CURRENT_PACKAGES_DIR = ${VCPKG_ROOT_DIR}\packages\${PORT}_${TARGET_TRIPLET} +# + +include(vcpkg_common_functions) +set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/netcdf-c-4.4.1.1) +vcpkg_download_distfile(ARCHIVE + URLS "https://github.com/Unidata/netcdf-c/archive/v4.4.1.1.zip" + FILENAME "netcdf-c-v4.4.1.1.zip" + SHA512 8d31e47f0bd4d5c8640d3444c5c83425862ed1e8283aa78419e86b18d33fd93bfeb0067e8e9630457cb9c334d6fedf630283b5227a15137a3e153d57b22364a8 +) +vcpkg_extract_source_archive(${ARCHIVE}) + +vcpkg_apply_patches( + SOURCE_PATH ${SOURCE_PATH} + PATCHES + ${CMAKE_CURRENT_LIST_DIR}/no-install-deps.patch + ${CMAKE_CURRENT_LIST_DIR}/config-pkg-location.patch +) + +vcpkg_configure_cmake( + SOURCE_PATH ${SOURCE_PATH} + PREFER_NINJA # Disable this option if project cannot be built with Ninja + OPTIONS + -DBUILD_UTILITIES=OFF + -DBUILD_TESTING=OFF + -DENABLE_EXAMPLES=OFF + -DENABLE_TESTS=OFF + -DUSE_HDF5=ON + -DENABLE_DAP_REMOTE_TESTS=OFF + -DDISABLE_INSTALL_DEPENDENCIES=ON + -DConfigPackageLocation=share/netcdf + + # OPTIONS_RELEASE -DOPTIMIZE=1 + # OPTIONS_DEBUG -DDEBUGGABLE=1 +) + +vcpkg_install_cmake() + +file(READ ${CURRENT_PACKAGES_DIR}/debug/share/netcdf/netCDFTargets-debug.cmake NETCDF_TARGETS_DEBUG_MODULE) +string(REPLACE "\${_IMPORT_PREFIX}" "\${_IMPORT_PREFIX}/debug" NETCDF_TARGETS_DEBUG_MODULE "${NETCDF_TARGETS_DEBUG_MODULE}") +file(WRITE ${CURRENT_PACKAGES_DIR}/share/netcdf/netCDFTargets-debug.cmake "${NETCDF_TARGETS_DEBUG_MODULE}") + +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) +file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share) + +# Handle copyright +file(COPY ${SOURCE_PATH}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/netcdf-c)