-
Notifications
You must be signed in to change notification settings - Fork 15
/
CMakeLists.txt
236 lines (193 loc) · 6.74 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
# SPDX-FileCopyrightText: 2021 Philipp Basler, Margarete Mühlleitner and Jonas
# Müller
#
# SPDX-License-Identifier: GPL-3.0-or-later
cmake_minimum_required(VERSION 3.23)
project(
BSMPT
VERSION 3.0.7
LANGUAGES C CXX
DESCRIPTION
"BSMPT - Beyond the Standard Model Phase Transitions : A C++ package for the computation of the EWPT in BSM models"
)
# -------------------------------- options --------------------------------
option(UseLibCMAES "Use libcmaes to minimize the potential" ON)
option(UseNLopt "Use NLopt to minimize the potential" ON)
option(MakeAdditionalTesting "Build the executables used for further testing"
OFF)
option(BSMPTCompileBaryo "Compile Baryogenesis" OFF)
option(EnableCoverage "Enable code coverage" OFF)
option(BSMPTUseVectorization "Disable vectorization" ON)
set(BSMPT_IS_TOPLEVEL NO)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(BSMPT_IS_TOPLEVEL YES)
endif()
if(NOT BSMPT_IS_TOPLEVEL)
set(EnableCoverage OFF)
endif()
if(EnableCoverage)
# The compiler flags don't mix well, so we turn it off in this scenario
set(BSMPTUseVectorization OFF)
endif()
if(BSMPT_IS_TOPLEVEL)
include(CTest)
endif()
# -------------------------------- setup cmake --------------------------------
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) # use <packagename>_ROOT as search path
endif(POLICY CMP0074)
list(APPEND CMAKE_MODULE_PATH "${BSMPT_SOURCE_DIR}/tools/cmake")
include(CompilerOptions)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif(NOT CMAKE_BUILD_TYPE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
include(LTO)
find_package(PkgConfig)
find_package(Eigen3 CONFIG REQUIRED)
find_package(Boost CONFIG)
find_package(GSL CONFIG REQUIRED)
find_package(nlohmann_json CONFIG)
find_package(Threads REQUIRED)
if(NOT Boost_FOUND)
set(BSMPTCompileBaryo OFF)
endif()
set(CodeCoverageExcludesFromOtherPkgs "")
if(NOT "${EIGEN3_ROOT_DIR}" STREQUAL "")
list(APPEND CodeCoverageExcludesFromOtherPkgs "${EIGEN3_ROOT_DIR}/*")
endif()
if(NOT "${GSL_ROOT_DIR}" STREQUAL "")
list(APPEND CodeCoverageExcludesFromOtherPkgs "${GSL_ROOT_DIR}/*")
endif()
if(Boost_FOUND)
if(NOT "${Boost_DIR}" STREQUAL "")
list(APPEND CodeCoverageExcludesFromOtherPkgs "${Boost_DIR}/*")
endif()
if(NOT "${Boost_ROOT_DIR}" STREQUAL "")
list(APPEND CodeCoverageExcludesFromOtherPkgs "${Boost_ROOT_DIR}/*")
endif()
endif()
if(nlohmann_json_FOUND)
if(NOT "${nlohmann_json}" STREQUAL "")
list(APPEND CodeCoverageExcludesFromOtherPkgs "${nlohmann_json}/*")
endif()
endif()
set(EXPORT_CMAES FALSE)
include(FetchContent)
if(UseLibCMAES AND NOT WIN32)
include(CMAES)
endif(UseLibCMAES AND NOT WIN32)
if(UseNLopt)
find_package(NLopt CONFIG QUIET)
if(NLopt_FOUND)
if(NOT "${NLopt_ROOT_DIR}" STREQUAL "")
set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs}
"${NLopt_ROOT_DIR}/*")
endif()
if(NOT "${NLopt_DIR}" STREQUAL "")
set(CodeCoverageExcludesFromOtherPkgs ${CodeCoverageExcludesFromOtherPkgs}
"${NLopt_DIR}/*")
endif()
endif()
endif(UseNLopt)
if(NOT libcmaes_FOUND AND NOT NLopt_FOUND)
message(FATAL_ERROR "You need at least libcmaes or NLopt.")
endif()
configure_file(include/BSMPT/config.h.in include/BSMPT/config.h)
# -------------------- Coverage
# --------------------------------------------------
if(EnableCoverage)
include(CodeCoverage)
append_coverage_compiler_flags()
# set(LCOV_ARGS "--no-external")
set(COVERAGE_EXCLUDES
"/usr/include/*"
"/usr/lib/*"
${CodeCoverageExcludesFromOtherPkgs}
"${PROJECT_SOURCE_DIR}/tests/*"
"tests/*"
"${PROJECT_SOURCE_DIR}/src/prog/*"
"${PROJECT_SOURCE_DIR}/src/utility/*"
"${PROJECT_SOURCE_DIR}/include/BSMPT/utility/Logger.h"
"${PROJECT_SOURCE_DIR}/src/Kfactors/Kfactors.cpp"
"${PROJECT_SOURCE_DIR}/src/models/ClassPotentialOrigin_deprecated.cpp"
"${PROJECT_SOURCE_DIR}/src/models/ClassTemplate.cpp"
"${PROJECT_SOURCE_DIR}/src/WallThickness/WallThickness1D.cpp"
"${PROJECT_SOURCE_DIR}/src/standalone/*"
"${PROJECT_SOURCE_DIR}/src/utility/spline/spline.cpp"
"${PROJECT_SOURCE_DIR}/src/utility/asciiplotter/asciiplotter.cpp")
setup_target_for_coverage_lcov(
NAME
coverage # New target name
EXECUTABLE
ctest
-j
${n_cores} # Executable in PROJECT_BINARY_DIR
BASE_DIRECTORY
"${PROJECT_SOURCE_DIR}"
DEPENDS
GenericTests)
endif(EnableCoverage)
find_lto(CXX)
add_subdirectory(src)
add_subdirectory(standalone)
# -------------------------- export as cmake package --------------------------
if(PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
BSMPTConfigVersion.cmake
VERSION ${PACKAGE_VERSION}
COMPATIBILITY AnyNewerVersion)
set(ExportList Models Minimizer ThermalFunctions Utility Spline ASCIIPlotter)
if(BSMPTCompileBaryo)
set(ExportList ${ExportList} Baryo LibWallThickness Kfactors)
endif(BSMPTCompileBaryo)
export(
TARGETS ${ExportList}
NAMESPACE BSMPT::
FILE BSMPTTargets.cmake)
if(EXPORT_CMAES)
export(
TARGETS cmaes
NAMESPACE libcmaes::
APPEND
FILE BSMPTTargets.cmake)
endif(EXPORT_CMAES)
configure_file(tools/cmake/BSMPTConfig.cmake.in BSMPTConfig.cmake @ONLY)
export(PACKAGE BSMPT)
endif()
# ------------------------ Doxygen --------------------------------------------
if(BSMPT_IS_TOPLEVEL)
find_package(Doxygen)
if(DOXYGEN_FOUND)
set(DOXYGEN_USE_MATHJAX YES)
set(DOXYGEN_STRIP_FROM_INC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(DOXYGEN_EXCLUDE
${CMAKE_CURRENT_SOURCE_DIR}/src/Kfactors/Kfunctions_grid_Part1.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/Kfactors/Kfunctions_grid_Part2.cpp)
set(DOXYGEN_EXCLUDE_PATTERNS ${CMAKE_CURRENT_SOURCE_DIR}/src/*/README.md)
set(DOXYGEN_PROJECT_BRIEF ${CMAKE_PROJECT_DESCRIPTION})
set(DOXYGEN_EXTRACT_PRIVATE YES)
set(DOXYGEN_GENERATE_TREEVIEW YES)
set(DOXYGEN_DISTRIBUTE_GROUP_DOC YES)
set(DOXYGEN_WARN_IF_UNDOCUMENTED YES)
set(DOXYGEN_WARN_IF_DOC_ERROR YES)
set(DOXYGEN_USE_MDFILE_AS_MAINPAGE ${CMAKE_CURRENT_SOURCE_DIR}/README.md)
doxygen_add_docs(
doc
"${CMAKE_CURRENT_SOURCE_DIR}/include/"
"${CMAKE_CURRENT_SOURCE_DIR}/src/"
"${CMAKE_CURRENT_SOURCE_DIR}/README.md"
"${CMAKE_CURRENT_SOURCE_DIR}/Changelog.md"
"${CMAKE_CURRENT_SOURCE_DIR}/tests/")
else()
message(
"Doxygen need to be installed to generate the doxygen documentation")
endif()
endif(BSMPT_IS_TOPLEVEL)
# -------------------- Testing
# ---------------------------------------------------
include(CTest)
if(BSMPT_IS_TOPLEVEL AND BUILD_TESTING)
add_subdirectory(tests)
endif()