-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
192 lines (171 loc) · 6.36 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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
### CMake version ###
CMAKE_MINIMUM_REQUIRED(VERSION 3.0 FATAL_ERROR)
### Project ###
PROJECT(elsi VERSION 2.9.1 LANGUAGES NONE)
SET(elsi_URL "http://elsi-interchange.org")
SET(elsi_EMAIL "[email protected]")
SET(elsi_LICENSE "BSD 3")
SET(elsi_DESCRIPTION "Electronic Structure Infrastructure")
SET(elsi_DATESTAMP "20220118")
### CMake modules ###
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
INCLUDE(Utils)
### Installation paths ###
IF(PROJECT_BINARY_DIR STREQUAL PROJECT_SOURCE_DIR)
MESSAGE(FATAL_ERROR "${MAGENTA}Build in the source directory is not allowed${COLORRESET}")
ENDIF()
SET(CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/include")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
FILE(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/generated")
IF(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
SET(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "Location to install module and header files")
ENDIF()
IF(NOT DEFINED CMAKE_INSTALL_LIBDIR)
SET(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "Location to install library files")
ENDIF()
### Options ###
OPTION(ENABLE_TESTS "Build ELSI Fortran test programs" OFF)
OPTION(ENABLE_C_TESTS "Build ELSI C test programs" OFF)
OPTION(ENABLE_PEXSI "Enable PEXSI" OFF)
OPTION(ENABLE_EIGENEXA "Enable EigenExa" OFF)
OPTION(ENABLE_SIPS "Enable SLEPc-SIPs" OFF)
OPTION(ENABLE_MAGMA "Enable MAGMA" OFF)
OPTION(ENABLE_BSEPACK "Enable BSEPACK" OFF)
OPTION(USE_MPI_MODULE "Use MPI module instead of mpif.h in Fortran code" OFF)
OPTION(ELSI_USE_FIND_PACKAGE_MPI "Use find_package(MPI)" OFF)
OPTION(USE_EXTERNAL_ELPA "Use external ELPA" OFF)
OPTION(USE_ELPA_2021 "Use ELPA 2021" OFF)
OPTION(USE_EXTERNAL_OMM "Use external libOMM" OFF)
OPTION(USE_EXTERNAL_PEXSI "Use external PEXSI" OFF)
OPTION(USE_EXTERNAL_NTPOLY "Use external NTPoly" OFF)
OPTION(USE_EXTERNAL_BSEPACK "Use external BSEPACK" OFF)
OPTION(USE_GPU_CUDA "Use GPU acceleration based on CUDA" OFF)
OPTION(ADD_UNDERSCORE "Suffix C functions with an underscore" ON)
OPTION(BUILD_SHARED_LIBS "Whether to build shared or static libraries" OFF)
SET(ELPA2_KERNEL "" CACHE STRING "Use AVX/AVX2/AVX512 ELPA2 kernel")
SET(MPIEXEC_NP "mpirun -n 4" CACHE STRING "Command to run parallel tests with multiple MPI tasks")
SET(MPIEXEC_1P "mpirun -n 1" CACHE STRING "Command to run serial tests with 1 MPI task")
SET(SCOTCH_LAST_RESORT "NOT_USED" CACHE STRING "Command to run PT-SCOTCH header generation")
SET(LIB_PATHS "" CACHE STRING "List of directories containing libraries to be linked against")
SET(INC_PATHS "" CACHE STRING "List of include directories")
SET(LIBS "" CACHE STRING "List of external libraries to be linked against")
### Compilers ###
IF(NOT DEFINED CMAKE_Fortran_COMPILER)
MESSAGE(FATAL_ERROR "${MAGENTA}Fortran compiler must be set${COLORRESET}")
ENDIF()
ENABLE_LANGUAGE(Fortran)
IF(NOT DEFINED CMAKE_C_COMPILER)
MESSAGE(FATAL_ERROR "${MAGENTA}C compiler must be set${COLORRESET}")
ENDIF()
ENABLE_LANGUAGE(C)
IF(ENABLE_PEXSI)
IF(NOT DEFINED CMAKE_CXX_COMPILER)
MESSAGE(FATAL_ERROR "${MAGENTA}C++ compiler must be set${COLORRESET}")
ENDIF()
ENABLE_LANGUAGE(CXX)
ENDIF()
IF(USE_GPU_CUDA)
IF(${CMAKE_VERSION} VERSION_LESS 3.8)
MESSAGE(FATAL_ERROR "${MAGENTA}CUDA support requires CMake 3.8 or higher${COLORRESET}")
ENDIF()
ENABLE_LANGUAGE(CUDA)
# See gitlab.kitware.com/cmake/cmake/issues/17797
IF(NOT CMAKE_GENERATOR STREQUAL Ninja AND ${CMAKE_VERSION} VERSION_LESS 3.11)
SET(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES 0)
SET(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_LIBRARIES 0)
SET(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_OBJECTS 0)
ENDIF()
ENDIF()
### External libraries ###
STRING(REPLACE "-l" "" LIBS "${LIBS}")
FOREACH(str LIBS LIB_PATHS INC_PATHS)
convert_to_list(${str})
ENDFOREACH()
generate_library_targets(LIB_PATHS LIBS)
### Compilations ###
IF(USE_EXTERNAL_ELPA)
MESSAGE(STATUS "Using external ELPA")
ELSE()
MESSAGE(STATUS "Enabling internal ELPA")
IF(USE_ELPA_2021)
ADD_SUBDIRECTORY(external/ELPA-2021.11.001)
ELSE()
ADD_SUBDIRECTORY(external/ELPA)
ENDIF()
ENDIF()
IF(USE_EXTERNAL_OMM)
MESSAGE(STATUS "Using external libOMM")
ELSE()
MESSAGE(STATUS "Enabling internal libOMM")
ADD_SUBDIRECTORY(external/libOMM)
ENDIF()
IF(ENABLE_PEXSI)
IF(USE_EXTERNAL_PEXSI)
MESSAGE(STATUS "Using external PEXSI")
ELSE()
MESSAGE(STATUS "Enabling internal PEXSI")
MESSAGE(STATUS "Enabling internal SuperLU_DIST")
MESSAGE(STATUS "Enabling internal PT-SCOTCH")
ADD_SUBDIRECTORY(external/PEXSI)
ADD_SUBDIRECTORY(external/SuperLU_DIST)
ADD_SUBDIRECTORY(external/SCOTCH)
ENDIF()
SET(ENABLE_PEXSI_BOOL 1)
ELSE()
SET(ENABLE_PEXSI_BOOL 0)
ENDIF()
IF(ENABLE_EIGENEXA)
MESSAGE(STATUS "Enabling EigenExa")
SET(ENABLE_EIGENEXA_BOOL 1)
ELSE()
SET(ENABLE_EIGENEXA_BOOL 0)
ENDIF()
IF(ENABLE_SIPS)
MESSAGE(STATUS "Enabling SLEPc-SIPs")
ADD_SUBDIRECTORY(external/SIPS)
SET(ENABLE_SIPS_BOOL 1)
ELSE()
SET(ENABLE_SIPS_BOOL 0)
ENDIF()
IF(USE_EXTERNAL_NTPOLY)
MESSAGE(STATUS "Using external NTPoly")
ELSE()
MESSAGE(STATUS "Enabling internal NTPoly")
ADD_SUBDIRECTORY(external/NTPoly)
ENDIF()
IF(ENABLE_MAGMA)
MESSAGE(STATUS "Enabling MAGMA")
SET(ENABLE_MAGMA_BOOL 1)
ELSE()
SET(ENABLE_MAGMA_BOOL 0)
ENDIF()
IF(ENABLE_BSEPACK)
IF(USE_EXTERNAL_BSEPACK)
MESSAGE(STATUS "Using external BSEPACK")
ELSE()
MESSAGE(STATUS "Enabling internal BSEPACK")
ADD_SUBDIRECTORY(external/BSEPACK)
ENDIF()
SET(ENABLE_BSEPACK_BOOL 1)
ELSE()
SET(ENABLE_BSEPACK_BOOL 0)
ENDIF()
ADD_SUBDIRECTORY(external/FortJSON)
ADD_SUBDIRECTORY(src)
IF(ENABLE_TESTS OR ENABLE_C_TESTS)
MESSAGE(STATUS "Enabling test programs")
ENABLE_TESTING()
ADD_SUBDIRECTORY(test)
ENDIF()
ADD_CUSTOM_TARGET(pack rm -rf ${PROJECT_BINARY_DIR}/elsi_packed
COMMAND mkdir ${PROJECT_BINARY_DIR}/elsi_packed
COMMAND cp ${PROJECT_SOURCE_DIR}/.elsi.pc.in ${PROJECT_BINARY_DIR}/elsi_packed
COMMAND cp ${PROJECT_SOURCE_DIR}/CMakeLists.txt ${PROJECT_BINARY_DIR}/elsi_packed
COMMAND cp ${PROJECT_SOURCE_DIR}/LICENSE ${PROJECT_BINARY_DIR}/elsi_packed
COMMAND cp ${PROJECT_SOURCE_DIR}/README.md ${PROJECT_BINARY_DIR}/elsi_packed
COMMAND cp -r ${PROJECT_SOURCE_DIR}/cmake ${PROJECT_BINARY_DIR}/elsi_packed
COMMAND cp -r ${PROJECT_SOURCE_DIR}/external ${PROJECT_BINARY_DIR}/elsi_packed
COMMAND cp -r ${PROJECT_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/elsi_packed
VERBATIM)