CMakeLists.txt 21 KB
Newer Older
1
2
3
4
5
#######################################################################
#                                                                     #
#  Copyright 2019 Max Planck Institute                                #
#                 for Dynamics and Self-Organization                  #
#                                                                     #
6
#  This file is part of TurTLE.                                       #
7
#                                                                     #
8
#  TurTLE is free software: you can redistribute it and/or modify     #
9
10
11
12
#  it under the terms of the GNU General Public License as published  #
#  by the Free Software Foundation, either version 3 of the License,  #
#  or (at your option) any later version.                             #
#                                                                     #
13
#  TurTLE is distributed in the hope that it will be useful,          #
14
15
16
17
18
#  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 General Public License  #
19
#  along with TurTLE.  If not, see <http://www.gnu.org/licenses/>     #
20
21
22
23
24
25
26
#                                                                     #
# Contact: Cristian.Lalescu@ds.mpg.de                                 #
#                                                                     #
#######################################################################



27
cmake_minimum_required(VERSION 3.6)
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
cmake_policy(VERSION 3.12)

if (DEFINED ENV{MPICXX})
    message(STATUS "Using CMAKE_CXX_COMPILER=MPICXX")
    set(CMAKE_CXX_COMPILER $ENV{MPICXX})
else()
    message(STATUS "MPICXX environment variable undefined, trying to find MPI")
    set(MPI_STATIC ON)
    find_package(MPI REQUIRED)
endif()

if (DEFINED ENV{MPICC})
    set(CMAKE_C_COMPILER $ENV{MPICC})
    message(STATUS "Using CMAKE_C_COMPILER=MPICC")
endif()

if (DEFINED ENV{CMAKE_INSTALL_PREFIX})
    set(CMAKE_INSTALL_PREFIX $ENV{CMAKE_INSTALL_PREFIX})
endif()
Cristian Lalescu's avatar
Cristian Lalescu committed
47

48
project(TurTLE)
49

50
execute_process(COMMAND python3 ${PROJECT_SOURCE_DIR}/get_version.py OUTPUT_VARIABLE TURTLE_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
51

52
53
project(TurTLE
        VERSION ${TURTLE_VERSION}
54
        LANGUAGES CXX)
55
56


57
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
58
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/morse ${CMAKE_MODULE_PATH})
59
set(TURTLE_LIBS "")
60

61
62
63
64
65
option(NDEBUG "Define NDEBUG macro" ON)
if(NDEBUG)
    add_definitions(-DNDEBUG)
endif()

66
67
# taken from https://vicrucann.github.io/tutorials/quick-cmake-doxygen/
# indicate the documentation build as an option and set it to ON by default
68
option(BUILD_DOC "Build documentation" OFF)
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87

# check if Doxygen is installed
find_package(Doxygen)
if (DOXYGEN_FOUND)
    # set input and output files
    set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/documentation/cpp/cpp_config)
    set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)

    # request to configure the file
    configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
    message("Doxygen build started")

    # note the option ALL which allows to build the docs together with the application
    add_custom_target( doc_doxygen
        COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
        COMMENT "Generating API documentation with Doxygen"
        VERBATIM )
else (DOXYGEN_FOUND)
88
    message("Doxygen needs to be installed to generate the doxygen documentation")
