Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
DLR-AMR
GitHub Repository: DLR-AMR/t8code
Path: blob/main/tutorials/CMakeLists.txt
900 views
1
# This file is part of t8code.
2
# t8code is a C library to manage a collection (a forest) of multiple
3
# connected adaptive space-trees of general element types in parallel.
4
#
5
# Copyright (C) 2025 the developers
6
#
7
# t8code is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
11
#
12
# t8code is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with t8code; if not, write to the Free Software Foundation, Inc.,
19
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
21
function( add_t8_tutorial )
22
set( options "" )
23
set( oneValueArgs "NAME" )
24
set( multiValueArgs "SOURCES" )
25
cmake_parse_arguments( ADD_T8_TUTORIAL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
26
27
# Get the path of the first file listed in the SOURCES list and use it to determine the build directory.
28
# The executable will be build in the same directory as the first source file.
29
list(GET ADD_T8_TUTORIAL_SOURCES 0 FIRST_SOURCE)
30
get_filename_component(TUTORIAL_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/${FIRST_SOURCE}" DIRECTORY)
31
file(RELATIVE_PATH TUTORIAL_RELATIVE_DIR "${CMAKE_SOURCE_DIR}" "${TUTORIAL_SOURCE_DIR}")
32
set(TUTORIAL_BUILD_DIR "${CMAKE_BINARY_DIR}/${TUTORIAL_RELATIVE_DIR}")
33
34
add_executable( ${ADD_T8_TUTORIAL_NAME} ${ADD_T8_TUTORIAL_SOURCES} )
35
target_link_libraries( ${ADD_T8_TUTORIAL_NAME} PRIVATE T8 SC::SC )
36
target_include_directories( ${ADD_T8_TUTORIAL_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/.. )
37
38
set_target_properties(${ADD_T8_TUTORIAL_NAME} PROPERTIES
39
RUNTIME_OUTPUT_DIRECTORY "${TUTORIAL_BUILD_DIR}"
40
LIBRARY_OUTPUT_DIRECTORY "${TUTORIAL_BUILD_DIR}"
41
ARCHIVE_OUTPUT_DIRECTORY "${TUTORIAL_BUILD_DIR}"
42
)
43
44
if( T8CODE_EXPORT_COMPILE_COMMANDS )
45
set_target_properties( ${ADD_T8_TUTORIAL_NAME} PROPERTIES EXPORT_COMPILE_COMMANDS ON )
46
endif( T8CODE_EXPORT_COMPILE_COMMANDS )
47
48
install( TARGETS ${ADD_T8_TUTORIAL_NAME} RUNTIME )
49
endfunction()
50
51
#copy tutorial files to the exact same location in the builddir as they are in the source dir
52
function( copy_tutorial_file TUTORIAL_FILE_NAME_SUBPATH )
53
configure_file(${CMAKE_CURRENT_LIST_DIR}/${TUTORIAL_FILE_NAME_SUBPATH} ${CMAKE_CURRENT_BINARY_DIR}/${TUTORIAL_FILE_NAME_SUBPATH} COPYONLY)
54
endfunction()
55
56
add_t8_tutorial( NAME t8_step0_helloworld SOURCES general/t8_step0_helloworld.cxx )
57
add_t8_tutorial( NAME t8_step1_coarsemesh SOURCES general/t8_step1_coarsemesh.cxx )
58
add_t8_tutorial( NAME t8_step2_uniform_forest SOURCES general/t8_step2_uniform_forest.cxx )
59
add_t8_tutorial( NAME t8_step3_adapt_forest SOURCES general/t8_step3_main.cxx general/t8_step3_adapt_forest.cxx )
60
add_t8_tutorial( NAME t8_step4_partition_balance_ghost SOURCES general/t8_step4_main.cxx general/t8_step3_adapt_forest.cxx general/t8_step4_partition_balance_ghost.cxx )
61
add_t8_tutorial( NAME t8_step5_element_data SOURCES general/t8_step5_main.cxx general/t8_step3_adapt_forest.cxx general/t8_step5_element_data.cxx )
62
add_t8_tutorial( NAME t8_step6_stencil SOURCES general/t8_step6_main.cxx general/t8_step3_adapt_forest.cxx general/t8_step6_stencil.cxx )
63
add_t8_tutorial( NAME t8_step7_interpolation SOURCES general/t8_step7_main.cxx general/t8_step7_interpolation.cxx )
64
add_t8_tutorial( NAME t8_tutorial_build_cmesh SOURCES general/t8_tutorial_build_cmesh.cxx general/t8_tutorial_build_cmesh_main.cxx)
65
add_t8_tutorial( NAME t8_tutorial_search SOURCES general/t8_tutorial_search.cxx general/t8_step3_adapt_forest.cxx )
66
add_t8_tutorial( NAME t8_features_curved_meshes SOURCES features/t8_features_curved_meshes.cxx)
67
add_t8_tutorial( NAME t8_tutorial_build_scheme SOURCES general/t8_tutorial_build_scheme.cxx)
68
copy_tutorial_file (features/t8_features_curved_meshes_generate_cmesh_hex.geo)
69
copy_tutorial_file (features/t8_features_curved_meshes_generate_cmesh_quad.geo)
70
copy_tutorial_file (features/t8_features_curved_meshes_generate_cmesh_tet.geo)
71
copy_tutorial_file (features/t8_features_curved_meshes_generate_cmesh_tri.geo)
72
73