forked from JCSDA/saber
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
132 lines (115 loc) · 4.29 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# (C) Copyright 2017-2020 UCAR.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
################################################################################
# SABER
################################################################################
cmake_minimum_required( VERSION 3.12 )
project( saber VERSION 1.10.0 LANGUAGES CXX Fortran )
option(OPENMP "Build saber with OpenMP support" ON)
## Ecbuild integration
find_package( ecbuild QUIET )
include( ecbuild_system NO_POLICY_SCOPE )
ecbuild_declare_project()
list( APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake )
set( CMAKE_DIRECTORY_LABELS ${PROJECT_NAME} )
## Configuration options
option( ENABLE_SABER_INSTRUMENTATION "Enable SABER instrumentation" OFF )
option( ENABLE_OFFLINE_CODECOV "Enable SABER offline code coverage" OFF )
option( ENABLE_SABER_DOC "Enable SABER documentation" OFF )
option( ENABLE_MKL "Use MKL for LAPACK implementation (if available)" ON )
include( ${PROJECT_NAME}_compiler_flags )
## Dependencies
# Required
find_package( jedicmake REQUIRED ) # Prefer find modules from jedi-cmake
if(OPENMP)
find_package( OpenMP REQUIRED COMPONENTS CXX Fortran )
endif()
find_package( MPI REQUIRED COMPONENTS Fortran )
find_package( NetCDF REQUIRED COMPONENTS C Fortran )
find_package( eckit 1.24.4 REQUIRED COMPONENTS MPI )
find_package( fckit 0.11.0 REQUIRED )
find_package( atlas 0.35.0 REQUIRED COMPONENTS OMP_Fortran TESSELATION)
# TODO(Benjamin): check when ATLAS PR #215 is merged into a tagged version to update the version number
if( atlas_VERSION VERSION_GREATER "0.38.1" )
set( ATLAS_REGIONAL_INTERP ON )
else()
set( ATLAS_REGIONAL_INTERP OFF )
endif()
if( DEFINED ENV{ATLAS_REGIONAL_INTERP} )
set( ATLAS_REGIONAL_INTERP $ENV{ATLAS_REGIONAL_INTERP} )
endif()
if( ENABLE_MKL )
find_package( MKL )
endif()
if( ENABLE_MKL AND MKL_FOUND )
set( LAPACK_LIBRARIES ${MKL_LIBRARIES} )
else()
find_package( LAPACK REQUIRED )
endif()
# Required
find_package( oops 1.10.0 REQUIRED )
find_package( vader 1.7.0 REQUIRED )
# Optionals
find_package( FFTW 3.3.8 QUIET )
find_package( gsibec 1.2.1 QUIET )
find_package( eccodes 2.24 QUIET )
if( eccodes_FOUND )
set( ECCODES_LIBRARIES eccodes )
add_definitions(-DECCODES_FOUND=1)
endif()
# Optional SABER blocks
if( gsibec_FOUND )
find_package( sp QUIET )
message( STATUS "SABER block GSI is enabled" )
else()
message( STATUS "SABER block GSI is NOT enabled" )
endif()
if( FFTW_FOUND )
message( STATUS "SABER block FastLAM spectral layer is enabled" )
else()
message( STATUS "SABER block FastLAM spectral layer is NOT enabled" )
endif()
if( atlas_TRANS_FOUND OR atlas_ECTRANS_FOUND )
message( STATUS "SABER block SPECTRALB is enabled" )
else()
message( STATUS "SABER block SPECTRALB is NOT enabled" )
endif()
## SABER instrumentation
if( ENABLE_SABER_INSTRUMENTATION )
message( STATUS "SABER instrumentation is enabled" )
add_definitions(-DENABLE_SABER_INSTRUMENTATION=1)
else()
message( STATUS "SABER instrumentation is not enabled" )
add_definitions(-DENABLE_SABER_INSTRUMENTATION=0)
endif()
## Code coverage
if ( ENABLE_OFFLINE_CODECOV )
message( STATUS "Offline code coverage is enabled" )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
set( CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -fprofile-arcs -ftest-coverage")
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -fprofile-arcs -ftest-coverage")
set( CMAKE_Fortran_LINK_FLAGS "${CMAKE_Fortran_LINK_FLAGS} -fprofile-arcs -ftest-coverage")
else()
message( STATUS "Offline code coverage is not enabled" )
endif()
## Sources
add_subdirectory( quench )
add_subdirectory( src/saber )
add_subdirectory( tools )
add_subdirectory( test )
if( ENABLE_SABER_DOC )
message( STATUS "SABER documentation is enabled" )
add_subdirectory( docs )
else()
message( STATUS "SABER documentation is not enabled" )
endif()
## Global tests
ecbuild_add_test( TARGET saber_coding_norms_src
TYPE SCRIPT
COMMAND ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}_cpplint.py
ARGS --quiet --recursive ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/src )
## Package Config
ecbuild_install_project( NAME ${PROJECT_NAME} )
ecbuild_print_summary()