89
90
endif (DOXYGEN_FOUND)

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
# check if sphinx is available
find_package(Sphinx)
if (SPHINX_FOUND)
    if(NOT DEFINED SPHINX_THEME)
        set(SPHINX_THEME default)
    endif()

    if(NOT DEFINED SPHINX_THEME_DIR)
        set(SPHINX_THEME_DIR)
    endif()

    # configured documentation tools and intermediate build results
    set(BINARY_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/sphinx_build")

    # Sphinx cache with pickled ReST documents
    set(SPHINX_CACHE_DIR "${CMAKE_CURRENT_BINARY_DIR}/sphinx_doctrees")

    # HTML output directory
    set(SPHINX_HTML_DIR "${CMAKE_CURRENT_BINARY_DIR}/sphinx_html")
    # LaTeX output directory
    set(SPHINX_LATEX_DIR "${CMAKE_CURRENT_BINARY_DIR}/sphinx_latex")

    configure_file(
        "${PROJECT_SOURCE_DIR}/documentation/conf.py.in"
        "${BINARY_BUILD_DIR}/conf.py"
        @ONLY)

    add_custom_target(doc_html
        ${SPHINX_EXECUTABLE}
            -q -b html
            -c "${BINARY_BUILD_DIR}"
            -d "${SPHINX_CACHE_DIR}"
            "${PROJECT_SOURCE_DIR}/documentation"
            "${SPHINX_HTML_DIR}"
            COMMENT "Building HTML documentation with Sphinx")

    add_custom_target(doc_latex
        ${SPHINX_EXECUTABLE}
            -q -b latex
            -c "${BINARY_BUILD_DIR}"
            -d "${SPHINX_CACHE_DIR}"
            "${PROJECT_SOURCE_DIR}/documentation"
            "${SPHINX_LATEX_DIR}"
            COMMENT "Building LaTeX documentation with Sphinx")
else (SPHINX_FOUND)
    message("Sphinx needs to be installed to generate the full documentation")
endif (SPHINX_FOUND)

139
140
141
142
143
option(TIMING_OUTPUT "Toggle timing output. WARNING: memory usage is proportional to `niter_todo`" OFF)
if(TIMING_OUTPUT)
    add_definitions(-DUSE_TIMINGOUTPUT)
endif()

144
145
146
147
148
149
150
#####################################################################################
## MPI

set(CMAKE_CXX_COMPILE_FLAGS "${CMAKE_CXX_COMPILE_FLAGS} ${MPI_CXX_COMPILE_OPTIONS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_CXX_LINK_FLAGS}")
include_directories(${MPI_CXX_INCLUDE_DIRS})
add_definitions(${MPI_CXX_COMPILE_DEFINITIONS})
151
list(APPEND TURTLE_LIBS "${MPI_CXX_LIBRARIES}")
152
153
154
155
156
157
158

#####################################################################################
## CXX Standard

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# set(CMAKE_CXX_EXTENSIONS OFF)
159
160

#####################################################################################
161
162
163
## OpenMP

find_package(OpenMP REQUIRED)
164

165
166
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
167
list(APPEND TURTLE_LIBS "${OpenMP_CXX_LIB_NAMES}")
168
169
170

#####################################################################################
## Extra flags
171

172
set(CMAKE_CXX_COMPILE_FLAGS "${CMAKE_CXX_COMPILE_FLAGS} $ENV{TURTLE_COMPILATION_FLAGS} -Wall -g -Wfatal-errors -fopenmp")
173
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_COMPILE_FLAGS}")
Cristian Lalescu's avatar
Cristian Lalescu committed
174

175
176
177
#####################################################################################
## HDF5

178
set(HDF5_STATIC ON)
179
180
if(NOT DEFINED ENV{HDF5_ROOT})
    message(WARNING "The environment variable HDF5_ROOT is undefined, this might cause trouble in finding the HDF5")
Cristian Lalescu's avatar
Cristian Lalescu committed
181
endif()
182

183
set(HDF5_PREFER_PARALLEL TRUE)
Cristian Lalescu's avatar
Cristian Lalescu committed
184
set(HDF5_NO_FIND_PACKAGE_CONFIG_FILE TRUE)
185
find_package(HDF5 REQUIRED)
186

187
188
189
190
message(STATUS "HDF5_C_INCLUDE_DIRS ${HDF5_C_INCLUDE_DIRS}")

include_directories(${HDF5_C_INCLUDE_DIRS})
add_definitions(${HDF5_C_DEFINITIONS})
191
list(APPEND TURTLE_LIBS "${HDF5_C_LIBRARIES}")
192

193
option(TURTLE_HDF5_USE_SZIP "Set to on to also link against SZIP" OFF)
194

195
196
197
198
if(TURTLE_HDF5_USE_SZIP)
    option(TURTLE_HDF5_SZIP_LIB_PATH "Additional lib path for SZIP" "")
    if(TURTLE_HDF5_SZIP_LIB_PATH)
        link_directories(${TURTLE_HDF5_SZIP_LIB_PATH})
