Skip to content

Commit 47b7841

Browse files
committed
Netcdf ports added to support oneapi
1 parent a318151 commit 47b7841

File tree

11 files changed

+282
-10
lines changed

11 files changed

+282
-10
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index f06fcc0..a19ab28 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -622,9 +622,23 @@ write_basic_package_version_file(
6+
VERSION ${NCXX_VERSION}
7+
COMPATIBILITY SameMajorVersion
8+
)
9+
+
10+
+install(
11+
+ EXPORT netcdf-cxx4Targets
12+
+ FILE netcdf-cxx4Targets.cmake
13+
+ NAMESPACE netCDF::
14+
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/netCDFCxx
15+
+ )
16+
17+
+configure_package_config_file(
18+
+ "${CMAKE_CURRENT_SOURCE_DIR}/netCDFCxxConfig.cmake.in"
19+
+ "${CMAKE_CURRENT_BINARY_DIR}/netCDFCxxConfig.cmake"
20+
+ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/netCDFCxx"
21+
+ )
22+
+
23+
install(
24+
FILES
25+
+ "${CMAKE_CURRENT_BINARY_DIR}/netCDFCxxConfig.cmake"
26+
"${CMAKE_CURRENT_BINARY_DIR}/netCDF/netCDFCxxConfigVersion.cmake"
27+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/netCDFCxx
28+
COMPONENT headers
29+
diff --git a/cxx4/CMakeLists.txt b/cxx4/CMakeLists.txt
30+
index b433786..5ef4bed 100644
31+
--- a/cxx4/CMakeLists.txt
32+
+++ b/cxx4/CMakeLists.txt
33+
@@ -32,7 +32,7 @@ SET(ALL_TLL_LIBS ${ALL_TLL_LIBS} ${HDF5_C_LIBRARY_hdf5})
34+
SET(ALL_TLL_LIBS ${ALL_TLL_LIBS} ${EXTRA_DEPS} PARENT_SCOPE)
35+
36+
ADD_LIBRARY(netcdf-cxx4 ${CXX_SOURCES})
37+
-TARGET_INCLUDE_DIRECTORIES(netcdf-cxx4 PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
38+
+TARGET_INCLUDE_DIRECTORIES(netcdf-cxx4 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)
39+
TARGET_LINK_LIBRARIES(netcdf-cxx4 ${ALL_TLL_LIBS})
40+
SET_TARGET_PROPERTIES(netcdf-cxx4 PROPERTIES
41+
VERSION ${NCXX_LIB_VERSION}
42+
@@ -49,6 +49,7 @@ INSTALL(
43+
)
44+
INSTALL(
45+
TARGETS netcdf-cxx4
46+
+ EXPORT netcdf-cxx4Targets
47+
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
48+
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
49+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index 60c699d..f06fcc0 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -395,14 +395,20 @@ ENDIF(NC_HAS_DEF_VAR_FILTER)
6+
###
7+
# Find HDF5
8+
###
9+
-IF(MSVC)
10+
+IF(0)
11+
SET(SEARCH_PACKAGE_NAME ${HDF5_PACKAGE_NAME})
12+
FIND_PACKAGE(HDF5 NAMES ${SEARCH_PACKAGE_NAME} COMPONENTS C HL NO_MODULES REQUIRED ${NC_HDF5_LINK_TYPE})
13+
ELSE(MSVC)
14+
- FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED)
15+
+ FIND_PACKAGE(hdf5 CONFIG REQUIRED)
16+
+ set(HDF5_FOUND ${hdf5_FOUND})
17+
+ if (NOT HDF5_USE_STATIC_LIBRARIES)
18+
+ set(HDF5_C_LIBRARY_hdf5 hdf5::hdf5-shared hdf5::hdf5_hl-shared)
19+
+ else()
20+
+ set(HDF5_C_LIBRARY_hdf5 hdf5::hdf5-static hdf5::hdf5_hl-static)
21+
+ endif()
22+
ENDIF(MSVC)
23+
24+
-CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY_hdf5} H5free_memory "" HAVE_H5FREE_MEMORY)
25+
+set(HAVE_H5FREE_MEMORY ON)
26+
IF(NOT HAVE_H5FREE_MEMORY)
27+
MESSAGE(STATUS "Plugin support requires libhdf5 with H5Free support. Your libhdf5 install does not provide H5Free. Please install a newer version of libhdf5 if you require plugin compression support.")
28+
SET(NC_HAS_DEF_VAR_FILTER "")
29+
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt
30+
index 30a4a96..1809d29 100644
31+
--- a/plugins/CMakeLists.txt
32+
+++ b/plugins/CMakeLists.txt
33+
@@ -23,7 +23,7 @@ SET_TARGET_PROPERTIES(test_bzip2 PROPERTIES OUTPUT_NAME "bzip2")
34+
SET_TARGET_PROPERTIES(test_bzip2 PROPERTIES LIBRARY_OUTPUT_NAME "h5bzip2")
35+
SET_TARGET_PROPERTIES(test_bzip2 PROPERTIES ARCHIVE_OUTPUT_NAME "h5bzip2")
36+
SET_TARGET_PROPERTIES(test_bzip2 PROPERTIES RUNTIME_OUTPUT_NAME "h5bzip2")
37+
-TARGET_LINK_LIBRARIES(test_bzip2 ${ALL_TLL_LIBS})
38+
+TARGET_LINK_LIBRARIES(test_bzip2 ${ALL_TLL_LIBS} ${HDF5_C_LIBRARY_hdf5})
39+
40+
ADD_LIBRARY(misc MODULE ${libmisc_SOURCES})
41+
SET_TARGET_PROPERTIES(misc PROPERTIES LIBRARY_OUTPUT_NAME "misc")
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff -Naur a/CMakeLists.txt b/CMakeLists.txt
2+
--- a/CMakeLists.txt 2019-09-12 20:34:58.000000000 +0200
3+
+++ b/CMakeLists.txt 2025-10-02 15:39:34.220278300 +0200
4+
@@ -5,7 +5,7 @@
5+
##################################
6+
7+
#Minimum required CMake Version
8+
-cmake_minimum_required(VERSION 2.8.12)
9+
+cmake_minimum_required(VERSION 3.21)
10+
11+
#Project Name
12+
PROJECT(NCXX C CXX)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# NetCDF CXX Configuration Summary
2+
@PACKAGE_INIT@
3+
4+
include(CMakeFindDependencyMacro)
5+
6+
if (@netCDF_FOUND@)
7+
if(EXISTS "@netCDF_ROOT@")
8+
set(netCDF_ROOT "@netCDF_ROOT@")
9+
endif()
10+
if(EXISTS "@netCDF_DIR@")
11+
set(netCDF_DIR "@netCDF_DIR@")
12+
endif()
13+
find_dependency(netCDF)
14+
set(NETCDF_C_LIBRARY ${netCDF_LIBRARIES})
15+
set(NETCDF_C_INCLUDE_DIR ${netCDF_INCLUDE_DIR})
16+
else()
17+
set(NETCDF_C_LIBRARY "@NETCDF_C_LIBRARY@")
18+
set(NETCDF_C_INCLUDE_DIR "@NETCDF_C_INCLUDE_DIR@")
19+
endif()
20+
21+
if (NOT TARGET netCDF::netcdf)
22+
add_library(netCDF::netcdf UNKNOWN IMPORTED)
23+
set_target_properties(netCDF::netcdf PROPERTIES
24+
IMPORTED_LOCATION "${NETCDF_C_LIBRARY}"
25+
INTERFACE_INCLUDE_DIRECTORIES "${NETCDF_C_INCLUDE_DIR}"
26+
)
27+
endif()
28+
29+
include("${CMAKE_CURRENT_LIST_DIR}/netcdf-cxx4Targets.cmake")
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" HDF5_USE_STATIC_LIBRARIES)
2+
3+
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
4+
5+
vcpkg_from_github(
6+
OUT_SOURCE_PATH SOURCE_PATH
7+
REPO Unidata/netcdf-cxx4
8+
REF f8882188267488ef801691e69ad072e3eb217ad8 # v4.3.1
9+
SHA512 9816acf221d196e21af19d4c3d85484934916e7c018e9b2c96aab9f5660b2f08c5db9cd8254ba3fa5f0aa5f5c5ad7bd3a3aaba559e5e640c5349d44e07a20ed3
10+
HEAD_REF master
11+
PATCHES
12+
fix-dependecy-hdf5.patch
13+
export-cmake-targets.patch
14+
min-cmake-version.patch
15+
)
16+
17+
# Provided by upstream https://github.com/Unidata/netcdf-cxx4/blob/master/netCDFCxxConfig.cmake.in
18+
file(COPY "${CMAKE_CURRENT_LIST_DIR}/netCDFCxxConfig.cmake.in" DESTINATION "${SOURCE_PATH}")
19+
20+
vcpkg_cmake_configure(
21+
SOURCE_PATH "${SOURCE_PATH}"
22+
OPTIONS
23+
-DNCXX_ENABLE_TESTS=OFF
24+
-DCMAKE_INSTALL_CMAKECONFIGDIR=share/netCDFCxx
25+
-DHDF5_USE_STATIC_LIBRARIES=${HDF5_USE_STATIC_LIBRARIES}
26+
-DNC_HAS_DEF_VAR_FILTER=OFF # do not build the plugins
27+
28+
# OPTIONS_RELEASE -DOPTIMIZE=1
29+
# OPTIONS_DEBUG -DDEBUGGABLE=1
30+
)
31+
32+
vcpkg_cmake_install()
33+
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/netCDFCxx PACKAGE_NAME netCDFCxx)
34+
vcpkg_copy_pdbs()
35+
36+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
37+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
38+
39+
if(VCPKG_LIBRARY_LINKAGE STREQUAL static)
40+
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
41+
endif()
42+
43+
# Handle copyright
44+
file(INSTALL "${SOURCE_PATH}/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "netcdf-cxx4",
3+
"version": "4.3.1",
4+
"port-version": 5,
5+
"description": "a set of machine-independent data formats that support the creation, access, and sharing of array-oriented scientific data.",
6+
"homepage": "https://github.com/Unidata/netcdf-cxx4",
7+
"dependencies": [
8+
"hdf5",
9+
"netcdf-c",
10+
{
11+
"name": "vcpkg-cmake",
12+
"host": true
13+
},
14+
{
15+
"name": "vcpkg-cmake-config",
16+
"host": true
17+
}
18+
]
19+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
include(FindPackageHandleStandardArgs)
2+
3+
find_path(NetcdfFortran_INCLUDE_DIR
4+
NAMES netcdf.mod
5+
HINTS ${NetcdfFortran_ROOT_DIR}/include ${NetcdfFortran_INCLUDEDIR}
6+
)
7+
8+
find_package(netCDF CONFIG REQUIRED QUIET)
9+
find_library(NetcdfFortran_LIBRARY NAMES netcdff HINTS ${NetcdfFortran_ROOT_DIR}/lib)
10+
find_library(NetcdfFortran_LIBRARY_DEBUG NAMES netcdffd netcdff HINTS ${NetcdfFortran_ROOT_DIR}/lib)
11+
12+
find_package_handle_standard_args(NetcdfFortran
13+
FOUND_VAR NetcdfFortran_FOUND
14+
REQUIRED_VARS NetcdfFortran_INCLUDE_DIR NetcdfFortran_LIBRARY
15+
)
16+
17+
mark_as_advanced(
18+
NetcdfFortran_ROOT_DIR
19+
NetcdfFortran_INCLUDE_DIR
20+
NetcdfFortran_LIBRARY
21+
NetcdfFortran_LIBRARY_DEBUG
22+
)
23+
24+
if(NetcdfFortran_FOUND AND NOT TARGET netcdf::fortran)
25+
add_library(netcdf::fortran STATIC IMPORTED)
26+
set_target_properties(netcdf::fortran PROPERTIES
27+
INTERFACE_INCLUDE_DIRECTORIES "${NetcdfFortran_INCLUDE_DIR}"
28+
INTERFACE_LINK_LIBRARIES "netcdf"
29+
IMPORTED_LOCATION "${NetcdfFortran_LIBRARY}"
30+
)
31+
32+
if(NetcdfFortran_LIBRARY_DEBUG)
33+
set_target_properties(netcdf::fortran PROPERTIES
34+
IMPORTED_LOCATION_DEBUG "${NetcdfFortran_LIBRARY_DEBUG}"
35+
)
36+
endif()
37+
endif()
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
vcpkg_from_github(
2+
OUT_SOURCE_PATH SOURCE_PATH
3+
REPO Unidata/netcdf-fortran
4+
REF v4.6.1
5+
SHA512 3cf3616610bcb7b06c7a78eb47ccf4decc695360d96e8514939a53a48f49f2a659ee77de9113673fc95fdc82581a264d781a6c18ef7127d8c13196c49e825a34
6+
HEAD_REF master
7+
)
8+
9+
vcpkg_configure_cmake(
10+
SOURCE_PATH ${SOURCE_PATH}
11+
PREFER_NINJA
12+
OPTIONS
13+
-DCMAKE_REQUIRED_INCLUDES=${CURRENT_INSTALLED_DIR}/include
14+
-DCMAKE_REQUIRED_LINK_OPTIONS=-L${CURRENT_INSTALLED_DIR}/lib
15+
-DBUILD_SHARED_LIBS=OFF
16+
-DENABLE_TESTS=OFF
17+
-DBUILD_EXAMPLES=OFF
18+
)
19+
20+
vcpkg_install_cmake()
21+
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/netCDF TARGET_PATH share/netcdf-fortran)
22+
23+
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
24+
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/bin ${CURRENT_PACKAGES_DIR}/bin)
25+
endif()
26+
27+
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
28+
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)
29+
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/include/CMakeFiles)
30+
31+
# Handle copyright
32+
file(INSTALL ${SOURCE_PATH}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
33+
#file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/FindnetCDFFortran.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/cmake)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "netcdf-fortran",
3+
"version": "4.6.1",
4+
"port-version": 0,
5+
"description": "netcdf fortran bindings.",
6+
"homepage": "https://github.com/Unidata/netcdf-fortran",
7+
"dependencies": ["netcdf-c"]
8+
}

