forked from spack/spack
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
netcdf-c[xx]: CMake/Windows build (spack#34935)
netcdf-cxx and netcdf-c now build with CMake rather than Autotools. netcdf-c can still optionally build with Autotools (but defaults to CMake). With some additional patches to the CMake files, netcdf-c can use CMake to build on Windows.
- Loading branch information
1 parent
84ab725
commit 2e9d0e1
Showing
3 changed files
with
169 additions
and
60 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
var/spack/repos/builtin/packages/netcdf-c/4.8.1-win-hdf5-with-zlib.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index ba66a6d4..217aa712 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -856,7 +856,7 @@ IF(USE_HDF5) | ||
# This needs to be near the beginning since we | ||
# need to know whether to add "-lz" to the symbol | ||
# tests below. | ||
- CHECK_C_SOURCE_COMPILES("#include <H5public.h> | ||
+ CHECK_C_SOURCE_COMPILES("#include <H5pubconf.h> | ||
#if !H5_HAVE_ZLIB_H | ||
#error | ||
#endif |
59 changes: 59 additions & 0 deletions
59
var/spack/repos/builtin/packages/netcdf-c/netcdfc-mpi-win-support.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 9b057311..37e96a96 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -1471,6 +1471,7 @@ ENDIF() | ||
|
||
# Enable Parallel IO with netCDF-4/HDF5 files using HDF5 parallel I/O. | ||
SET(STATUS_PARALLEL "OFF") | ||
+set(IMPORT_MPI "") | ||
OPTION(ENABLE_PARALLEL4 "Build netCDF-4 with parallel IO" "${HDF5_PARALLEL}") | ||
IF(ENABLE_PARALLEL4 AND ENABLE_HDF5) | ||
IF(NOT HDF5_PARALLEL) | ||
@@ -1492,6 +1493,7 @@ IF(ENABLE_PARALLEL4 AND ENABLE_HDF5) | ||
FILE(COPY "${netCDF_BINARY_DIR}/tmp/run_par_tests.sh" | ||
DESTINATION ${netCDF_BINARY_DIR}/h5_test | ||
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) | ||
+ set(IMPORT_MPI "include(CMakeFindDependencyMacro)\nfind_dependency(mpi COMPONENTS C)") | ||
ENDIF() | ||
ENDIF() | ||
|
||
diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt | ||
index e3eddc0f..0493cb9d 100644 | ||
--- a/liblib/CMakeLists.txt | ||
+++ b/liblib/CMakeLists.txt | ||
@@ -50,6 +50,7 @@ ADD_LIBRARY(netcdf nc_initialize.c ${LARGS} ) | ||
|
||
IF(MPI_C_INCLUDE_PATH) | ||
target_include_directories(netcdf PUBLIC ${MPI_C_INCLUDE_PATH}) | ||
+ target_link_libraries(netcdf PUBLIC MPI::MPI_C) | ||
ENDIF(MPI_C_INCLUDE_PATH) | ||
|
||
IF(MOD_NETCDF_NAME) | ||
diff --git a/netCDFConfig.cmake.in b/netCDFConfig.cmake.in | ||
index 9d68eec5..dae2429e 100644 | ||
--- a/netCDFConfig.cmake.in | ||
+++ b/netCDFConfig.cmake.in | ||
@@ -14,6 +14,8 @@ set(netCDF_LIBRARIES netCDF::netcdf) | ||
# include target information | ||
include("${CMAKE_CURRENT_LIST_DIR}/netCDFTargets.cmake") | ||
|
||
+@IMPORT_MPI@ | ||
+ | ||
# Compiling Options | ||
# | ||
set(netCDF_C_COMPILER "@CC_VERSION@") | ||
diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt | ||
index 65891d82..15567c8f 100644 | ||
--- a/plugins/CMakeLists.txt | ||
+++ b/plugins/CMakeLists.txt | ||
@@ -62,6 +62,9 @@ MACRO(buildplugin TARGET TARGETLIB) | ||
set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF") | ||
# Set file name & location | ||
set_target_properties(${TARGET} PROPERTIES COMPILE_PDB_NAME ${TARGET} COMPILE_PDB_OUTPUT_DIR ${CMAKE_BINARY_DIR}) | ||
+ IF(MPI_C_INCLUDE_PATH) | ||
+ target_include_directories(${TARGET} PRIVATE ${MPI_C_INCLUDE_PATH}) | ||
+ ENDIF(MPI_C_INCLUDE_PATH) | ||
ENDIF() | ||
ENDMACRO() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters