-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
273 lines (217 loc) · 8.04 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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
# ---------------------------------------------------------------
# Programmer(s): Radu Serban, David J. Gardner, Cody J. Balos,
# and Slaven Peles @ LLNL
# ---------------------------------------------------------------
# SUNDIALS Copyright Start
# Copyright (c) 2002-2022, Lawrence Livermore National Security
# and Southern Methodist University.
# All rights reserved.
#
# See the top-level LICENSE and NOTICE files for details.
#
# SPDX-License-Identifier: BSD-3-Clause
# SUNDIALS Copyright End
# ---------------------------------------------------------------
# Top level CMakeLists.txt for SUNDIALS (for cmake build system)
# ---------------------------------------------------------------
# ===============================================================
# Initial setup.
# ===============================================================
cmake_minimum_required(VERSION 3.12)
# Project SUNDIALS (initially only C supported)
# sets PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR variables.
project(SUNDIALS C)
# Specify the location of additional CMAKE modules
set(CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/cmake
${PROJECT_SOURCE_DIR}/cmake/macros
${PROJECT_SOURCE_DIR}/cmake/tpl
)
# MACRO definitions
include(SundialsCMakeMacros)
include(CMakePrintHelpers)
include(CheckCSourceCompiles)
include(FindPackageHandleStandardArgs)
# Set some variables with info on the SUNDIALS project
set(PACKAGE_BUGREPORT "[email protected]")
set(PACKAGE_NAME "SUNDIALS")
set(PACKAGE_STRING "SUNDIALS 6.1.1-dev")
set(PACKAGE_TARNAME "sundials")
# Set SUNDIALS version numbers
sundials_git_version() # sets SUNDIALS_GIT_VERSION
message(STATUS "SUNDIALS_GIT_VERSION: ${SUNDIALS_GIT_VERSION}")
# (use "" for the version label if none is needed)
set(PACKAGE_VERSION_MAJOR "6")
set(PACKAGE_VERSION_MINOR "1")
set(PACKAGE_VERSION_PATCH "1")
set(PACKAGE_VERSION_LABEL "dev")
if(PACKAGE_VERSION_LABEL)
set(PACKAGE_VERSION
"${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}-${PACKAGE_VERSION_LABEL}"
)
else()
set(PACKAGE_VERSION
"${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}"
)
endif()
# Specify the VERSION and SOVERSION for shared libraries
set(arkodelib_VERSION "5.1.1-dev")
set(arkodelib_SOVERSION "5")
set(cvodelib_VERSION "6.1.1-dev")
set(cvodelib_SOVERSION "6")
set(cvodeslib_VERSION "6.1.1-dev")
set(cvodeslib_SOVERSION "6")
set(idalib_VERSION "6.1.1-dev")
set(idalib_SOVERSION "6")
set(idaslib_VERSION "5.1.1-dev")
set(idaslib_SOVERSION "5")
set(kinsollib_VERSION "6.1.1-dev")
set(kinsollib_SOVERSION "6")
set(cpodeslib_VERSION "0.0.0")
set(cpodeslib_SOVERSION "0")
set(nveclib_VERSION "6.1.1-dev")
set(nveclib_SOVERSION "6")
set(sunmatrixlib_VERSION "4.1.1-dev")
set(sunmatrixlib_SOVERSION "4")
set(sunlinsollib_VERSION "4.1.1-dev")
set(sunlinsollib_SOVERSION "4")
set(sunnonlinsollib_VERSION "3.1.1-dev")
set(sunnonlinsollib_SOVERSION "3")
set(sundialslib_VERSION
"${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}.${PACKAGE_VERSION_PATCH}"
)
set(sundialslib_SOVERSION "${PACKAGE_VERSION_MAJOR}")
# ===============================================================
# Initial Setup
# ===============================================================
# Prohibit in-source build
if("${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_BINARY_DIR}")
print_error("In-source build prohibited.")
endif()
# Organize targets into folders when using an IDE
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Get correct build paths automatically, but expose LIBDIR and
# INCLUDEDIR as a regular cache variable so that a user can more
# easily see what they were set to by GNUInstallDirs.
include(GNUInstallDirs)
mark_as_advanced(CLEAR CMAKE_INSTALL_LIBDIR)
mark_as_advanced(CLEAR CMAKE_INSTALL_INCLUDEDIR)
# Suffixes to use for static and shared targets.
set(_STATIC_LIB_SUFFIX
"_static"
CACHE INTERNAL "" FORCE
)
set(_SHARED_LIB_SUFFIX
"_shared"
CACHE INTERNAL "" FORCE
)
# A list of all the alias targets created.
set(_SUNDIALS_ALIAS_TARGETS ""
CACHE INTERNAL "" FORCE)
# ===============================================================
# Build options to be processed first
# ===============================================================
include(SundialsDeprecated)
include(SundialsBuildOptionsPre)
# ===============================================================
# Options for external packages
# ===============================================================
include(SundialsTPLOptions)
# ===============================================================
# Options for examples
# ===============================================================
include(SundialsExampleOptions)
# ===============================================================
# Setup compilers
# ===============================================================
include(SundialsSetupCompilers)
# ===============================================================
# Setup third-party libraries
# ===============================================================
include(SundialsSetupTPLs)
# ===============================================================
# Build options to be proccessed last
# ===============================================================
include(SundialsBuildOptionsPost)
# ===============================================================
# At this point all the configuration options are set.
# Setup the sundials_config.h.
# ===============================================================
include(SundialsSetupConfig)
# ===============================================================
# Add src and tests; optionally add examples and unit tests.
# ===============================================================
# Add selected packages and modules to the build
add_subdirectory(src)
# Add selected examples to the build
if(_BUILD_EXAMPLES)
include(SundialsSetupTesting)
add_subdirectory(examples)
endif()
# Add benchmarks to the build
if(BUILD_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
# ===============================================================
# Install configuration header files and license file.
# ===============================================================
# install sundials_export header file
install(FILES "${PROJECT_BINARY_DIR}/include/sundials/sundials_export.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials"
)
# install configured header file
install(FILES "${PROJECT_BINARY_DIR}/include/sundials/sundials_config.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials"
)
# install shared Fortran 2003 modules
if(BUILD_FORTRAN_MODULE_INTERFACE)
# While the .mod files get generated for static and shared
# libraries, they are identical. So only install one set
# of the .mod files.
if(BUILD_STATIC_LIBS)
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_STATIC/
DESTINATION ${Fortran_INSTALL_MODDIR}
)
else()
install(DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}_SHARED/
DESTINATION ${Fortran_INSTALL_MODDIR}
)
endif()
endif()
# install license and notice files
install(FILES "${PROJECT_SOURCE_DIR}/LICENSE"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials"
)
install(FILES "${PROJECT_SOURCE_DIR}/NOTICE"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/sundials"
)
# create package version file
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
SUNDIALSConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY SameMajorVersion
)
# install targets
install(
EXPORT sundials-targets
FILE SUNDIALSTargets.cmake
NAMESPACE SUNDIALS::
DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}"
)
# install SUNDIALSConfig.cmake
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/SUNDIALSConfig.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfig.cmake"
INSTALL_DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}"
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSConfigVersion.cmake"
DESTINATION "${SUNDIALS_INSTALL_CMAKEDIR}"
)
# Export targets so build directory can be used directly
export(
EXPORT sundials-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/SUNDIALSTargets.cmake"
NAMESPACE SUNDIALS::
)