199
    endif()
200
    list(APPEND TURTLE_LIBS "z")
201
202
203
204
205
endif()

#####################################################################################
## FFTW

206
set(FFTW_STATIC ON)
207
208
209
210
if(NOT DEFINED ENV{FFTW_DIR})
    message(WARNING "The environment variable FFTW_DIR is undefined, this might cause trouble in finding the FFTW")
endif()

211
find_package(FFTW REQUIRED)
212
213
214

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FFTW_CFLAGS_OTHER}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FFTW_LDFLAGS_OTHER}")
215
list(APPEND TURTLE_LIBS "${FFTW_LIBRARIES}")
216
217
218
include_directories(${FFTW_INCLUDE_DIRS})
link_directories(${FFTW_LIBRARY_DIRS})

219
find_package(FFTW REQUIRED SIMPLE)
220
221
222

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${FFTW_CFLAGS_OTHER}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FFTW_LDFLAGS_OTHER}")
223
list(APPEND TURTLE_LIBS "${FFTW_LIBRARIES}")
224
225
include_directories(${FFTW_INCLUDE_DIRS})
link_directories(${FFTW_LIBRARY_DIRS})
226

227
228
229
230
231
232
233
234
235
236
# hack for FFTW OMP libs
find_library(
    FFTWF_OMP fftw3f_omp
    HINTS ${FFTW_LIBRARY_DIRS} $ENV{FFTW_LIBDIR} $ENV{FFTW_OPENMP_LIBDIR})
set(TURTLE_LIBS ${FFTWF_OMP} ${TURTLE_LIBS})
find_library(
    FFTW_OMP fftw3_omp
    HINTS ${FFTW_LIBRARY_DIRS} $ENV{FFTW_LIBDIR} $ENV{FFTW_OPENMP_LIBDIR})
set(TURTLE_LIBS ${FFTW_OMP} ${TURTLE_LIBS})

237
# hack for FFTW MPI libs
238
239
find_library(
    FFTWF_MPI fftw3f_mpi
240
    HINTS ${FFTW_LIBRARY_DIRS} $ENV{FFTW_LIBDIR} $ENV{FFTW_MPI_LIBDIR})
241
set(TURTLE_LIBS ${FFTWF_MPI} ${TURTLE_LIBS})
242
243
find_library(
    FFTW_MPI fftw3_mpi
244
    HINTS ${FFTW_LIBRARY_DIRS} $ENV{FFTW_LIBDIR} $ENV{FFTW_MPI_LIBDIR})
245
set(TURTLE_LIBS ${FFTW_MPI} ${TURTLE_LIBS})
246
247


248
249
250
251
252
253
#####################################################################################
## Get the links and include from deps

