-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
207 lines (172 loc) · 6.78 KB
/
CMakeLists.txt
File metadata and controls
207 lines (172 loc) · 6.78 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
# ######################################################################################################################
#
# ADCIRC - The ADvanced CIRCulation model Copyright (C) 1994-2025 R.A. Luettich, Jr., J.J. Westerink
#
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General
# Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along with this program. If not, see
# <http://www.gnu.org/licenses/>.
#
# ######################################################################################################################
# CMake Build File for ADCIRC(+SWAN)
#
# Written By: Zach Cobell
#
# ######################################################################################################################
#
# The CMake build system enable ADCIRC (and SWAN) to be deployed and built in a cross platform environment.
#
# ######################################################################################################################
# Set a default build type if none was specified
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to 'RelWithDebInfo' as none was specified.")
set(CMAKE_BUILD_TYPE
RelWithDebInfo
CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui, ccmake
set_property(
CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS
"Debug"
"Release"
"MinSizeRel"
"RelWithDebInfo")
endif()
# ######################################################################################################################
# GENERAL OPTIONS
# ######################################################################################################################
cmake_minimum_required(VERSION 3.16)
project(adcirc)
# RPATH CONFIGURATION
option(ADCIRC_USE_RPATH "Use RPATH to find shared libraries at runtime" ON)
mark_as_advanced(ADCIRC_USE_RPATH)
if(ADCIRC_USE_RPATH)
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
list(
FIND
CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
isSystemDir)
if("${isSystemDir}" STREQUAL "-1")
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
# ######################################################################################################################
# ######################################################################################################################
# COMPILERS/LANGUAGE
# ######################################################################################################################
# ######################################################################################################################
# ...Perl is required to use SWAN since it generates the source files. All SWAN options will be disabled if perl cannot
# be found.
find_package(Perl)
# ######################################################################################################################
# ######################################################################################################################
# ...Language Specifications
enable_language(Fortran)
enable_language(C)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# ######################################################################################################################
# ######################################################################################################################
# ...Put the static libraries in the CMakeFiles folder so they don't contaminate the build directory
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
# ######################################################################################################################
# ...Set the version string (used for libraries)
set(ADCIRC_VERSION_STRING "v56.2.1")
# Parse version string into components
string(
REGEX
REPLACE "^v"
""
ADCIRC_VERSION_NUMERIC
"${ADCIRC_VERSION_STRING}")
string(
REPLACE "."
";"
VERSION_LIST
${ADCIRC_VERSION_NUMERIC})
list(
GET
VERSION_LIST
0
ADCIRC_VERSION_MAJOR)
list(
GET
VERSION_LIST
1
ADCIRC_VERSION_MINOR)
list(
GET
VERSION_LIST
2
ADCIRC_VERSION_PATCH)
# Set module path for cleaner include() statements
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
# ...Include helper functions to build components
include(helper_functions)
# ...Determine architecture specific parameters
include(architecture)
# ...Generate the selection list of options
include(options_select)
# ...Translate the selected options list into compiler flags
include(options_flags)
# ...Ensure that the netCDF libraries are working
include(netcdf_check)
# GRIB2 requires DATETIME, establish dependency
if(ENABLE_GRIB2 AND NOT ENABLE_DATETIME)
message(STATUS "GRIB2 support requires datetime library, enabling ENABLE_DATETIME")
set(ENABLE_DATETIME
TRUE
CACHE BOOL "Enable datetime library (required by GRIB2)" FORCE)
endif()
# Build datetime_fortran if enabled
if(ENABLE_DATETIME)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/datetime_fortran EXCLUDE_FROM_ALL)
endif()
# Build wgrib2 if GRIB2 is enabled (depends on datetime)
if(ENABLE_GRIB2)
set(JAS_ENABLE_SHARED
FALSE
CACHE BOOL "Enable shared JAS")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/wgrib2 EXCLUDE_FROM_ALL)
endif()
# ...Include the macros for developer mode
include(developer)
# ...Ensure that the XDMF libraries are working
include(xdmf_check)
# ...Build the version module
include(version)
# ...Build the mkdir library
include(mkdir)
# ...Create interface libraries for compiler flags and dependencies
adcirc_create_interface_libraries()
# ...Build ADCIRC
include(adcirc)
# ...Build METIS
include(metis)
# ...Build ADCPREP
include(adcprep)
# ...Build ADCSWAN (Serial ADCIRC+SWAN)
include(adcswan)
# ...Build SWAN (Serial structured SWAN)
include(swan)
# ...Build PADCIRC (Parallel ADCIRC)
include(padcirc)
# ...Build PADCSWAN (Parallel ADCIRC+SWAN)
include(padcswan)
# ...Build PUNSWAN (Parallel Unstructured SWAN)
include(punswan)
# ...Build ASWIP
include(aswip)
# ...Build ADCIRC Utility Codes
include(utilities)
# ...Build LIBADC
include(libadcirc)