vcpkg_overlay/triplets/toolchain-linux-intel.cmake

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,11 @@ if(NOT _VCPKG_LINUX_TOOLCHAIN)
1717

1818
# if(NOT INTEL_INSTALL_PATH)
1919
# set(INTEL_INSTALL_PATH /tools/toolchains/intel/oneapi/compiler/latest)
20+
# set(HAVE_LIBM "${INTEL_INSTALL_PATH}/lib/libimf.a" CACHE FILEPATH "")
2021
# endif()
22+
2123
# set(INTEL_PATH ${INTEL_INSTALL_PATH}/bin/)
2224
# set(INTEL_LLVM_PATH ${INTEL_INSTALL_PATH}/bin/compiler/)
23-
2425
# set(ENV{LD_LIBRARY_PATH} "${INTEL_PATH}/compiler/lib/intel64_lin:$ENV{LD_LIBRARY_PATH}")
2526
set(CMAKE_C_COMPILER ${INTEL_PATH}icx CACHE FILEPATH "")
2627
set(CMAKE_ASM_COMPILER ${INTEL_PATH}icx CACHE FILEPATH "")
@@ -33,8 +34,7 @@ if(NOT _VCPKG_LINUX_TOOLCHAIN)
3334
set(CMAKE_C_FLAGS "${VCPKG_C_FLAGS} ${CMAKE_C_FLAGS}" CACHE STRING "")
3435
set(CMAKE_CXX_FLAGS "${VCPKG_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" CACHE STRING "")
3536

36-
# set(HAVE_LIBM "${INTEL_INSTALL_PATH}/lib/libimf.a" CACHE FILEPATH "")
37-
set(CMAKE_EXE_LINKER_FLAGS "-static-intel -static-libstdc++ -static-libgcc ${VCPKG_LINKER_FLAGS}" CACHE STRING "" FORCE)
37+
set(CMAKE_EXE_LINKER_FLAGS "-static-libstdc++ -static-libgcc ${VCPKG_LINKER_FLAGS}" CACHE STRING "" FORCE)
3838
set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} CACHE STRING "" FORCE)
3939
set(CMAKE_MODULE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} CACHE STRING "" FORCE)
4040

0 commit comments

Comments
 (0)