-
Notifications
You must be signed in to change notification settings - Fork 18
/
CMakeLists.txt
93 lines (73 loc) · 2.79 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
cmake_minimum_required(VERSION 3.21)
set(NSEOF_PROJECT_NAME "NS-EOF")
set(NSEOF_PROJECT_DESCRIPTION "Navier Stokes - Ernst-Otto-Fischer Teaching Code")
set(NSEOF_AUTHOR_ORGANIZATION "Chair of Scientific Computing, Department of Informatics, Technische Universitaet Muenchen")
set(NSEOF_AUTHOR_DOMAIN "https://github.com/TUM-I5/NS-EOF")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
project(${NSEOF_PROJECT_NAME}
DESCRIPTION ${NSEOF_PROJECT_DESCRIPTION}
HOMEPAGE_URL ${NSEOF_AUTHOR_DOMAIN}
LANGUAGES C CXX
)
set(CMAKE_C_STANDARD 17 CACHE STRING "")
set(CMAKE_C_STANDARD_REQUIRED TRUE)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 20 CACHE STRING "")
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_CXX_VISIBILITY_INLINES_HIDDEN YES)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE INTERNAL "")
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
file(WRITE "${PROJECT_BINARY_DIR}/.gitignore" "*")
include(GNUInstallDirs)
set(DEFAULT_CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR})
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
include(ProcessorCount)
ProcessorCount(AVAILABLE_PROCESSOR_COUNT)
include(CTest)
enable_testing()
include(CheckIPOSupported)
check_ipo_supported(RESULT IPO_SUPPORTED OUTPUT IPO_ERROR)
if(IPO_SUPPORTED)
message(STATUS "IPO/LTO enabled")
set_property(GLOBAL PROPERTY INTERPROCEDURAL_OPTIMIZATION 1)
else()
#message(WARNING "IPO/LTO not supported: ${IPO_ERROR}")
message(WARNING "IPO/LTO not supported")
endif()
add_library(NS-EOF-Interface INTERFACE)
target_compile_features(NS-EOF-Interface INTERFACE cxx_std_${CMAKE_CXX_STANDARD})
target_compile_options(NS-EOF-Interface INTERFACE
-W
-Wall
-Wextra
-Wpedantic
)
option(ENABLE_SINGLE_PRECISION "Enable single floating-point precision" OFF)
if(ENABLE_SINGLE_PRECISION)
target_compile_definitions(NS-EOF-Interface INTERFACE ENABLE_SINGLE_PRECISION)
endif()
option(ENABLE_PETSC "Enable the Portable, Extensible Toolkit for Scientific Computation (PETSc)" ON)
if(ENABLE_PETSC)
find_package(PETSc REQUIRED)
target_compile_definitions(NS-EOF-Interface INTERFACE ENABLE_PETSC)
target_link_libraries(NS-EOF-Interface INTERFACE ${PETSc_LIBRARIES})
target_include_directories(NS-EOF-Interface INTERFACE ${PETSc_INCLUDE_DIRS})
endif()
find_package(MPI REQUIRED)
find_package(Catch2 REQUIRED)
find_package(spdlog REQUIRED)
find_package(tinyxml2 REQUIRED)
target_link_libraries(NS-EOF-Interface INTERFACE
MPI::MPI_CXX
spdlog::spdlog
tinyxml2::tinyxml2
)
add_subdirectory(Source)
add_subdirectory(Tests)