Added support for netcdf c++ 4.2

This commit is contained in:
Guilhem Lavaux 2012-09-15 18:53:47 -04:00
parent 0afe7b7eab
commit 26a2e15cbe
3 changed files with 15 additions and 2 deletions

View File

@ -11,10 +11,17 @@ option(BUILD_SHARED_LIBS "Build shared libraries." OFF)
option(BUILD_STATIC_LIBS "Build static libraries." ON)
find_path(NETCDF_INCLUDE_PATH NAMES netcdf.h)
find_path(NETCDFCPP_INCLUDE_PATH NAMES netcdfcpp.h netcdf)
find_path(GSL_INCLUDE_PATH NAMES gsl/gsl_blas.h)
IF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf)
FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#define NETCDFCPP4 1")
ELSE(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf)
FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#undef NETCDFCPP4")
ENDIF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf)
find_library(NETCDF_LIBRARY netcdf)
find_library(NETCDFCPP_LIBRARY netcdf_c++)
find_library(NETCDFCPP_LIBRARY NAMES netcdf_c++ netcdf_c++4)
find_library(GSL_LIBRARY gsl)
find_library(GSLCBLAS_LIBRARY gslcblas)

View File

@ -46,7 +46,7 @@ SET(CosmoTool_SRCS ${CosmoTool_SRCS}
growthFactor.hpp
)
include_directories(${GSL_INCLUDE_PATH} ${NETCDF_INCLUDE_PATH})
include_directories(${GSL_INCLUDE_PATH} ${NETCDF_INCLUDE_PATH} ${NETCDFCPP_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src)
set(CosmoTool_LIBS ${NETCDF_LIBRARY} ${NETCDFCPP_LIBRARY} ${GSL_LIBRARIES})
if (HDF5_FOUND)

View File

@ -1,5 +1,11 @@
#include "ctool_netcdf_ver.hpp"
#include "config.hpp"
#ifdef NETCDFCPP4
#include <netcdf>
using namespace netCDF
#else
#include <netcdfcpp.h>
#endif
#include <fstream>
#include "yorick.hpp"
#include <assert.h>