Fix compilation process. Fix compile error on new compiler

This commit is contained in:
Guilhem Lavaux 2017-08-09 17:24:54 +02:00
parent 8cbec6637c
commit 170e7b7020
4 changed files with 55 additions and 32 deletions

View File

@ -6,7 +6,8 @@ SET(FFTW_URL "http://www.fftw.org/fftw-3.3.3.tar.gz" CACHE URL "URL to download
SET(EIGEN_URL "http://bitbucket.org/eigen/eigen/get/3.2.10.tar.gz" CACHE URL "URL to download Eigen from")
SET(GENGETOPT_URL "ftp://ftp.gnu.org/gnu/gengetopt/gengetopt-2.22.5.tar.gz" CACHE STRING "URL to download gengetopt from")
SET(HDF5_URL "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.8/hdf5-1.8.18/src/hdf5-1.8.18.tar.gz" CACHE STRING "URL to download HDF5 from")
SET(NETCDF_URL "http://www.unidata.ucar.edu/downloads/netcdf/ftp/netcdf-4.1.3.tar.gz" CACHE STRING "URL to download NetCDF from")
SET(NETCDF_URL "ftp://ftp.unidata.ucar.edu/pub/netcdf/netcdf-4.4.1.1.tar.gz" CACHE STRING "URL to download NetCDF from")
SET(NETCDFCXX_URL "https://github.com/Unidata/netcdf-cxx4/archive/v4.3.0.tar.gz" CACHE STRING "URL to download NetCDF-C++ from")
SET(BOOST_URL "http://sourceforge.net/projects/boost/files/boost/1.61.0/boost_1_61_0.tar.gz/download" CACHE STRING "URL to download Boost from")
SET(GSL_URL "ftp://ftp.gnu.org/gnu/gsl/gsl-1.15.tar.gz" CACHE STRING "URL to download GSL from ")
mark_as_advanced(FFTW_URL EIGEN_URL HDF5_URL NETCDF_URL BOOST_URL GSL_URL)
@ -77,13 +78,14 @@ if (INTERNAL_HDF5)
ExternalProject_Add(hdf5
PREFIX ${BUILD_PREFIX}/hdf5-prefix
URL ${HDF5_URL}
CONFIGURE_COMMAND ${HDF5_SOURCE_DIR}/configure
--disable-shared --enable-cxx --with-pic
--prefix=${HDF5_BIN_DIR} --libdir=${HDF5_BIN_DIR}/lib
CPPFLAGS=${CONFIGURE_CPP_FLAGS} CC=${CMAKE_C_COMPILER}
CXX=${CMAKE_CXX_COMPILER}
BUILD_IN_SOURCE 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${EXT_INSTALL}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DHDF5_BUILD_CPP_LIB=ON
-DHDF5_BUILD_TOOLS=ON
-DHDF5_BUILD_HL_LIB=ON
-DBUILD_SHARED_LIBS=OFF
)
SET(cosmotool_DEPS ${cosmotool_DEPS} hdf5)
SET(hdf5_built hdf5)
@ -142,7 +144,7 @@ endforeach(include_dir)
if (INTERNAL_NETCDF)
SET(NETCDF_SOURCE_DIR ${BUILD_PREFIX}/netcdf-prefix/src/netcdf)
SET(NETCDF_BIN_DIR ${EXT_INSTALL})
# SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${NETCDF_BIN_DIR}/include")
SET(CONFIGURE_CPP_FLAGS "${CONFIGURE_CPP_FLAGS} -I${NETCDF_BIN_DIR}/include")
SET(CONFIGURE_LDFLAGS "${CONFIGURE_LDFLAGS} -L${NETCDF_BIN_DIR}/lib")
SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LIBS=${CONFIGURE_LIBS} LDFLAGS=${CONFIGURE_LDFLAGS})
SET(NETCDF_CONFIG_COMMAND ${NETCDF_SOURCE_DIR}/configure
@ -155,15 +157,36 @@ if (INTERNAL_NETCDF)
DEPENDS ${hdf5_built}
PREFIX ${BUILD_PREFIX}/netcdf-prefix
URL ${NETCDF_URL}
CONFIGURE_COMMAND ${NETCDF_CONFIG_COMMAND}
BUILD_IN_SOURCE 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
CMAKE_ARGS
-DCMAKE_PREFIX_PATH=${EXT_INSTALL}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DBUILD_SHARED_LIBS=OFF
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=Release
-DENABLE_NETCDF4=ON
-DENABLE_DAP=OFF
-DCMAKE_INSTALL_PREFIX=${NETCDF_BIN_DIR}
)
SET(NETCDFCXX_SOURCE_DIR ${BUILD_PREFIX}/netcdf-c++-prefix/src/netcdf-c++)
ExternalProject_Add(netcdf-c++
DEPENDS ${hdf5_built} netcdf
PREFIX ${BUILD_PREFIX}/netcdf-c++-prefix
URL ${NETCDFCXX_URL}
CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DBUILD_SHARED_LIBS=OFF
-DBUILD_TESTING=OFF
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${NETCDF_BIN_DIR}
)
# SET(CONFIGURE_CPP_LDFLAGS "${CONFIGURE_LDFLAGS}")
# SET(EXTRA_NC_FLAGS CPPFLAGS=${CONFIGURE_CPP_FLAGS} LDFLAGS=${CONFIGURE_CPP_LDFLAGS})
SET(cosmotool_DEPS ${cosmotool_DEPS} netcdf)
SET(cosmotool_DEPS ${cosmotool_DEPS} netcdf netcdf-c++)
SET(NETCDF_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf.a CACHE STRING "NetCDF lib" FORCE)
SET(NETCDFCPP_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf_c++4.a CACHE STRING "NetCDF-C++ lib" FORCE)
SET(NETCDFCPP_LIBRARY ${NETCDF_BIN_DIR}/lib/libnetcdf-cxx4.a CACHE STRING "NetCDF-C++ lib" FORCE)
SET(NETCDF_INCLUDE_PATH ${NETCDF_BIN_DIR}/include CACHE STRING "NetCDF include" FORCE)
SET(NETCDFCPP_INCLUDE_PATH ${NETCDF_INCLUDE_PATH} CACHE STRING "NetCDF C++ include path" FORCE)

