-
Notifications
You must be signed in to change notification settings - Fork 52
/
CMakeLists.txt
166 lines (133 loc) · 6.28 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
cmake_minimum_required( VERSION 3.16 )
include(cmake/GitProjectVersion.cmake)
project( T8CODE
DESCRIPTION "Parallel algorithms and data structures for tree-based AMR with arbitrary element shapes."
LANGUAGES C CXX
VERSION "${T8CODE_VERSION_MAJOR}.${T8CODE_VERSION_MINOR}.${T8CODE_VERSION_PATCH}" )
include( CTest )
option( T8CODE_BUILD_AS_SHARED_LIBRARY "Whether t8code should be built as a shared or a static library" ON )
option( T8CODE_BUILD_PEDANTIC "Compile t8code with `-Wall -pedantic -Werror` as done in the Github CI." OFF )
option( T8CODE_EXPORT_COMPILE_COMMANDS "Export the compile commands as json. Can be used by IDEs for code completion (e.g. intellisense, clangd)" OFF )
option( T8CODE_BUILD_TESTS "Build t8code's automated tests" ON )
option( T8CODE_BUILD_TUTORIALS "Build t8code's tutorials" ON )
option( T8CODE_BUILD_EXAMPLES "Build t8code's examples" ON )
option( T8CODE_BUILD_BENCHMARKS "Build t8code's benchmarks" ON )
option( T8CODE_BUILD_FORTRAN_INTERFACE "Build t8code's Fortran interface" OFF )
option( T8CODE_ENABLE_LESS_TESTS "Tests not as thoroughly to speed up the test suite. Tests the same functionality. (WARNING: Use with care.)" OFF )
option( T8CODE_ENABLE_MPI "Enable t8code's features which rely on MPI" ON )
option( T8CODE_ENABLE_VTK "Enable t8code's features which rely on VTK" OFF )
option( T8CODE_ENABLE_OCC "Enable t8code's features which rely on OpenCASCADE" OFF )
option( T8CODE_ENABLE_NETCDF "Enable t8code's features which rely on netCDF" OFF )
option( T8CODE_USE_SYSTEM_SC "Use system-installed sc library" OFF )
option( T8CODE_USE_SYSTEM_P4EST "Use system-installed p4est library" OFF )
option( T8CODE_BUILD_DOCUMENTATION "Build t8code's documentation" OFF )
include(CMakeDependentOption)
cmake_dependent_option( T8CODE_BUILD_DOCUMENTATION_SPHINX "Build t8code's documentation using sphinx" OFF "T8CODE_BUILD_DOCUMENTATION" OFF )
set(T8CODE_CUSTOM_PARALLEL_TEST_COMMAND "" CACHE STRING "Define a custom command for parallel tests , e.g.: mpirun -np 8 (overwrites standard mpirun -np 4 if build with mpi)")
set(T8CODE_CUSTOM_SERIAL_TEST_COMMAND "" CACHE STRING "Define a custom command for serial tests.")
# Set a default build type if none was specified
set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build. Build types available: Release Debug RelWithDebInfo" FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "RelWithDebInfo")
endif()
if( NOT DEFINED CMAKE_C_STANDARD )
set( CMAKE_C_STANDARD 11 )
elseif( CMAKE_C_STANDARD LESS 11 )
message( FATAL_ERROR "The CMAKE_C_STANDARD variable has been set to ${CMAKE_C_STANDARD}, but t8code requires C11" )
endif()
set( CMAKE_C_STANDARD_REQUIRED ON )
set( CMAKE_C_EXTENSIONS OFF )
if( NOT DEFINED CMAKE_CXX_STANDARD )
set( CMAKE_CXX_STANDARD 20 )
elseif( CMAKE_CXX_STANDARD LESS 20 )
message( FATAL_ERROR "The CMAKE_CXX_STANDARD variable has been set to ${CMAKE_CXX_STANDARD}, but t8code requires C++20" )
endif()
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
if( T8CODE_BUILD_FORTRAN_INTERFACE )
enable_language( Fortran )
endif()
if( T8CODE_ENABLE_MPI )
if( T8CODE_BUILD_FORTRAN_INTERFACE )
find_package( MPI COMPONENTS C Fortran REQUIRED )
else()
find_package( MPI COMPONENTS C REQUIRED )
endif()
if( NOT MPIEXEC_EXECUTABLE )
message( FATAL_ERROR "MPIEXEC was not found" )
endif()
set( mpi ON ) # This is very dirty and will be fixed in the libsc repo (https://github.com/cburstedde/libsc/pull/178)
# set( SC_ENABLE_MPI ON ) # When the fix gets merged, replace the previous line with this one
endif()
if( T8CODE_ENABLE_VTK )
find_package( VTK REQUIRED COMPONENTS
IOXML CommonExecutionModel CommonDataModel
IOGeometry IOXMLParser IOParallelXML IOPLY
ParallelMPI FiltersCore vtksys CommonCore zlib IOLegacy)
if(VTK_FOUND)
message("Found VTK")
endif (VTK_FOUND)
endif( T8CODE_ENABLE_VTK )
if( T8CODE_ENABLE_OCC )
find_package( OpenCASCADE REQUIRED COMPONENTS
TKBO TKPrim TKTopAlgo
TKGeomAlgo TKBRep
TKG3d TKG2d TKMath TKernel )
if(OpenCASCADE_FOUND)
message("Found OpenCASCADE")
endif (OpenCASCADE_FOUND)
endif( T8CODE_ENABLE_OCC )
if( T8CODE_ENABLE_NETCDF )
find_package( netCDF REQUIRED )
if(netCDF_FOUND)
message("Found netCDF")
include(cmake/CheckNetCDFPar.cmake)
endif (netCDF_FOUND)
endif( T8CODE_ENABLE_NETCDF )
# Override default for this libsc option
set( BUILD_SHARED_LIBS ON CACHE BOOL "Build libsc as a shared library" )
# Prevent `libsc` and `p4est` from overwriting the default install prefix.
set(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT FALSE)
# Rpath options necessary for shared library install to work correctly in user projects.
set(CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/lib)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH true)
if ( T8CODE_USE_SYSTEM_SC )
find_package( SC REQUIRED PATHS /path/to/system/sc )
else()
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/sc )
endif()
if ( T8CODE_USE_SYSTEM_P4EST )
find_package( P4EST REQUIRED PATHS /path/to/system/p4est )
else()
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/p4est )
endif()
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/src )
if ( T8CODE_BUILD_TESTS )
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/test )
endif()
if ( T8CODE_BUILD_TUTORIALS )
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/tutorials )
endif()
if ( T8CODE_BUILD_EXAMPLES )
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/example )
endif()
if ( T8CODE_BUILD_BENCHMARKS )
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/benchmarks )
endif()
if ( T8CODE_BUILD_DOCUMENTATION )
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/doc )
endif()
if( T8CODE_BUILD_FORTRAN_INTERFACE )
add_subdirectory( ${CMAKE_CURRENT_LIST_DIR}/api/t8_fortran_interface )
if( NOT T8CODE_ENABLE_MPI )
message( FATAL_ERROR "Fortran API only available when MPI is enabled." )
endif()
endif()
include (cmake/CPackConfig.cmake)