-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
executable file
·115 lines (103 loc) · 3.38 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
cmake_minimum_required(VERSION 3.20)
project(fdm)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_package(PkgConfig REQUIRED)
find_package(OpenMP)
enable_testing()
if (EXISTS ${CMAKE_BINARY_DIR}/local.cmake)
include(${CMAKE_BINARY_DIR}/local.cmake)
endif ()
pkg_check_modules(NETCDF REQUIRED netcdf)
pkg_check_modules(PLPLOT REQUIRED plplot)
pkg_check_modules(VULKAN vulkan)
if (NOT BLAS_FOUND)
pkg_check_modules(BLAS openblas)
endif()
if (NOT BLAS_FOUND)
pkg_check_modules(BLAS blas)
endif ()
if (NOT BLAS_FOUND)
pkg_check_modules(BLAS REQUIRED blas-atlas)
endif()
if (NOT LAPACK_FOUND)
include(CheckLibraryExists REQUIRED)
set(CMAKE_REQUIRED_LIBRARIES ${BLAS_LINK_LIBRARIES})
list(GET BLAS_LINK_LIBRARIES 0 HEAD)
check_library_exists(${HEAD} clacpy_ "" HAS_LAPACK)
unset(CMAKE_REQUIRED_LIBRARIES)
if (HAS_LAPACK)
set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
set (LAPACK_LIBRARY_DIRS ${BLAS_LIBRARY_DIRS})
else ()
pkg_check_modules(LAPACK lapack)
endif ()
endif ()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (EXISTS ${CMAKE_SOURCE_DIR}/deps/umfpack/UFconfig/UFconfig.h)
set(UMFPACK_SHARED TRUE)
add_subdirectory(deps/umfpack)
endif()
if (EXISTS ${CMAKE_SOURCE_DIR}/deps/superlu/SRC/superluConfig.cmake.in)
add_subdirectory(deps/superlu_build)
endif ()
if (EXISTS ${CMAKE_SOURCE_DIR}/deps/arpack/CMakeLists.txt)
add_subdirectory(deps/arpack)
endif ()
set(SRC
src/sds_bar.cpp
src/asp_sphere_lapl.cpp
src/asp_gauss.cpp
src/asp_sphere_jac.cpp
src/asp_misc.cpp
src/sds_bar2.cpp
src/asp_lapl.cpp
src/matrix_plot.cpp
src/asp_fft.cpp
src/config.cpp
src/jacobi_solver.cpp
src/gmres_solver.cpp
src/arpack_solver.cpp
src/sparse.cpp
src/fft.cpp
src/lapl_rect.cpp
src/lapl_cyl.cpp
src/lapl_cube.cpp
src/ns_cube.cpp
src/ns_cyl.cpp
src/velocity_plot.cpp
src/eigenvectors_storage.cpp
)
add_library(fdm SHARED ${SRC})
if (VULKAN_FOUND)
find_package(glslang CONFIG REQUIRED)
find_package(Threads REQUIRED)
set(COMPUTE_SRC
compute/vulkan/compute.cpp
compute/vulkan/command_pool.cpp
compute/vulkan/loader.c
compute/vulkan/instance.cpp
compute/vulkan/device.cpp
compute/vulkan/shader.cpp
)
add_library(compute SHARED ${COMPUTE_SRC})
target_link_libraries(compute PUBLIC glslang::glslang glslang::SPIRV glslang::glslang-default-resource-limits)
target_include_directories(compute PUBLIC glslang::glslang glslang::SPIRV glslang::glslang-default-resource-limits)
target_include_directories(compute PUBLIC ${CMAKE_SOURCE_DIR})
endif ()
if (MSVC)
target_compile_options(fdm PUBLIC ${PLPLOT_CFLAGS_OTHER} PRIVATE "/DFDM_LIBRARY_EXPORT" "/W4")
else ()
target_compile_options(fdm PUBLIC ${PLPLOT_CFLAGS_OTHER} "-Wall")
endif()
target_include_directories(fdm PUBLIC ${PLPLOT_INCLUDE_DIRS} ${BLAS_INCLUDE_DIRS} PRIVATE ${NETCDF_INCLUDE_DIRS})
target_link_directories(fdm PUBLIC ${PLPLOT_STATIC_LIBRARY_DIRS} ${BLAS_LIBRARY_DIRS} ${LAPACK_LIBRARY_DIRS} PRIVATE ${NETCDF_LIBRARY_DIRS})
target_link_libraries(fdm PUBLIC ${PLPLOT_STATIC_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} arpack superlu umfpack PRIVATE ${NETCDF_LIBRARIES})
if (OpenMP_CXX_FOUND)
target_link_libraries(fdm PUBLIC OpenMP::OpenMP_CXX)
endif()
add_subdirectory(test)
add_subdirectory(utils)
add_subdirectory(ut)