cmake_minimum_required(VERSION 2.6) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") project(CosmoToolbox) include(GetGitRevisionDescription) include(ExternalProject) include(FindOpenMP) include(FindPythonInterp) set(NumPy_FIND_REQUIRED TRUE) include(${CMAKE_SOURCE_DIR}/FindPyLibs.cmake) include(${CMAKE_SOURCE_DIR}/FindNumPy.cmake) get_git_head_revision(HEAD GIT_VER) option(BUILD_SHARED_LIBS "Build shared libraries." OFF) option(BUILD_STATIC_LIBS "Build static libraries." ON) option(ENABLE_OPENMP "Enable OpenMP support." OFF) option(ENABLE_SHARP "Enable SPHT support." ON) IF(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS) SET(CosmoTool_local CosmoTool_static) ELSE(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS) SET(CosmoTool_local CosmoTool) ENDIF(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS) 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) find_library(NETCDFCPP_LIBRARY NAMES netcdf_c++ netcdf_c++4) IF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") SET(FOUND_NETCDF4 1) FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#define NETCDFCPP4 1") ELSE(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") SET(FOUND_NETCDF3 1) FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#undef NETCDFCPP4") ENDIF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") find_library(NETCDF_LIBRARY netcdf) find_library(GSL_LIBRARY gsl) find_library(GSLCBLAS_LIBRARY gslcblas) find_program(CYTHON cython) find_package(Boost 1.53) include(${CMAKE_SOURCE_DIR}/external/external_build.cmake) set(HDF5_FIND_COMPONENTS HL CXX) if(HDF5_ROOTDIR) SET(ENV{HDF5_ROOT} ${HDF5_ROOTDIR}) endif(HDF5_ROOTDIR) include(FindHDF5) include(FindPkgConfig) pkg_check_modules(FFTW3 fftw3>=3.3) pkg_check_modules(FFTW3F fftw3f>=3.3) pkg_check_modules(EIGEN3 eigen3) find_library(FFTW3F_LIBRARY_FULL fftw3f PATHS ${FFTW3F_LIBDIR} NO_DEFAULT_PATH) find_library(FFTW3_LIBRARY_FULL fftw3 PATHS ${FFTW3_LIBDIR} NO_DEFAULT_PATH) include(FindPackageHandleStandardArgs) set(NETCDF_FIND_REQUIRED TRUE) set(GSL_FIND_REQUIRED TRUE) FIND_PACKAGE_HANDLE_STANDARD_ARGS(NetCDF DEFAULT_MSG NETCDF_LIBRARY NETCDFCPP_LIBRARY NETCDF_INCLUDE_PATH) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GSL DEFAULT_MSG GSL_LIBRARY GSLCBLAS_LIBRARY GSL_INCLUDE_PATH) 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_LINKER_FLAGS} ${OpenMP_C_FLAGS}") ENDIF(ENABLE_OPENMP) set(GSL_LIBRARIES ${GSL_LIBRARY} ${GSLCBLAS_LIBRARY}) # 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") SET(CPACK_PACKAGE_VERSION_PATCH "0-${GIT_VER}") 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") add_subdirectory(src) add_subdirectory(sample) add_subdirectory(python) include(CPack)