-
Notifications
You must be signed in to change notification settings - Fork 8
/
CMakeLists.txt
128 lines (113 loc) · 4.23 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
# (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.4.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_DOC "Build 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 Fortran )
endif()
find_package( MPI REQUIRED COMPONENTS Fortran )
find_package( NetCDF REQUIRED COMPONENTS C Fortran )
find_package( eckit 1.11.6 REQUIRED COMPONENTS MPI )
find_package( fckit 0.7.0 REQUIRED )
find_package( atlas 0.27.0 REQUIRED COMPONENTS OMP_Fortran )
if( ENABLE_MKL )
find_package( MKL )
endif()
if( MKL_FOUND )
set( LAPACK_LIBRARIES ${MKL_LIBRARIES} )
else()
find_package( LAPACK REQUIRED )
endif()
# Optionals
find_package( oops QUIET OPTIONAL_COMPONENTS qg )
find_package( gsibec 1.0.5 QUIET )
find_package( vader QUIET )
# Optional SABER blocks
if( gsibec_FOUND )
find_package( sp QUIET )
message( STATUS "SABER block GSI is enabled" )
add_definitions(-DENABLE_GSIBEC=1)
else()
message( STATUS "SABER block GSI is not enabled" )
add_definitions(-DENABLE_GSIBEC=0)
endif()
# TODO(Benjamin): remove this line once ATLAS is upgraded to 0.30.0 everywhere
set( ENABLE_SPECTRALB 0 )
if( atlas_VERSION GREATER_EQUAL 0.30.0 )
message( STATUS "ATLAS version higher or equal to 0.30.0" )
if( atlas_TRANS_FOUND )
message( STATUS "SABER block SPECTRALB is enabled" )
add_definitions(-Datlas_TRANS_FOUND=1)
set( ENABLE_SPECTRALB 1 )
else()
message( STATUS "SABER block SPECTRALB is not enabled" )
add_definitions(-Datlas_TRANS_FOUND=0)
endif()
else()
message( STATUS "ATLAS version lower than 0.30.0" )
message( STATUS "SABER block SPECTRALB is not enabled" )
add_definitions(-Datlas_TRANS_FOUND=0)
endif()
if( vader_FOUND )
if ( ENABLE_VADER_MO )
message( STATUS "SABER blocks VADER are enabled (with MO-specific blocks)" )
add_definitions(-DENABLE_VADER_MO=1)
else()
message( STATUS "SABER blocks VADER are enabled (without MO-specific blocks)" )
add_definitions(-DENABLE_VADER_MO=0)
endif()
add_definitions(-DENABLE_VADER=1)
else()
message( STATUS "SABER blocks VADER are not enabled" )
add_definitions(-DENABLE_VADER=0)
endif()
## SABER instrumentation
set( ENABLE_SABER_INSTRUMENTATION 0 )
if( DEFINED ENV{ENABLE_SABER_INSTRUMENTATION} )
set( ENABLE_SABER_INSTRUMENTATION $ENV{ENABLE_SABER_INSTRUMENTATION} )
endif()
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()
## Sources
add_subdirectory( src/saber )
add_subdirectory( tools ) # tools is needed for test
add_subdirectory( test )
if( ENABLE_SABER_DOC )
add_subdirectory( docs )
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 )
ecbuild_add_test( TARGET saber_coding_norms_test
TYPE SCRIPT
COMMAND ${CMAKE_BINARY_DIR}/bin/${PROJECT_NAME}_cpplint.py
ARGS --quiet --recursive ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}/test )
## Package Config
ecbuild_install_project( NAME ${PROJECT_NAME} )
ecbuild_print_summary()