forked from NOAA-EMC/saber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
85 lines (72 loc) · 2.77 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
# (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.2.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.20.2 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 )
## 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()