-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
87 lines (71 loc) · 2.47 KB
/
Copy pathCMakeLists.txt
File metadata and controls
87 lines (71 loc) · 2.47 KB
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
cmake_minimum_required(VERSION 3.20)
project(Aeolus LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# --- Dependencies & Package Management ---
include(cmake/CPM.cmake)
CPMAddPackage("gh:catchorg/Catch2#v3.15.0")
CPMAddPackage("gl:libeigen/eigen#5.0.1")
find_library(ACCELERATE_FRAMEWORK Accelerate)
find_package(PkgConfig REQUIRED)
pkg_check_modules(PETSC REQUIRED petsc)
find_package(MPI REQUIRED)
option(ENABLE_OPENMP "Enable OpenMP multi-threading" ON)
if(ENABLE_OPENMP)
if(APPLE)
execute_process(COMMAND brew --prefix libomp OUTPUT_VARIABLE HOMEBREW_LIBOMP_PREFIX OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(HOMEBREW_LIBOMP_PREFIX AND EXISTS "${HOMEBREW_LIBOMP_PREFIX}")
list(APPEND CMAKE_PREFIX_PATH "${HOMEBREW_LIBOMP_PREFIX}")
endif()
endif()
find_package(OpenMP)
if(OpenMP_CXX_FOUND)
message(STATUS "OpenMP CXX enabled (version ${OpenMP_CXX_VERSION})")
else()
message(STATUS "OpenMP CXX not found. Building without OpenMP.")
endif()
endif()
add_compile_definitions(ACCELERATE_NEW_LAPACK)
# --- Core Library ---
add_library(aeolus_core STATIC
src/mesh/Geometry.cpp
src/mesh/Connectivity.cpp
src/mesh/MeshParser.cpp
src/mesh/Export.cpp
src/math/SparseMatrix.cpp
src/math/LinearSolver.cpp
src/fvm/FVM.cpp
src/fvm/FVC.cpp
src/solver/PressureVelocityCoupling.cpp
src/solver/SimpleSolver.cpp
src/solver/BoundaryCondition.cpp
)
target_include_directories(aeolus_core PUBLIC src ${PETSC_INCLUDE_DIRS})
target_link_directories(aeolus_core PUBLIC ${PETSC_LIBRARY_DIRS})
target_link_libraries(aeolus_core PUBLIC ${PETSC_LIBRARIES} MPI::MPI_CXX ${ACCELERATE_FRAMEWORK})
if(OpenMP_CXX_FOUND)
target_link_libraries(aeolus_core PUBLIC OpenMP::OpenMP_CXX)
endif()
# --- Executable Application ---
add_executable(Aeolus app/main.cpp)
target_link_libraries(Aeolus PRIVATE aeolus_core Eigen3::Eigen)
# --- Unit Test Suite ---
enable_testing()
include(CTest)
add_executable(tests
tests/test_main.cpp
tests/test_vector3.cpp
tests/test_geometry.cpp
tests/test_cell_geometry.cpp
tests/test_topology.cpp
tests/test_gmsh_loader.cpp
tests/test_sparse_matrix.cpp
tests/test_poisson.cpp
tests/test_convection.cpp
tests/test_simple.cpp
tests/test_petsc.cpp
)
target_link_libraries(tests PRIVATE aeolus_core Catch2::Catch2)
list(APPEND CMAKE_MODULE_PATH "${Catch2_SOURCE_DIR}/extras")
include(Catch)
catch_discover_tests(tests)