|
| 1 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 2 | +index de95010c..25229f9c 100644 |
| 3 | +--- a/CMakeLists.txt |
| 4 | ++++ b/CMakeLists.txt |
| 5 | +@@ -664,6 +664,7 @@ ENDIF(ENABLE_STRICT_NULL_BYTE_HEADER_PADDING) |
| 6 | + # * |
| 7 | + ## |
| 8 | + SET(USE_HDF5 ${ENABLE_HDF5}) |
| 9 | ++SET(IMPORT_HDF5 "") |
| 10 | + IF(USE_HDF5) |
| 11 | + |
| 12 | + ## |
| 13 | +@@ -671,7 +672,6 @@ IF(USE_HDF5) |
| 14 | + ## |
| 15 | + SET(HDF5_VERSION_REQUIRED 1.8.10) |
| 16 | + |
| 17 | +- |
| 18 | + ## |
| 19 | + # Accommodate developers who have hdf5 libraries and |
| 20 | + # headers on their system, but do not have a the hdf |
| 21 | +@@ -744,6 +744,9 @@ IF(USE_HDF5) |
| 22 | + ELSE(MSVC) |
| 23 | + FIND_PACKAGE(HDF5 COMPONENTS C HL REQUIRED) |
| 24 | + ENDIF(MSVC) |
| 25 | ++ # Export HDF5 Dependency so consumers can properly use |
| 26 | ++ # exported link interface |
| 27 | ++ set(IMPORT_HDF5 "find_dependency(HDF5 COMPONENTS C HL)") |
| 28 | + |
| 29 | + ## |
| 30 | + # Next, check the HDF5 version. This will inform which |
| 31 | +@@ -1481,6 +1484,7 @@ ENDIF() |
| 32 | + |
| 33 | + # Enable Parallel IO with netCDF-4/HDF5 files using HDF5 parallel I/O. |
| 34 | + SET(STATUS_PARALLEL "OFF") |
| 35 | ++set(IMPORT_MPI "") |
| 36 | + OPTION(ENABLE_PARALLEL4 "Build netCDF-4 with parallel IO" "${HDF5_PARALLEL}") |
| 37 | + IF(ENABLE_PARALLEL4 AND ENABLE_HDF5) |
| 38 | + IF(NOT HDF5_PARALLEL) |
| 39 | +@@ -1502,6 +1506,7 @@ IF(ENABLE_PARALLEL4 AND ENABLE_HDF5) |
| 40 | + FILE(COPY "${netCDF_BINARY_DIR}/tmp/run_par_tests.sh" |
| 41 | + DESTINATION ${netCDF_BINARY_DIR}/h5_test |
| 42 | + FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE) |
| 43 | ++ set(IMPORT_MPI "find_dependency(MPI COMPONENTS C)") |
| 44 | + ENDIF() |
| 45 | + ENDIF() |
| 46 | + |
| 47 | +@@ -2652,6 +2657,8 @@ endif(DEFINED ENV{LIB_FUZZING_ENGINE}) |
| 48 | + # cmake should be able to find netcdf using find_package and find_library. |
| 49 | + # The EXPORT call is paired with one in liblib. |
| 50 | + set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/netCDF) |
| 51 | ++set(IMPORT_FIND_DEP "include(CMakeFindDependencyMacro)") |
| 52 | ++ |
| 53 | + |
| 54 | + install(EXPORT netCDFTargets |
| 55 | + DESTINATION ${ConfigPackageLocation} |
| 56 | +diff --git a/liblib/CMakeLists.txt b/liblib/CMakeLists.txt |
| 57 | +index e3eddc0f..0493cb9d 100644 |
| 58 | +--- a/liblib/CMakeLists.txt |
| 59 | ++++ b/liblib/CMakeLists.txt |
| 60 | +@@ -50,6 +50,7 @@ ADD_LIBRARY(netcdf nc_initialize.c ${LARGS} ) |
| 61 | + |
| 62 | + IF(MPI_C_INCLUDE_PATH) |
| 63 | + target_include_directories(netcdf PUBLIC ${MPI_C_INCLUDE_PATH}) |
| 64 | ++ target_link_libraries(netcdf MPI::MPI_C) |
| 65 | + ENDIF(MPI_C_INCLUDE_PATH) |
| 66 | + |
| 67 | + IF(MOD_NETCDF_NAME) |
| 68 | +diff --git a/netCDFConfig.cmake.in b/netCDFConfig.cmake.in |
| 69 | +index 9d68eec5..eece09cb 100644 |
| 70 | +--- a/netCDFConfig.cmake.in |
| 71 | ++++ b/netCDFConfig.cmake.in |
| 72 | +@@ -14,6 +14,10 @@ set(netCDF_LIBRARIES netCDF::netcdf) |
| 73 | + # include target information |
| 74 | + include("${CMAKE_CURRENT_LIST_DIR}/netCDFTargets.cmake") |
| 75 | + |
| 76 | ++@IMPORT_FIND_DEP@ |
| 77 | ++@IMPORT_MPI@ |
| 78 | ++@IMPORT_HDF5@ |
| 79 | ++ |
| 80 | + # Compiling Options |
| 81 | + # |
| 82 | + set(netCDF_C_COMPILER "@CC_VERSION@") |
| 83 | +diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt |
| 84 | +index 65891d82..15567c8f 100644 |
| 85 | +--- a/plugins/CMakeLists.txt |
| 86 | ++++ b/plugins/CMakeLists.txt |
| 87 | +@@ -62,6 +62,9 @@ MACRO(buildplugin TARGET TARGETLIB) |
| 88 | + set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "/INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF") |
| 89 | + # Set file name & location |
| 90 | + set_target_properties(${TARGET} PROPERTIES COMPILE_PDB_NAME ${TARGET} COMPILE_PDB_OUTPUT_DIR ${CMAKE_BINARY_DIR}) |
| 91 | ++ IF(MPI_C_INCLUDE_PATH) |
| 92 | ++ target_include_directories(${TARGET} PRIVATE ${MPI_C_INCLUDE_PATH}) |
| 93 | ++ ENDIF(MPI_C_INCLUDE_PATH) |
| 94 | + ENDIF() |
| 95 | + ENDMACRO() |
| 96 | + |
0 commit comments