Skip to content

Commit

Permalink
Merge pull request ESMCI#1735 from NCAR/ejh_cmake
Browse files Browse the repository at this point in the history
stop setting some command line pre-processor definitions from CMake build - use config.h for all pre-processor defines instead
  • Loading branch information
edwardhartnett authored Aug 27, 2020
2 parents 54ee841 + f130a86 commit 22d1160
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 41 deletions.
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@ else()
find_package (PnetCDF COMPONENTS C)
endif()

# Did we find pnetCDF? If so, set _PNETCDF in config.h.
if (PnetCDF_C_FOUND)
set(_PNETCDF 1)
endif ()

#==============================================================================
# INCLUDE SOURCE DIRECTORIES
#==============================================================================
Expand Down Expand Up @@ -312,6 +317,11 @@ CHECK_C_SOURCE_COMPILES("
#endif
int main() {return 0;}" HAVE_NETCDF_PAR)

# Set this synonym for HAVE_NETCDF_PAR. It is defined in config.h.
if (HAVE_NETCDF_PAR)
set(_NETCDF4 1)
endif ()

###
# Check to see if szip write capability is present in netcdf-c.
###
Expand Down
13 changes: 10 additions & 3 deletions cmake_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,22 @@

#define USE_VARD @USE_VARD@

/* Does netCDF support netCDF/HDF5 files? */
#cmakedefine HAVE_NETCDF4

/* Does netCDF support parallel I/O for netCDF/HDF5 files? */
#cmakedefine HAVE_NETCDF_PAR

/* Does PIO support netCDF/HDF5 files? (Will be same as
* HAVE_NETCDF_PAR). */
#cmakedefine _NETCDF4

/* Does netCDF and HDF5 support parallel I/O filters? */
#cmakedefine HAVE_PAR_FILTERS

/* Was PIO built with netCDF integration? */
#cmakedefine NETCDF_INTEGRATION

/* Does PIO support netCDF/HDF5 files? */
#cmakedefine _NETCDF4

/* Does PIO support using pnetcdf for I/O? */
#cmakedefine _PNETCDF

Expand Down
2 changes: 2 additions & 0 deletions libpio.settings.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ Parallel Filters: @HAS_PAR_FILTERS@
NetCDF/HDF5 Support: @HAS_NETCDF4@
NetCDF/HDF5 Par I/O: @HAS_NETCDF4_PAR@
NetCDF Integration: @HAS_NETCDF_INTEGRATION@
PIO Logging: @HAS_LOGGING@
MPIEXEC: @WITH_MPIEXEC@

16 changes: 0 additions & 16 deletions src/clib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,32 +94,19 @@ endif ()
if (NetCDF_C_FOUND)
target_include_directories (pioc
PUBLIC ${NetCDF_C_INCLUDE_DIRS})
target_compile_definitions (pioc
PUBLIC _NETCDF)
target_link_libraries (pioc
PUBLIC ${NetCDF_C_LIBRARIES})
if (${NetCDF_C_HAS_PARALLEL})
target_compile_definitions (pioc
PUBLIC _NETCDF4)
endif ()
if (${NetCDF_C_LOGGING_ENABLED})
target_compile_definitions (pioc
PUBLIC NETCDF_C_LOGGING_ENABLED)
# netcdf.h needs this to be defined to use netCDF logging.
target_compile_definitions (pioc
PUBLIC LOGGING)
endif()
else ()
target_compile_definitions (pioc
PUBLIC _NONETCDF)
endif ()

#===== PnetCDF-C =====
if (PnetCDF_C_FOUND)
target_include_directories (pioc
PUBLIC ${PnetCDF_C_INCLUDE_DIRS})
target_compile_definitions (pioc
PUBLIC _PNETCDF)
target_link_libraries (pioc
PUBLIC ${PnetCDF_C_LIBRARIES})

Expand All @@ -131,9 +118,6 @@ if (PnetCDF_C_FOUND)
PUBLIC USE_PNETCDF_VARN
PUBLIC USE_PNETCDF_VARN_ON_READ)
endif()
else ()
target_compile_definitions (pioc
PUBLIC _NOPNETCDF)
endif ()

#===== Add EXTRAs =====
Expand Down
1 change: 1 addition & 0 deletions src/clib/pio_meta.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
#define PIO_HAS_NETCDF4 @PIO_HAS_NETCDF4@ /*!< NetCDF-4 supported. */
#define PIO_HAS_NETCDF4_PAR @PIO_HAS_NETCDF4_PAR@ /*!< NetCDF-4 parallel I/O supported. */
#define PIO_HAS_NETCDF_INTEGRATION @PIO_HAS_NETCDF_INTEGRATION@ /*!< NetCDF integration supported. */
#define PIO_HAS_LOGGING @PIO_HAS_LOGGING@ /*!< PIO logging turned on. */

#endif
8 changes: 0 additions & 8 deletions src/clib/pioc_support.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,6 @@ PIOc_set_log_level(int level)
/* Set the log level. */
pio_log_level = level;

#if NETCDF_C_LOGGING_ENABLED
int ret;

/* If netcdf logging is available turn it on starting at level = 4. */
if (level > NC_LEVEL_DIFF)
if ((ret = nc_set_log_level(level - NC_LEVEL_DIFF)))
return pio_err(NULL, NULL, ret, __FILE__, __LINE__);
#endif /* NETCDF_C_LOGGING_ENABLED */
#endif /* PIO_ENABLE_LOGGING */

return PIO_NOERR;
Expand Down
14 changes: 0 additions & 14 deletions src/flib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,25 +216,14 @@ endif ()
if (NetCDF_Fortran_FOUND)
target_include_directories (piof
PUBLIC ${NetCDF_Fortran_INCLUDE_DIRS})
target_compile_definitions (piof
PUBLIC _NETCDF)
target_link_libraries (piof
PUBLIC ${NetCDF_Fortran_LIBRARIES})
if (EXISTS ${NetCDF_Fortran_INCLUDE_DIR}/netcdf_par.h)
target_compile_definitions (piof
PUBLIC _NETCDF4)
endif ()
else ()
target_compile_definitions (piof
PUBLIC _NONETCDF)
endif ()

#===== PnetCDF =====
if (PnetCDF_Fortran_FOUND)
target_include_directories (piof
PUBLIC ${PnetCDF_Fortran_INCLUDE_DIRS})
target_compile_definitions (piof
PUBLIC _PNETCDF)
target_link_libraries (piof
PUBLIC ${PnetCDF_Fortran_LIBRARIES})

Expand All @@ -246,9 +235,6 @@ if (PnetCDF_Fortran_FOUND)
PUBLIC USE_PNETCDF_VARN
PUBLIC USE_PNETCDF_VARN_ON_READ)
endif()
else ()
target_compile_definitions (piof
PUBLIC _NOPNETCDF)
endif ()

#===== Add EXTRAs =====
Expand Down

0 comments on commit 22d1160

Please sign in to comment.