get_property(ALL_INCLUDE_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
get_property(ALL_LINK_DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY LINK_DIRECTORIES)

254
255
256
#####################################################################################
## Build the lib

257
include_directories(${PROJECT_SOURCE_DIR}/cpp)
Cristian Lalescu's avatar
Cristian Lalescu committed
258

259
260
261
262
263
#file(GLOB_RECURSE cpp_for_lib ${PROJECT_SOURCE_DIR}/*.cpp)
set(cpp_for_lib
    ${PROJECT_SOURCE_DIR}/cpp/full_code/code_base.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/direct_numerical_simulation.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVE.cpp
Cristian Lalescu's avatar
Cristian Lalescu committed
264
    ${PROJECT_SOURCE_DIR}/cpp/full_code/static_field.cpp
Lukas Bentkamp's avatar
Lukas Bentkamp committed
265
    ${PROJECT_SOURCE_DIR}/cpp/full_code/kraichnan_field.cpp
266
267
268
269
    ${PROJECT_SOURCE_DIR}/cpp/full_code/joint_acc_vel_stats.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/test.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/filter_test.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/field_test.cpp
270
    ${PROJECT_SOURCE_DIR}/cpp/full_code/write_filtered_test.cpp
Cristian Lalescu's avatar
Cristian Lalescu committed
271
    ${PROJECT_SOURCE_DIR}/cpp/full_code/Gauss_field_test.cpp
272
273
274
    ${PROJECT_SOURCE_DIR}/cpp/full_code/symmetrize_test.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/field_output_test.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/get_rfields.cpp
275
    ${PROJECT_SOURCE_DIR}/cpp/full_code/bandpass_stats.cpp
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
    ${PROJECT_SOURCE_DIR}/cpp/full_code/field_single_to_double.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/resize.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVE_field_stats.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/native_binary_to_hdf5.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/postprocess.cpp
    ${PROJECT_SOURCE_DIR}/cpp/field.cpp
    ${PROJECT_SOURCE_DIR}/cpp/kspace.cpp
    ${PROJECT_SOURCE_DIR}/cpp/field_layout.cpp
    ${PROJECT_SOURCE_DIR}/cpp/hdf5_tools.cpp
    ${PROJECT_SOURCE_DIR}/cpp/fftw_tools.cpp
    ${PROJECT_SOURCE_DIR}/cpp/vorticity_equation.cpp
    ${PROJECT_SOURCE_DIR}/cpp/field_binary_IO.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n1.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n2.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n3.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n4.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n5.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n6.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n7.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n8.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n9.cpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n10.cpp
    ${PROJECT_SOURCE_DIR}/cpp/Lagrange_polys.cpp
    ${PROJECT_SOURCE_DIR}/cpp/scope_timer.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/test_interpolation.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVEparticles.cpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVEcomplex_particles.cpp
303
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVE_Stokes_particles.cpp
304
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVEp_extra_sampling.cpp
305
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_inner_computer.cpp
306
    ${PROJECT_SOURCE_DIR}/cpp/full_code/ornstein_uhlenbeck_process.cpp
sniklas142's avatar
sniklas142 committed
307
    ${PROJECT_SOURCE_DIR}/cpp/full_code/ou_vorticity_equation.cpp)
308

309
310
311
312
set(hpp_for_lib
    ${PROJECT_SOURCE_DIR}/cpp/full_code/code_base.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/direct_numerical_simulation.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVE.hpp
Cristian Lalescu's avatar
Cristian Lalescu committed
313
    ${PROJECT_SOURCE_DIR}/cpp/full_code/static_field.hpp
Lukas Bentkamp's avatar
Lukas Bentkamp committed
314
    ${PROJECT_SOURCE_DIR}/cpp/full_code/kraichnan_field.hpp
315
316
317
    ${PROJECT_SOURCE_DIR}/cpp/full_code/joint_acc_vel_stats.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/test.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/filter_test.hpp
Cristian Lalescu's avatar
Cristian Lalescu committed
318
    ${PROJECT_SOURCE_DIR}/cpp/full_code/Gauss_field_test.hpp
319
    ${PROJECT_SOURCE_DIR}/cpp/full_code/field_test.hpp
320
    ${PROJECT_SOURCE_DIR}/cpp/full_code/write_filtered_test.hpp
321
322
323
    ${PROJECT_SOURCE_DIR}/cpp/full_code/symmetrize_test.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/field_output_test.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/get_rfields.hpp
324
    ${PROJECT_SOURCE_DIR}/cpp/full_code/bandpass_stats.hpp
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
    ${PROJECT_SOURCE_DIR}/cpp/full_code/field_single_to_double.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/resize.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVE_field_stats.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/native_binary_to_hdf5.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/postprocess.hpp
    ${PROJECT_SOURCE_DIR}/cpp/field.hpp
    ${PROJECT_SOURCE_DIR}/cpp/kspace.hpp
    ${PROJECT_SOURCE_DIR}/cpp/field_layout.hpp
    ${PROJECT_SOURCE_DIR}/cpp/hdf5_tools.hpp
    ${PROJECT_SOURCE_DIR}/cpp/fftw_tools.hpp
    ${PROJECT_SOURCE_DIR}/cpp/vorticity_equation.hpp
    ${PROJECT_SOURCE_DIR}/cpp/field_binary_IO.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n1.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n2.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n3.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n4.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n5.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n6.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n7.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n8.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n9.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline_n10.hpp
    ${PROJECT_SOURCE_DIR}/cpp/Lagrange_polys.hpp
    ${PROJECT_SOURCE_DIR}/cpp/scope_timer.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/test_interpolation.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVEparticles.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVEcomplex_particles.hpp
352
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVE_Stokes_particles.hpp
353
354
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVEp_extra_sampling.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_inner_computer.hpp
355
356
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_inner_computer_2nd_order.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_inner_computer_empty.hpp
357
358
359
    ${PROJECT_SOURCE_DIR}/cpp/particles/abstract_particles_input.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/abstract_particles_output.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/abstract_particles_system.hpp
360
    ${PROJECT_SOURCE_DIR}/cpp/particles/abstract_particles_system_with_p2p.hpp
361
362
363
364
365
    ${PROJECT_SOURCE_DIR}/cpp/particles/alltoall_exchanger.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/env_utils.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/lock_free_bool_array.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/p2p_computer_empty.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/p2p_computer.hpp
366
367
    ${PROJECT_SOURCE_DIR}/cpp/particles/p2p_ghost_collisions.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/p2p_cylinder_collisions.hpp
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
    ${PROJECT_SOURCE_DIR}/cpp/particles/p2p_distr_mpi.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/p2p_tree.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_adams_bashforth.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_distr_mpi.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_field_computer.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_generic_interp.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_input_hdf5.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_output_hdf5.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_output_mpiio.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_output_sampling_hdf5.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_sampling.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_system_builder.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_system.hpp
    ${PROJECT_SOURCE_DIR}/cpp/particles/particles_utils.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/main_code.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/codes_with_no_output.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVE_no_output.hpp
    ${PROJECT_SOURCE_DIR}/cpp/full_code/NSVEparticles_no_output.hpp
    ${PROJECT_SOURCE_DIR}/cpp/base.hpp
    ${PROJECT_SOURCE_DIR}/cpp/fftw_interface.hpp
    ${PROJECT_SOURCE_DIR}/cpp/bfps_timer.hpp
    ${PROJECT_SOURCE_DIR}/cpp/omputils.hpp
    ${PROJECT_SOURCE_DIR}/cpp/shared_array.hpp
    ${PROJECT_SOURCE_DIR}/cpp/spline.hpp
392
    ${PROJECT_SOURCE_DIR}/cpp/full_code/ornstein_uhlenbeck_process.hpp
393
    ${PROJECT_SOURCE_DIR}/cpp/full_code/ou_vorticity_equation.hpp
394
395
    )
#file(GLOB_RECURSE hpp_for_lib ${PROJECT_SOURCE_DIR}/*.hpp)
396
LIST(APPEND source_files ${hpp_for_lib} ${cpp_for_lib})
Cristian Lalescu's avatar
Cristian Lalescu committed
397

Cristian Lalescu's avatar
Cristian Lalescu committed
398
add_library(TurTLE ${source_files})
399

Cristian Lalescu's avatar
Cristian Lalescu committed
400
target_link_libraries(TurTLE ${TURTLE_LIBS})
401

Cristian Lalescu's avatar
Cristian Lalescu committed
402
403
install(TARGETS TurTLE EXPORT TURTLE_EXPORT DESTINATION lib/ )
install(DIRECTORY ${PROJECT_SOURCE_DIR}/cpp/ DESTINATION include/TurTLE/ FILES_MATCHING PATTERN "*.h*")
404
405
406
407

#####################################################################################
## Export the configuration

Cristian Lalescu's avatar
Cristian Lalescu committed
408
configure_file(${PROJECT_SOURCE_DIR}/cmake/TurTLEConfig.cmake.in ${PROJECT_BINARY_DIR}/TurTLEConfig.cmake @ONLY)
409

Cristian Lalescu's avatar
Cristian Lalescu committed
410
install(FILES "${PROJECT_BINARY_DIR}/TurTLEConfig.cmake" DESTINATION lib/)
Cristian Lalescu's avatar
Cristian Lalescu committed
411
export(TARGETS TurTLE FILE "${PROJECT_BINARY_DIR}/TurTLELibraryDepends.cmake")
412
install(EXPORT TURTLE_EXPORT DESTINATION lib/)
413

414

415
#####################################################################################
416
## Install the python3 wrapper
417
# copy command
Cristian Lalescu's avatar
Cristian Lalescu committed
418
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/TurTLE ${PROJECT_BINARY_DIR}/python/TurTLE/)")
419
if(EXISTS "${PROJECT_SOURCE_DIR}/host_info.py")
Cristian Lalescu's avatar
Cristian Lalescu committed
420
    install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/host_info.py ${PROJECT_BINARY_DIR}/python/TurTLE/)")
