|
| 1 | +# (C) Copyright 2019-2019 UCAR. |
| 2 | +# |
| 3 | +# This software is licensed under the terms of the Apache Licence Version 2.0 |
| 4 | +# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. |
| 5 | + |
| 6 | +################################################################################ |
| 7 | +# OISST |
| 8 | +################################################################################ |
| 9 | + |
| 10 | +cmake_minimum_required( VERSION 3.8 FATAL_ERROR ) |
| 11 | + |
| 12 | +project( oisst C CXX Fortran) |
| 13 | + |
| 14 | +set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}) |
| 15 | + |
| 16 | +set( ENABLE_OS_TESTS OFF CACHE BOOL "Disable OS tests" FORCE ) |
| 17 | +set( ENABLE_LARGE_FILE_SUPPORT OFF CACHE BOOL "Disable testing of large file support" FORCE ) |
| 18 | +set( ENABLE_MPI ON CACHE BOOL "Compile with MPI" ) |
| 19 | + |
| 20 | +include( ecbuild_system NO_POLICY_SCOPE ) |
| 21 | + |
| 22 | +ecbuild_requires_macro_version( 2.5 ) |
| 23 | + |
| 24 | + |
| 25 | +################################################################################ |
| 26 | +# Project |
| 27 | +################################################################################ |
| 28 | + |
| 29 | +ecbuild_declare_project() |
| 30 | + |
| 31 | +ecbuild_enable_fortran( REQUIRED ) |
| 32 | +ecbuild_add_cxx11_flags() |
| 33 | + |
| 34 | +set( OISST_LINKER_LANGUAGE CXX ) |
| 35 | + |
| 36 | + |
| 37 | +################################################################################ |
| 38 | +# Dependencies |
| 39 | +################################################################################ |
| 40 | +# Boost Headers |
| 41 | +set( Boost_MINIMUM_VERSION "1.47" ) |
| 42 | +include_directories( ${Boost_INCLUDE_DIR} ) |
| 43 | + |
| 44 | +# NetCDF |
| 45 | +find_package( NetCDF REQUIRED COMPONENTS Fortran ) |
| 46 | +include_directories( ${NETCDF_INCLUDE_DIRS} ) |
| 47 | + |
| 48 | +# eckit |
| 49 | +ecbuild_use_package( PROJECT eckit VERSION 1.1.0 REQUIRED ) |
| 50 | +include_directories( ${ECKIT_INCLUDE_DIRS} ) |
| 51 | +link_libraries( ${ECKIT_LIBRARIES} ) |
| 52 | + |
| 53 | +# fckit |
| 54 | +ecbuild_use_package( PROJECT fckit VERSION 0.4.1 REQUIRED ) |
| 55 | +include_directories( ${FCKIT_INCLUDE_DIRS} ) |
| 56 | + |
| 57 | +# atlas |
| 58 | +ecbuild_use_package( PROJECT atlas VERSION 0.18.1 REQUIRED ) |
| 59 | +include_directories( ${ATLAS_INCLUDE_DIRS} ) |
| 60 | + |
| 61 | +# oops |
| 62 | +ecbuild_use_package( PROJECT oops VERSION 0.1.0 REQUIRED ) |
| 63 | +include_directories( ${OOPS_INCLUDE_DIRS} ) |
| 64 | +add_definitions(-DATLASIFIED=1) |
| 65 | + |
| 66 | +# saber |
| 67 | +ecbuild_use_package( PROJECT saber VERSION 0.0.1 REQUIRED ) |
| 68 | +include_directories( ${SABER_INCLUDE_DIRS} ) |
| 69 | + |
| 70 | +# ioda |
| 71 | +ecbuild_use_package( PROJECT ioda VERSION 0.1.0 REQUIRED ) |
| 72 | +include_directories( ${IODA_INCLUDE_DIRS} ) |
| 73 | + |
| 74 | +# ufo |
| 75 | +ecbuild_use_package( PROJECT ufo VERSION 0.1.0 REQUIRED ) |
| 76 | +include_directories( ${UFO_INCLUDE_DIRS} ) |
| 77 | + |
| 78 | +# MPI |
| 79 | +ecbuild_find_mpi( COMPONENTS CXX Fortran REQUIRED ) |
| 80 | +ecbuild_include_mpi() |
| 81 | +link_libraries(${MPI_CXX_LIBRARIES} ${MPI_Fortran_LIBRARIES}) |
| 82 | + |
| 83 | + |
| 84 | +################################################################################ |
| 85 | +# Export package info |
| 86 | +################################################################################ |
| 87 | +list( APPEND OISST_TPLS atlas atlas_f LAPACK MPI NetCDF ) |
| 88 | + |
| 89 | +set( OISST_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src |
| 90 | + ${CMAKE_CURRENT_BINARY_DIR}/src |
| 91 | + ${CMAKE_Fortran_MODULE_DIRECTORY} ) |
| 92 | +set( OISST_LIBRARIES oisst ) |
| 93 | + |
| 94 | +get_directory_property( OISST_DEFINITIONS COMPILE_DEFINITIONS ) |
| 95 | + |
| 96 | +foreach( _tpl ${OISST_TPLS} ) |
| 97 | +string( TOUPPER ${_tpl} TPL ) |
| 98 | +list( APPEND OISST_EXTRA_DEFINITIONS ${${TPL}_DEFINITIONS} ${${TPL}_TPL_DEFINITIONS} ) |
| 99 | +list( APPEND OISST_EXTRA_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} ${${TPL}_TPL_INCLUDE_DIRS} ) |
| 100 | +list( APPEND OISST_EXTRA_LIBRARIES ${${TPL}_LIBRARIES} ${${TPL}_TPL_LIBRARIES} ) |
| 101 | +endforeach() |
| 102 | + |
| 103 | + |
| 104 | +################################################################################ |
| 105 | +# Sources |
| 106 | +################################################################################ |
| 107 | +include( oisst_compiler_flags ) |
| 108 | +include_directories( ${OISST_INCLUDE_DIRS} ${OISST_EXTRA_INCLUDE_DIRS} ) |
| 109 | + |
| 110 | +add_subdirectory( src ) |
| 111 | +add_subdirectory( test ) |
| 112 | + |
| 113 | +if(ECBUILD_INSTALL_FORTRAN_MODULES) |
| 114 | + install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/${CMAKE_CFG_INTDIR} DESTINATION ${INSTALL_INCLUDE_DIR} ) |
| 115 | +endif() |
| 116 | + |
| 117 | +################################################################################ |
| 118 | +# Finalise configuration |
| 119 | +################################################################################ |
| 120 | + |
| 121 | +# prepares a tar.gz of the sources and/or binaries |
| 122 | +ecbuild_install_project( NAME oisst ) |
| 123 | + |
| 124 | +# print the summary of the configuration |
| 125 | +ecbuild_print_summary() |
0 commit comments