forked from sxs-collaboration/spectre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
199 lines (170 loc) · 6.13 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
# Distributed under the MIT License.
# See LICENSE.txt for details.
cmake_minimum_required(VERSION 3.18.0)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# Create a new (or overwrite existing) info file at start of configuration
file(WRITE "${CMAKE_BINARY_DIR}/BuildInfo.txt" "")
# Determine the project version and other metadata
include(SpectreLoadMetadata)
# Set up the project. Notes:
# - Fortran is needed for SPHEREPACK
project(${SPECTRE_NAME} VERSION ${SPECTRE_VERSION} LANGUAGES CXX C Fortran)
# Unset the CMake-defined version variable because it strips zeros from the
# version components, e.g. 2020.12.07 becomes 2020.12.7
unset(${SPECTRE_NAME}_VERSION)
# Also unset the version-component variables because they have no meaning in
# our versioning scheme
unset(${SPECTRE_NAME}_VERSION_MAJOR)
unset(${SPECTRE_NAME}_VERSION_MINOR)
unset(${SPECTRE_NAME}_VERSION_PATCH)
# Policies
# The `cmake_minimum_required` above sets policies to `NEW` that are compatible
# with the given minimum cmake version. Here we overwrite policies that we
# have back-ported in our cmake code.
# - We use test names with '.' characters in them
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
cmake_policy(SET CMP0110 NEW)
endif ()
# - Prefer finding Python by location (NEW behavior) instead of always choosing
# the latest version installed on the system (OLD behavior). This allows to
# set `Python_ROOT_DIR` on the command line, like for any other package.
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15)
cmake_policy(SET CMP0094 NEW)
endif()
# Define standard installation directories
include(GNUInstallDirs)
# Disable `make install` depending on `make all` since we want to control what
# we install more closely. With this setting, and targets marked as `OPTIONAL`,
# only targets that were built will be installed.
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY ON)
set(CMAKE_VERBOSE_MAKEFILE OFF)
include(SpectreGetGitHash)
include(SpectreSetSiteName)
# We need Python in the build system and throughout the code. Setting it up
# early so we can rely on a consistent Python version in the build system.
find_package(Python 3.7 REQUIRED)
# Define the location of Python code in the build directory. Unit tests etc. can
# add this location to their `PYTHONPATH`.
set(SPECTRE_PYTHON_PREFIX_PARENT "${CMAKE_BINARY_DIR}/bin/python")
get_filename_component(
SPECTRE_PYTHON_PREFIX_PARENT "${SPECTRE_PYTHON_PREFIX_PARENT}" ABSOLUTE)
set(SPECTRE_PYTHON_SITE_PACKAGES "${CMAKE_BINARY_DIR}/lib/\
python${Python_VERSION_MAJOR}.${Python_VERSION_MINOR}/site-packages")
set(PYTHONPATH "${SPECTRE_PYTHON_PREFIX_PARENT}:\
${SPECTRE_PYTHON_SITE_PACKAGES}")
if(DEFINED ENV{PYTHONPATH})
set(PYTHONPATH "${PYTHONPATH}:$ENV{PYTHONPATH}")
endif()
message(STATUS "PYTHONPATH: ${PYTHONPATH}")
include(BootstrapPyDeps)
option(BUILD_DOCS "Enable building documentation" ON)
option(
DOCS_ONLY
"Skip all initialization not required for rendering documentation"
OFF
)
if (BUILD_DOCS AND DOCS_ONLY)
include(SetupDoxygen)
return()
endif()
include(SpectreInitializeVariables)
include(CheckCompilerVersion)
include(ProhibitInSourceBuild)
include(SpectreSetupFlagsTarget)
include(SetupNinjaColors)
include(SetOutputDirectory)
include(SpectreAddInterfaceLibraryHeaders)
include(SpectreTargetHeaders)
include(SpectreTargetSources)
include(SetupFormaline)
include(SetupGitHooks)
include(SetBuildType)
include(SetupPic)
include(SetCxxStandard)
include(StripSymbols)
# We need Boost for InfoAtLink
include(SetupBoost)
include(SetupInformer)
include(SetupCCache)
include(SetupCraySupport)
include(SetupCharm)
include(EnableWarnings)
include(SetupGoldOrLldLinker)
# In order to use certain code analysis tools like clang-tidy and cppcheck the
# compile commands need to be accessible. CMake can write these to a
# "compile_commands.json" file.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(SetupLIBCXX)
include(SetupSpectreInlining)
include(SetupCxxFlags)
include(SetupProfiling)
include(SetupSanitizers)
include(SetupListTargets)
include(AddSpectreExecutable)
include(CheckBrokenArray0)
# Blaze depends on both Blas and Lapack, since LIBXSMM is a Blas
# alternative we set it up early too.
include(SetupBlas)
include(SetupLapack)
include(SetupLIBXSMM)
include(SetupBlaze)
include(SetupBrigand)
include(SetupGoogleBenchmark)
include(SetupGsl)
include(SetupHdf5)
include(SetupAllocator)
include(SetupPapi)
include(SetupPybind11)
include(SetupSpec)
include(SetupStl)
include(SetupLibsharp)
include(SetupXsimd)
include(SetupYamlCpp)
include(SetupLIBCXXCharm)
# The precompiled header must be setup after all libraries have been found
include(SetupPch)
# All special targets and configs that need to be applied to *all*
# executables must be added at once in the 'UpdateAddExecutables' file.
# This is because of what is likely a bug in CMake where if a function is
# overridden multiple times (using the _function_name(...) method) then some
# versions of CMake (at least 3.13.2) segfault.
include(UpdateAddExecutables)
# The ClangFormat, clang-tidy, CppCheck, Doxygen, and CodeCov are intentionally
# after the PCH setup because that way they are able to change their
# dependencies on the PCH if necessary.
include(SetupClangFormat)
include(SetupClangTidy)
include(SetupIwyu)
include(SetupCppCheck)
if(BUILD_DOCS)
include(SetupDoxygen)
include(SetupSphinx)
endif()
include(CodeCoverageDetection)
include(SpectreAddLibraries)
include(SpectreSetupTesting)
if(BUILD_TESTING)
include(SetupCatch)
include(SetupPypp)
include(SpectreAddTestLibs)
include(SpectreAddCatchTests)
include(AddInputFileTests)
include(AddStandaloneTests)
endif()
include(SpectreSetupPythonPackage)
include_directories(${CMAKE_SOURCE_DIR}/external)
include_directories(${CMAKE_SOURCE_DIR}/src)
include_directories(${CMAKE_SOURCE_DIR}/tests/Unit)
# Charm++ generated headers are created in the build directory
spectre_include_directories(${CMAKE_BINARY_DIR})
spectre_include_directories(${CMAKE_BINARY_DIR}/src)
spectre_include_directories(${CMAKE_BINARY_DIR}/src/Parallel)
add_subdirectory(external)
add_subdirectory(src)
add_subdirectory(support)
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
add_subdirectory(tools)
include(PrintUsefulCMakeInfo)
include(SpectreCheckDependencies)