421
else()
Cristian Lalescu's avatar
Cristian Lalescu committed
422
    install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_SOURCE_DIR}/pc_host_info.py ${PROJECT_BINARY_DIR}/python/TurTLE/host_info.py)")
423
endif()
424
install(CODE "execute_process(COMMAND python3 ${PROJECT_SOURCE_DIR}/setup.py install --force --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/python/)")
425
426
427
428
429


#####################################################################################
## Add tests
include(CTest)
Cristian Lalescu's avatar
Cristian Lalescu committed
430
set(TEST_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/test_runs/")
431
432
enable_testing()
if (BUILD_TESTING)
Cristian Lalescu's avatar
Cristian Lalescu committed
433
434
    file(MAKE_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
    ### basic functionality
435
436
437
438
439
440
441
442
    add_test(
        NAME test_fftw
        COMMAND turtle.test_fftw
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
    add_test(
        NAME test_Parseval
        COMMAND turtle.test_Parseval
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
Cristian Lalescu's avatar
Cristian Lalescu committed
443
    ### compare DNS output to stored results
444
445
446
447
    add_test(
        NAME test_NSVEparticles
        COMMAND turtle.test_NSVEparticles
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
Cristian Lalescu's avatar
Cristian Lalescu committed
448
    ### simple runs of post-processing tools
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
    add_test(
        NAME test_pp_single_to_double
        COMMAND turtle PP field_single_to_double --simname dns_nsveparticles --iter0 32 --iter1 32
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
    add_test(
        NAME test_pp_get_rfields
        COMMAND turtle PP get_rfields --simname dns_nsveparticles --iter0 0 --iter1 64
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
    add_test(
        NAME test_pp_joint_acc_vel_stats
        COMMAND turtle PP joint_acc_vel_stats --simname dns_nsveparticles --iter0 0 --iter1 64
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
    add_test(
        NAME test_pp_resize
        COMMAND turtle PP resize --simname dns_nsveparticles --new_nx 96 --new_ny 96 --new_nz 96 --new_simname dns_nsveparticles_resized
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
Cristian Lalescu's avatar
Cristian Lalescu committed
465
    ### simple runs of different DNS
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
    add_test(
        NAME test_NSVEp_extra_sampling
        COMMAND turtle DNS NSVEp_extra_sampling -n 32 --src-simname dns_nsveparticles --src-iteration 32 --simname dns_nsvep_extra_sampling --nparticles 1000
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
    add_test(
        NAME test_NSVEcomplex_particles
        COMMAND turtle DNS NSVEcomplex_particles -n 32 --src-simname dns_nsveparticles --src-iteration 32 --simname dns_nsvecomplex_particles --nparticles 1000
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
    add_test(
        NAME test_static_field
        COMMAND turtle DNS static_field --simname dns_static_field --nparticles 10000
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
    add_test(
        NAME test_kraichnan_field
        COMMAND turtle DNS kraichnan_field --simname dns_kraichnan_field --nparticles 10000
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
    add_test(
        NAME test_NSVE_Stokes_particles
        COMMAND turtle DNS NSVE_Stokes_particles  -n 32 --src-simname dns_nsveparticles --src-iteration 32 --simname dns_nsve_tokes_particles --nparticles 10000
        WORKING_DIRECTORY ${TEST_OUTPUT_DIRECTORY})
486
487
endif(BUILD_TESTING)