-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
136 lines (115 loc) · 3.88 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
cmake_minimum_required(VERSION 3.12)
project(ezp)
if (NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
message(FATAL_ERROR "Only Linux is supported.")
endif ()
include_directories(${PROJECT_SOURCE_DIR})
include_directories(${PROJECT_SOURCE_DIR}/include)
if (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(-Rno-debug-disables-optimization)
add_link_options(-Rno-debug-disables-optimization)
endif ()
set(CMAKE_CXX_STANDARD 20)
option(EZP_ADD_UNDERSCORE "Use lowercase with appended underscore subroutine names." ON)
if (EZP_ADD_UNDERSCORE)
add_compile_definitions(EZP_UNDERSCORE)
endif ()
option(EZP_USE_64BIT_INT "Use 64-bit integer." OFF)
set(MKL_LINK static)
string(TOLOWER "${MPI_HOME}" MPI_PATH_LOWER)
if (MPI_PATH_LOWER MATCHES "openmpi")
set(MKL_MPI openmpi)
message(STATUS "MKL_MPI: ${MKL_MPI}")
elseif (MPI_PATH_LOWER MATCHES "mpich")
set(MKL_MPI mpich)
message(STATUS "MKL_MPI: ${MKL_MPI}")
endif ()
if (EZP_USE_64BIT_INT)
add_compile_definitions(EZP_INT64)
set(MKL_INTERFACE ilp64)
else ()
set(MKL_INTERFACE lp64)
endif ()
find_package(MKL QUIET)
if (MKL_FOUND)
message(STATUS "Using MKL.")
link_libraries(MKL::MKL_SCALAPACK)
add_compile_definitions(EZP_MKL)
endif ()
find_package(MPI REQUIRED)
message(STATUS ${MPIEXEC_EXECUTABLE})
if (NOT MKL_FOUND)
option(EZP_USE_SYSTEM_LIBS "Use system libraries." OFF)
if (EZP_USE_SYSTEM_LIBS)
find_library(SCALAPACK_LIB scalapack)
if (SCALAPACK_LIB)
message(STATUS "Using system libraries.")
link_libraries(${SCALAPACK_LIB})
else ()
message(FATAL_ERROR "ScaLAPACK not found.")
endif ()
find_library(FLEX_LIB flexiblas)
if (FLEX_LIB)
link_libraries(${FLEX_LIB})
endif ()
find_library(OPENBLAS_LIB openblas)
if (OPENBLAS_LIB)
message(STATUS "Using OpenBLAS.")
link_libraries(${OPENBLAS_LIB})
endif ()
else ()
link_directories(${PROJECT_SOURCE_DIR}/libs)
string(TOLOWER ${MPI_C_INCLUDE_DIRS} MPI_PATH)
if (MPI_PATH MATCHES "openmpi")
message(STATUS "Using OpenMPI.")
link_libraries(scalapack-openmpi)
else ()
message(STATUS "Using MPICH.")
link_libraries(scalapack-mpich)
endif ()
link_libraries(lapack blas gfortran)
endif ()
endif ()
link_libraries(MPI::MPI_C MPI::MPI_CXX)
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-Wall)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-fprofile-arcs -ftest-coverage -fconcepts-diagnostics-depth=4)
link_libraries(gcov)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
endif ()
option(EZP_ASAN "Enable asan." OFF)
endif ()
if (EZP_ASAN)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif ()
file(GLOB EXAMPLES "*.cpp" "examples/*.cpp")
foreach (EXAMPLE ${EXAMPLES})
get_filename_component(EXAMPLE_NAME ${EXAMPLE} NAME_WLE)
add_executable(${EXAMPLE_NAME} ${EXAMPLE})
endforeach ()
option(EZP_TEST "Enable testing." OFF)
if (EZP_TEST)
add_compile_definitions(EZP_ENABLE_TEST)
endif ()
file(GLOB EXAMPLES "tests/*.cpp")
if (EZP_TEST)
add_executable(catch2 ${EXAMPLES} include/catch2/catchy.cpp)
else ()
foreach (EXAMPLE ${EXAMPLES})
get_filename_component(EXAMPLE_NAME ${EXAMPLE} NAME_WLE)
add_executable(${EXAMPLE_NAME} ${EXAMPLE})
endforeach ()
endif ()
option(EZP_STANDALONE "Enable standalone solver." OFF)
if (EZP_STANDALONE)
include_directories(mpl)
file(GLOB EXAMPLES "standalone/*.cpp")
foreach (EXAMPLE ${EXAMPLES})
get_filename_component(EXAMPLE_NAME ${EXAMPLE} NAME_WLE)
add_executable(${EXAMPLE_NAME} ${EXAMPLE})
install(TARGETS ${EXAMPLE_NAME} DESTINATION bin)
endforeach ()
endif ()