-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
137 lines (101 loc) · 4.18 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
133
134
135
136
# (C) Copyright 2022- ECMWF.
#
# 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.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation
# nor does it submit to any jurisdiction.
cmake_minimum_required( VERSION 3.12 FATAL_ERROR )
find_package( ecbuild 3.4 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild )
if( NOT ECWAM_PROJECT_NAME )
set( ECWAM_PROJECT_NAME ecwam )
endif()
project( ${ECWAM_PROJECT_NAME} LANGUAGES Fortran C CXX )
include( ecwam_macros )
ecbuild_enable_fortran( REQUIRED NO_MODULE_DIRECTORY )
### Dependencies
ecbuild_find_package( fiat REQUIRED )
ecbuild_find_package( eccodes REQUIRED )
### Options
ecbuild_add_option( FEATURE OMP
DESCRIPTION "support for OpenMP shared memory parallelism"
REQUIRED_PACKAGES "OpenMP COMPONENTS Fortran" )
ecbuild_add_option( FEATURE MPI
DESCRIPTION "Support for MPI distributed parallelism"
REQUIRED_PACKAGES "MPI COMPONENTS Fortran" )
ecbuild_add_option( FEATURE MULTIO
DESCRIPTION "Support for IO to the FDB"
REQUIRED_PACKAGES "multio" )
ecbuild_add_option( FEATURE SINGLE_PRECISION
DEFAULT OFF
DESCRIPTION "Support for Single Precision" )
ecbuild_add_option( FEATURE UNWAM
DEFAULT OFF
DESCRIPTION "Support for UNWAM" )
ecbuild_add_option( FEATURE OCEAN_COUPLING
DEFAULT ON
DESCRIPTION "Support ocean coupling"
CONDITION ${PNAME}_OCEANMODEL_LIBRARIES )
ecbuild_add_option( FEATURE ECWAM_LAUNCH
DEFAULT ON
DESCRIPTION "Use share/ecwam/scripts/ecwam-launch script to run ecwam tests" )
if( HAVE_ECWAM_LAUNCH )
# Overwrite meaning of mpiexec
set( ECWAM_LAUNCH ${CMAKE_CURRENT_SOURCE_DIR}/share/ecwam/scripts/ecwam-launch )
set( MPIEXEC_EXECUTABLE ${ECWAM_LAUNCH} )
set( MPIEXEC_NUMPROC_FLAG -n )
set( MPIEXEC_NUMTHREAD_FLAG -c )
set( CMAKE_CROSSCOMPILING_EMULATOR ${ECWAM_LAUNCH} ) # For serial runs
endif()
### field_api
include(cmake/ecwam_fetchcontent_field_api.cmake)
ecbuild_find_package( NAME field_api REQUIRED )
### Optional dependencies
ecbuild_find_package( NAME loki )
ecwam_find_python_mods()
ecbuild_add_option( FEATURE GEN_DERIV_TYPES
DEFAULT ON
DESCRIPTION "Generate derived-type data structures using fypp pre-processor and yaml config"
CONDITION FYPP_FOUND AND PYYAML_FOUND )
### Set third party libraries
if( HAVE_SINGLE_PRECISION )
set( prec sp )
else()
set( prec dp )
endif()
unset( OpenMP_Fortran_LIBRARIES )
if( HAVE_OMP )
set( OpenMP_Fortran_LIBRARIES OpenMP::OpenMP_Fortran )
endif()
### Apply Loki source-to-source transformations to the ecWam physics
ecbuild_add_option( FEATURE WAM_LOKI
DEFAULT OFF
DESCRIPTION "Apply Loki transformations to ecWam physics"
CONDITION loki_FOUND )
# Determine Loki transformation type
if( NOT DEFINED LOKI_MODE )
set( LOKI_MODE "scc-stack" CACHE STRING "Transformation mode for Loki source transformations" )
endif()
# Workaround for the fact that CMake only sets language components to FOUND,
# so OpenACC_FOUND must be set manually
find_package( OpenACC )
if( OpenACC_Fortran_FOUND AND OpenACC_C_FOUND )
set( OpenACC_FOUND ON )
endif()
ecbuild_add_option( FEATURE ACC
DESCRIPTION "OpenACC" DEFAULT OFF
REQUIRED_PACKAGES "OpenACC"
CONDITION HAVE_WAM_LOKI AND NOT LOKI_MODE MATCHES "idem|idem-stack" AND HAVE_GEN_DERIV_TYPES )
### Sources
include(ecwam_compile_flags)
add_subdirectory(src)
add_subdirectory(share)
### Tests
add_subdirectory(tests)
get_property(ecwam_test_configs GLOBAL PROPERTY ecwam_test_configs)
ecwam_cache_bathymetry( ${ecwam_test_configs} )
### Documentation
add_subdirectory(doc)
### Export
ecbuild_install_project( NAME ${PROJECT_NAME} )
ecbuild_print_summary()