2010-09-12 21:09:39 +02:00
|
|
|
cmake_minimum_required(VERSION 2.6)
|
2011-05-31 16:08:44 +02:00
|
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
|
2010-09-12 21:09:39 +02:00
|
|
|
|
|
|
|
project(CosmoToolbox)
|
|
|
|
|
2011-05-31 16:08:44 +02:00
|
|
|
include(GetGitRevisionDescription)
|
2012-11-10 17:10:04 +01:00
|
|
|
include(ExternalProject)
|
2012-11-10 18:22:37 +01:00
|
|
|
include(FindOpenMP)
|
2011-05-31 16:08:44 +02:00
|
|
|
|
|
|
|
get_git_head_revision(HEAD GIT_VER)
|
|
|
|
|
2010-09-15 20:51:18 +02:00
|
|
|
option(BUILD_SHARED_LIBS "Build shared libraries." OFF)
|
2011-06-28 15:08:14 +02:00
|
|
|
option(BUILD_STATIC_LIBS "Build static libraries." ON)
|
2012-11-10 18:22:37 +01:00
|
|
|
option(ENABLE_OPENMP "Enable OpenMP support." OFF)
|
2013-03-19 14:25:45 +01:00
|
|
|
option(ENABLE_SHARP "Enable SPHT support." ON)
|
2010-09-15 20:51:18 +02:00
|
|
|
|
2010-09-12 21:09:39 +02:00
|
|
|
find_path(NETCDF_INCLUDE_PATH NAMES netcdf.h)
|
2012-09-16 00:53:47 +02:00
|
|
|
find_path(NETCDFCPP_INCLUDE_PATH NAMES netcdfcpp.h netcdf)
|
2010-09-12 21:36:37 +02:00
|
|
|
find_path(GSL_INCLUDE_PATH NAMES gsl/gsl_blas.h)
|
2014-02-21 09:34:15 +01:00
|
|
|
find_library(NETCDFCPP_LIBRARY NAMES netcdf_c++ netcdf_c++4)
|
2010-09-12 21:09:39 +02:00
|
|
|
|
2014-02-21 09:34:15 +01:00
|
|
|
IF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4")
|
2012-09-19 15:15:09 +02:00
|
|
|
SET(FOUND_NETCDF4 1)
|
2012-09-16 00:53:47 +02:00
|
|
|
FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#define NETCDFCPP4 1")
|
2014-02-21 09:34:15 +01:00
|
|
|
ELSE(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4")
|
2012-09-19 15:15:09 +02:00
|
|
|
SET(FOUND_NETCDF3 1)
|
2012-09-16 00:53:47 +02:00
|
|
|
FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#undef NETCDFCPP4")
|
2014-02-21 09:34:15 +01:00
|
|
|
ENDIF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4")
|
2012-09-16 00:53:47 +02:00
|
|
|
|
2010-09-12 21:09:39 +02:00
|
|
|
find_library(NETCDF_LIBRARY netcdf)
|
2010-09-12 21:36:37 +02:00
|
|
|
find_library(GSL_LIBRARY gsl)
|
|
|
|
find_library(GSLCBLAS_LIBRARY gslcblas)
|
2010-09-12 21:09:39 +02:00
|
|
|
|
2013-03-19 14:25:45 +01:00
|
|
|
if (ENABLE_SHARP)
|
|
|
|
SET(SHARP_SOURCE ${CMAKE_SOURCE_DIR}/external/sharp)
|
|
|
|
SET(DEP_BUILD ${CMAKE_SOURCE_DIR}/external/sharp/auto)
|
|
|
|
ExternalProject_Add(sharp
|
|
|
|
SOURCE_DIR ${SHARP_SOURCE}
|
|
|
|
BUILD_IN_SOURCE 1
|
2014-04-10 09:12:01 +02:00
|
|
|
CONFIGURE_COMMAND ${SHARP_SOURCE}/configure "CC=${CMAKE_C_COMPILER}" "CXX=${CMAKE_CXX_COMPILER}" --prefix=${DEP_BUILD}
|
2013-03-19 14:25:45 +01:00
|
|
|
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM}
|
|
|
|
INSTALL_COMMAND echo "No install"
|
|
|
|
)
|
2013-04-07 20:44:04 +02:00
|
|
|
SET(CUTILS_LIBRARY ${DEP_BUILD}/lib/libc_utils.a)
|
|
|
|
SET(FFTPACK_LIBRARY ${DEP_BUILD}/lib/libfftpack.a)
|
2013-03-19 14:25:45 +01:00
|
|
|
SET(SHARP_LIBRARY ${DEP_BUILD}/lib/libsharp.a)
|
2013-04-07 20:44:04 +02:00
|
|
|
SET(SHARP_LIBRARIES ${SHARP_LIBRARY} ${FFTPACK_LIBRARY} ${CUTILS_LIBRARY})
|
2013-03-19 14:25:45 +01:00
|
|
|
SET(SHARP_INCLUDE_PATH ${DEP_BUILD}/include)
|
|
|
|
endif (ENABLE_SHARP)
|
|
|
|
|
2012-11-10 15:02:08 +01:00
|
|
|
|
2012-09-20 07:59:46 +02:00
|
|
|
set(HDF5_FIND_COMPONENTS HL CXX)
|
|
|
|
if(HDF5_ROOTDIR)
|
|
|
|
SET(ENV{HDF5_ROOT} ${HDF5_ROOTDIR})
|
|
|
|
endif(HDF5_ROOTDIR)
|
2011-06-06 15:56:54 +02:00
|
|
|
include(FindHDF5)
|
2010-09-12 21:09:39 +02:00
|
|
|
|
2012-10-06 18:56:33 +02:00
|
|
|
include(FindPkgConfig)
|
|
|
|
|
|
|
|
pkg_check_modules(FFTW3 fftw3>=3.3)
|
2012-11-11 20:30:45 +01:00
|
|
|
pkg_check_modules(FFTW3F fftw3f>=3.3)
|
2012-10-06 18:56:33 +02:00
|
|
|
pkg_check_modules(EIGEN3 eigen3)
|
2010-09-12 21:09:39 +02:00
|
|
|
|
2014-02-27 15:30:21 +01:00
|
|
|
|
|
|
|
find_library(FFTW3F_LIBRARY_FULL fftw3f PATHS ${FFTW3F_LIBDIR} NO_DEFAULT_PATH)
|
|
|
|
find_library(FFTW3_LIBRARY_FULL fftw3 PATHS ${FFTW3_LIBDIR} NO_DEFAULT_PATH)
|
|
|
|
|
2010-09-12 21:09:39 +02:00
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
set(NETCDF_FIND_REQUIRED TRUE)
|
2010-09-12 21:36:37 +02:00
|
|
|
set(GSL_FIND_REQUIRED TRUE)
|
2010-09-12 21:09:39 +02:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(NetCDF DEFAULT_MSG NETCDF_LIBRARY NETCDFCPP_LIBRARY NETCDF_INCLUDE_PATH)
|
2010-09-12 21:36:37 +02:00
|
|
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GSL DEFAULT_MSG GSL_LIBRARY GSLCBLAS_LIBRARY GSL_INCLUDE_PATH)
|
2010-09-12 21:09:39 +02:00
|
|
|
|
2014-05-05 12:07:55 +02:00
|
|
|
IF(ENABLE_OPENMP)
|
|
|
|
|
|
|
|
IF (NOT OPENMP_FOUND)
|
|
|
|
MESSAGE(ERROR "No known compiler option for enabling OpenMP")
|
|
|
|
ENDIF(NOT OPENMP_FOUND)
|
|
|
|
|
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
|
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
|
|
|
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKED_FLAGS} ${OpenMP_C_FLAGS}")
|
|
|
|
ENDIF(ENABLE_OPENMP)
|
|
|
|
|
|
|
|
|
2010-09-12 21:22:20 +02:00
|
|
|
|
2011-12-03 16:00:38 +01:00
|
|
|
set(GSL_LIBRARIES ${GSL_LIBRARY} ${GSLCBLAS_LIBRARY})
|
|
|
|
|
2010-09-12 21:22:20 +02:00
|
|
|
# CPACK Configuration
|
|
|
|
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A toolbox for impatient cosmologists")
|
|
|
|
SET(CPACK_PACKAGE_VENDOR "Guilhem Lavaux")
|
|
|
|
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENCE_CeCILL_V2")
|
|
|
|
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
|
|
|
|
SET(CPACK_PACKAGE_VERSION_MINOR "0")
|
2011-05-31 16:08:44 +02:00
|
|
|
SET(CPACK_PACKAGE_VERSION_PATCH "0-${GIT_VER}")
|
2010-09-12 21:22:20 +02:00
|
|
|
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "CosmoToolbox-${GalaxExplorer_VERSION_MAJOR}.${GalaxExplorer_VERSION_MINOR}")
|
|
|
|
SET(CPACK_STRIP_FILES "lib/libCosmoTool.so")
|
|
|
|
SET(CPACK_SOURCE_IGNORE_FILES
|
|
|
|
"/CVS/;/\\\\.git/;/\\\\.svn/;\\\\.swp$;\\\\.#;/#;.*~;cscope.*;/CMakeFiles/;.*\\\\.cmake;Makefile")
|
|
|
|
|
2010-09-12 21:09:39 +02:00
|
|
|
add_subdirectory(src)
|
2010-09-12 21:36:37 +02:00
|
|
|
add_subdirectory(sample)
|
2010-09-12 21:22:20 +02:00
|
|
|
|
|
|
|
include(CPack)
|