View File

@ -62,7 +62,7 @@ void computeInterpolatedField(MyTree *tree1, double boxsize, int Nres, double cx
{
double px = (rx)*boxsize/Nres-cx;
MyTree::coords c = { px, py, pz };
MyTree::coords c = { float(px), float(py), float(pz) };
double r2 = c[0]*c[0]+c[1]*c[1]+c[2]*c[2];
if (r2 > rLimit2)
@ -179,7 +179,7 @@ int main(int argc, char **argv)
{
double px = (rx)*boxsize/Nres-cx;
MyTree::coords c = { px, py, pz };
MyTree::coords c = { float(px), float(py), float(pz) };
double r2 = c[0]*c[0]+c[1]*c[1]+c[2]*c[2];
if (r2 > rLimit2)

View File

@ -75,7 +75,7 @@ int main()
cout << "iy=" << iy << endl;
for (uint32_t ix = 0; ix < NX; ix++)
{
MyTree::coords c = { 1.0*ix/NX, 1.0*iy/NX };
MyTree::coords c = { 1.0f*ix/NX, 1.0f*iy/NX };
smooth.fetchNeighbours(c);
smooth.addGridSite(c);
}
@ -92,7 +92,7 @@ int main()
cout << "iy=" << iy << endl;
for (uint32_t ix = 0; ix < NX; ix++)
{
MyTree::coords c = { 1.0*ix/NX, 1.0*iy/NX };
MyTree::coords c = { 1.0f*ix/NX, 1.0f*iy/NX };
smooth.fetchNeighbours(c, &state);
out.put(smooth.computeSmoothedValue(c, unit_fun, &state));

View File

@ -1,18 +1,18 @@
SET(CosmoTool_SRCS
fortran.cpp
interpolate.cpp
load_data.cpp
loadRamses.cpp
powerSpectrum.cpp
miniargs.cpp
growthFactor.cpp
cosmopower.cpp
cic.cpp
)
SET(CosmoTool_SRCS
fortran.cpp
interpolate.cpp
load_data.cpp
loadRamses.cpp
powerSpectrum.cpp
miniargs.cpp
growthFactor.cpp
cosmopower.cpp
cic.cpp
)
IF (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
IF (Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
SET(CosmoTool_SRCS
${CosmoTool_SRCS}
loadGadget.cpp
@ -78,7 +78,7 @@ endif(YORICK_SUPPORT)
if (HDF5_FOUND)
set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES} ${HDF5_CXX_LIBRARIES} ${ZLIB})
include_directories(${HDF5_INCLUDE_DIRS})
include_directories(${HDF5_INCLUDE_DIR})
message(STATUS "CosmoTool_LIBS: ${CosmoTool_LIBS}")
endif (HDF5_FOUND)