forked from CompFUSE/DCA
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
264 lines (219 loc) · 8.6 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
################################################################################
# Author: Urs R. Haehner (haehneru@itp.phys.ethz.ch)
# John Biddiscombe (john.biddiscombe@cscs.ch)
#
# CMake build script for DCA++
cmake_minimum_required(VERSION 3.18)
project(DCA++ LANGUAGES C CXX)
cmake_policy(VERSION 3.18)
################################################################################
# Always use <PackageName>_ROOT vars to search first
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
################################################################################
# Always use <PackageName>_ROOT vars to search first
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW)
endif()
################################################################################
# Disable in-source builds.
if (${PROJECT_BINARY_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
message(FATAL_ERROR "In-source builds are not permitted. Make a separate folder for building:\n
mkdir build; cd build; cmake ..\n
Before that, remove the files that have already been created:\n
rm -rf CMakeCache.txt CMakeFiles")
endif()
set(SANE_DEV_BUILD true)
################################################################################
# Include CMake scripts from cmake directory.
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
################################################################################
# Enable CTest/CDash dashboard testing
enable_testing()
include(CTest)
################################################################################
# Load global variables to store preprocessor definitions.
include(dca_defines)
################################################################################
# Check for CXX features that might not be supported.
# If any of these features are not supported by the compiler, then the DCA++ project will not
# compile.
include(dca_cmake_utils) # for dca_check_cxx_features
dca_check_cxx_features(
cxx_alias_templates
cxx_auto_type
cxx_constexpr
cxx_decltype
cxx_decltype_auto
cxx_decltype_incomplete_return_types
cxx_default_function_template_args
cxx_defaulted_functions
cxx_defaulted_move_initializers
cxx_generic_lambdas
cxx_lambdas
cxx_nullptr
cxx_range_for
cxx_rvalue_references
cxx_static_assert
cxx_template_template_parameters
cxx_variadic_templates)
################################################################################
# Modules: for reproducibility
include(dca_modules/init)
get_module_list(MODULE_LIST)
configure_file("${PROJECT_SOURCE_DIR}/src/util/modules.cpp.in"
"${PROJECT_BINARY_DIR}/src/util/modules.cpp" @ONLY)
################################################################################
# Git version: for reproducibility
include(dca_git_version/init)
get_git_log(GIT_LOG) # Executes 'git log -1'.
get_git_status(GIT_STATUS) # Executes 'git status --porcelain'.
if (GIT_STATUS)
message(STATUS "Working tree is dirty. Run 'git status' for details.")
endif()
configure_file("${PROJECT_SOURCE_DIR}/src/util/git_version.cpp.in"
"${PROJECT_BINARY_DIR}/src/util/git_version.cpp" @ONLY)
################################################################################
# Configure DCA++'s applications
include(dca_config)
################################################################################
# Compiler options and tweaks
# Depends on dca_config.
include(dca_compiler_options)
################################################################################
# Generate preprocessor definitions header files.
# Depends on dca_config.
dca_write_config_definitions_file()
dca_write_haves_definitions_file()
install(DIRECTORY ${CMAKE_BINARY_DIR}/include/dca/config DESTINATION include/dca)
################################################################################
# External libraries
include(dca_external_libs) # Sets DCA_EXTERNAL_LIBS and DCA_EXTERNAL_INCLUDE_DIRS.
include(dca_check_stdlib)
message("std::filesystem resolved")
################################################################################
# Include directories
# For "dca/.../..." #includes.
include_directories(${PROJECT_SOURCE_DIR}/include)
# Directory where dca/config/headers.hpp will be created.
include_directories(${CMAKE_BINARY_DIR}/include)
set(DCA_INCLUDE_DIRS
${DCA_EXTERNAL_INCLUDE_DIRS})
if(DCA_HAVE_MAGMA)
include_directories(${MAGMA_INCLUDE_DIR})
endif(DCA_HAVE_MAGMA)
include(dca_linking)
################################################################################
# Libraries
add_subdirectory(src)
message(Threading Libs: "${DCA_THREADING_LIBS}")
# We are trying to move away from this abdication targeting try to explicitly link
# without using this mess.
set(DCA_LIBS
git_version
modules
timer
cmake_options
ctaux
ctint
ss_ct_hyb
g0_interpolation
function_transform
gaussian_quadrature
nfft
tetrahedron_mesh
${DCA_RNG_LIBRARY}
parallel_util
dca_algorithms
json
dca_hdf5
enumerations
profiling
function
convert_domains
cluster_domains
quantum_domains
time_and_frequency_domains
signals
symmetrization
coarsegraining
${DCA_CONCURRENCY_LIB}
${DCA_THREADING_LIBS}
lapack
)
set(SYSTEM_GPU_COUNT 0)
if (DCA_HAVE_GPU)
if (DCA_HAVE_CUDA)
EXECUTE_PROCESS(COMMAND bash -c "nvidia-smi -L | awk 'BEGIN { num_gpu=0;} /GPU/ { num_gpu++;} END { printf(\"%d\", num_gpu) }'"
OUTPUT_VARIABLE SYSTEM_GPU_COUNT)
endif()
if (DCA_HAVE_HIP)
EXECUTE_PROCESS(COMMAND bash -c "rocm-smi -i | awk 'BEGIN { num_gpu=0;} /GPU/ { num_gpu++;} END { printf(\"%d\", num_gpu) }'"
OUTPUT_VARIABLE SYSTEM_GPU_COUNT)
endif()
list(APPEND DCA_LIBS
blas_kernels
lapack_kernels
mc_kernels
special_transform_kernels
${DCA_GPU_LIBS})
set(DCA_KERNEL_LIBS
blas_kernels
lapack_kernels
mc_kernels
special_transform_kernels
)
endif()
if (DCA_WITH_ADIOS2 AND DCA_HAVE_ADIOS2)
list(APPEND DCA_LIBS
dca_adios2 adios2::adios2
)
message("-- Add dca_adios2 to targets")
endif()
# The BLAS and LAPACK libraries in DCA_EXTERNAL_LIBS should be linked after MAGMA.
list(APPEND DCA_LIBS lapack ${DCA_EXTERNAL_LIBS})
################################################################################
# Testing
option(DCA_WITH_TESTS_FAST "Build DCA++'s fast tests." OFF)
option(DCA_WITH_TESTS_EXTENSIVE "Build DCA++'s extensive tests." OFF)
option(DCA_WITH_TESTS_PERFORMANCE "Build DCA++'s performance tests. (Results only meaningful in Release mode.)" OFF)
option(DCA_WITH_TESTS_STOCHASTIC "Build DCA++'s stochastic tests." OFF)
set(DCA_TEST_GPU_COUNT "${SYSTEM_GPU_COUNT}" CACHE INTEGER "Number of GPUs available on one node for one test.")
set(TEST_RUNNER "" CACHE STRING "Command for executing (MPI) programs.")
set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by TEST_RUNNER to specify the number of processes.")
set(MPIEXEC_PREFLAGS "" CACHE STRING "Flags to pass to TEST_RUNNER directly before the executable to run.")
separate_arguments(MPIEXEC_PREFLAGS UNIX_COMMAND ${MPIEXEC_PREFLAGS})
set(gtest_dir "${PROJECT_SOURCE_DIR}/libs/googletest-1.8.0" CACHE PATH "Path to Google Test.")
mark_as_advanced(gtest_dir)
set(benchmark_dir "${PROJECT_SOURCE_DIR}/libs/benchmark" CACHE PATH "Path to Google Benchmark.")
mark_as_advanced(benchmark_dir)
if (DCA_WITH_TESTS_FAST OR DCA_WITH_TESTS_EXTENSIVE OR DCA_WITH_TESTS_STOCHASTIC OR
DCA_WITH_TESTS_PERFORMANCE)
include(dca_testing)
# if (((CMAKE_BUILD_TYPE STREQUAL "Release") OR
# (CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") OR
# (CMAKE_BUILD_TYPE STREQUAL "MinSizeRel")) AND
# (DCA_WITH_TESTS_FAST OR DCA_WITH_TESTS_EXTENSIVE))
# message(WARNING "Tests are built with NDEBUG defined!")
# endif()
set(BENCHMARK_ENABLE_TESTING OFF)
add_subdirectory(${gtest_dir})
add_subdirectory(${PROJECT_SOURCE_DIR}/test)
if (DCA_WITH_TESTS_PERFORMANCE)
if(NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
message(WARNING "Performance tests are only built in release mode.")
endif()
add_subdirectory(${benchmark_dir})
endif()
if (DCA_HAVE_MPI AND (TEST_RUNNER STREQUAL ""))
message(FATAL_ERROR "TEST_RUNNER needs to be set to the command for executing MPI programs, e.g. mpiexec, mpirun, aprun or srun.")
endif()
endif()
################################################################################
# Build applications.
add_subdirectory(applications)
###############################################################################
# Generate a .cpp file with DCA++'s CMake options and their values.
configure_file("${PROJECT_SOURCE_DIR}/src/config/cmake_options.cpp.in"
"${PROJECT_BINARY_DIR}/src/config/cmake_options.cpp" @ONLY)