Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
143 lines (113 loc) · 4.28 KB
/
Copy pathCMakeLists.txt
File metadata and controls
143 lines (113 loc) · 4.28 KB
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
137
138
139
140
141
142
143
# (C) Crown Copyright Met Office. All rights reserved.
cmake_minimum_required( VERSION 3.26 FATAL_ERROR )
project( opsinputs VERSION 2026 LANGUAGES C CXX Fortran )
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )
set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH} )
set( CMAKE_DIRECTORY_LABELS "opsinputs" )
set( ECBUILD_DEFAULT_BUILD_TYPE Release )
find_package( ecbuild 3.3.2 REQUIRED )
include( ecbuild_system NO_POLICY_SCOPE )
ecbuild_requires_macro_version( 2.7 )
################################################################################
# Project
################################################################################
ecbuild_declare_project()
ecbuild_enable_fortran( REQUIRED )
set( OPSINPUTS_LINKER_LANGUAGE CXX )
################################################################################
# Dependencies
################################################################################
## Dependencies
find_package( jedicmake QUIET ) # Prefer find modules from jedi-cmake
find_package( MPI REQUIRED COMPONENTS C CXX Fortran )
# Boost
include_directories( ${Boost_INCLUDE_DIR} )
# NetCDF
find_package( NetCDF REQUIRED COMPONENTS C CXX Fortran )
# eckit
find_package( eckit REQUIRED )
include_directories( ${ECKIT_INCLUDE_DIRS} )
# fckit
find_package( fckit REQUIRED )
include_directories( ${FCKIT_INCLUDE_DIRS} )
# ufo
find_package( ufo REQUIRED )
include_directories( ${UFO_INCLUDE_DIRS} )
# ioda
find_package( ioda REQUIRED )
include_directories( ${IODA_INCLUDE_DIRS} )
# oops
find_package( oops REQUIRED )
include_directories( ${OOPS_INCLUDE_DIRS} )
find_package(SHUM REQUIRED)
include_directories( ${SHUM_INCLUDE_DIR} )
################################################################################
# Export package info
################################################################################
list( APPEND OPSINPUTS_TPLS ufo ioda oops )
set( OPSINPUTS_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src
${CMAKE_Fortran_MODULE_DIRECTORY} )
set( OPSINPUTS_LIBRARIES opsinputs )
get_directory_property( OPSINPUTS_DEFINITIONS COMPILE_DEFINITIONS )
foreach( _tpl ${OPSINPUTS_TPLS} )
string( TOUPPER ${_tpl} TPL )
list( APPEND OPSINPUTS_EXTRA_DEFINITIONS ${${TPL}_DEFINITIONS} ${${TPL}_TPL_DEFINITIONS} )
list( APPEND OPSINPUTS_EXTRA_INCLUDE_DIRS ${${TPL}_INCLUDE_DIRS} ${${TPL}_TPL_INCLUDE_DIRS} )
list( APPEND OPSINPUTS_EXTRA_LIBRARIES ${${TPL}_LIBRARIES} ${${TPL}_TPL_LIBRARIES} )
endforeach()
################################################################################
# Sources
################################################################################
include( opsinputs_compiler_flags )
add_subdirectory( deps )
add_subdirectory( etc )
add_subdirectory( src )
if( ECBUILD_INSTALL_FORTRAN_MODULES )
install(
DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/${CMAKE_CFG_INTDIR}
DESTINATION ${INSTALL_INCLUDE_DIR}
)
endif()
if( BUILD_TESTING )
add_subdirectory( test )
# We can make use of CMake's native support of cpplint in future. If we set
# `CMAKE_<LANG>_CPPLINT` (where `<LANG>` is either `C` or `CXX`) to point to
# the `cpplint` executable, it will run `cpplint` as part of the build.
find_program(
CPPLINT_EXECUTABLE
NAMES cpplint
DOC "Path to the cpplint executable"
)
if(CPPLINT_EXECUTABLE)
ecbuild_add_test(
TARGET "${PROJECT_NAME}_coding_norms"
LABELS lint
TYPE SCRIPT
COMMAND "${CPPLINT_EXECUTABLE}"
ARGS --quiet --recursive "${CMAKE_CURRENT_SOURCE_DIR}"
)
endif()
find_program(
FORTITUDE_EXECUTABLE
NAMES fortitude
DOC "Path to the Fortitude linter executable"
)
if(FORTITUDE_EXECUTABLE)
ecbuild_add_test(
TARGET "${PROJECT_NAME}_fortitude_check"
LABELS lint
TYPE SCRIPT
COMMAND "${FORTITUDE_EXECUTABLE}"
ARGS check "${CMAKE_CURRENT_SOURCE_DIR}"
)
endif()
endif()
################################################################################
# Finalise configuration
################################################################################
# prepares a tar.gz of the sources and/or binaries
ecbuild_install_project( NAME opsinputs )
# print the summary of the configuration
ecbuild_print_summary()