-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
289 lines (264 loc) · 15.7 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
############################# Superbuild Project #############################
cmake_minimum_required(VERSION 3.8 FATAL_ERROR) # 3.8: CXX_STANDARD recognizes C++17
# 3.3: EP_add(DEPENDS interfacelib, CheckFortranCompilerFlag
# 3.2: continue()
# 3.1: CMAKE_CXX_STANDARD, BUILD_ALWAYS
project(psi4
LANGUAGES C CXX)
set(psi4_URL "http://www.psicode.org/")
set(psi4_EMAIL "psi4aiqc+cmake@gmail.com")
set(psi4_LICENSE "GNU Lesser General Public License, version 3 (LGPL-3.0)")
set(psi4_DESCRIPTION "Open-Source Quantum Chemistry")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
################ Options: Overview and Not Otherwise Mentioned ###############
# <<< CMake build overview >>>
#
# >>> ls
# external/ COPYING psi4/ tests/ ...
# >>> cmake -H. -Bobjdir -DCMAKE_INSTALL_PREFIX=/path/to/install-psi4 ...
# ...
# -- Generating done
# -- Build files have been written to: /current/dir/objdir
# >>> cd objdir && make -j`getconf _NPROCESSORS_ONLN`
# >>> make install
# <<< Required build dependencies that Psi4 can't build itself >>>
#
# - CMake (e.g., `conda install cmake`)
# - C++ and C compilers (C++11 compliant)
# - BLAS/LAPACK (also runtime; e.g., `conda install mkl-devel`)
# - Python (also runtime; interpreter and headers; e.g., `conda install python`)
# - NumPy (also runtime; avoidable at buildtime if gau2grid pre-built; e.g., `conda install numpy`)
# - networkx >=2.4 (runtime only; e.g., `conda install networkx`)
# - pint (runtime only; e.g., `conda install pint -c conda-forge`)
# - pydantic >=1.0 (runtime only; e.g., `conda install pydantic -c conda-forge`)
# - msgpack-python (runtime only; e.g., `conda install msgpack-python`)
# These three "### Options ###" sections contain useful CMake variables for build configuration.
# <<< Compilers and flags >>>
#
# - CMAKE_C_COMPILER "C compiler"
# - CMAKE_C_FLAGS "Additional C flags"
# - CMAKE_CXX_COMPILER "C++ compiler"
# - CMAKE_CXX_FLAGS "Additional C++ flags"
# - CMAKE_Fortran_COMPILER "Fortran compiler (required for some add-ons)"
# - CMAKE_Fortran_FLAGS "Additional Fortran flags"
# <<< Detecting dependencies and add-ons >>>
#
# - PYTHON_EXECUTABLE "Python interpreter to use (e.g., /path/to/bin/python3.7)"
# - PYTHON_LIBRARY "Python library that goes with the interpreter (e.g., /path/to/lib/python3.7.so)"
# - PYTHON_INCLUDE_DIR "Path to the python include files (e.g., /path/to/include/python3.7)"
# - SPHINX_ROOT "Root directory for Sphinx: 'bin/sphinx-build' (or similar) should be in this dir."
#
# For any ${AddOn} of: ambit, CheMPS2, dkh, libefp, erd, gau2grid, gdma, Libint, PCMSolver, pybind11, pylibefp,
# qcelemental, qcengine, simint, Libxc
# - CMAKE_PREFIX_PATH "Set to list of root directories to look for externally built add-ons and dependencies
# (e.g., /path/to/install-libint;/path/to/install-gdma where exists /path/to/install-libint/lib/libderiv.a)"
# - ${AddOn}_DIR "Set to directory containing ${AddOn}Config.cmake file to facilitate detection of external build"
# - CMAKE_DISABLE_FIND_PACKAGE_${AddON} "Set to OFF to force internal build"
# - CMAKE_INSIST_FIND_PACKAGE_${AddON} "Set to ON to force external detect"
# <<< Detecting BLAS/LAPACK >>>
#
# - ENV(MATH_ROOT) "Root directory where BLAS/LAPACK libraries should be detected (e.g., ${MATH_ROOT}/lib/libblas.so)"
# - BLAS_TYPE "Target BLAS distribution for math detection
# (default: search order MKL>OPENBLAS>ESSL>ATLAS>ACML>SYSTEM_NATIVE on Linux; MKL>Accelerate>... on Mac)"
# - LAPACK_TYPE "Target LAPACK distribution for math detection
# (default: search order MKL>OPENBLAS>ESSL>ATLAS>ACML>SYSTEM_NATIVE on Linux; MKL>Accelerate>... on Mac)"
# - LAPACK_LIBRARIES "Location of BLAS/LAPACK libraries as ";"-separated list of full paths, bypassing math detection"
# - LAPACK_INCLUDE_DIRS "Location of BLAS/LAPACK headers (only needed for MKL), bypassing math detection"
# - OpenMP_LIBRARY_DIRS "Location of OpenMP libraries (iomp5/gomp/omp) as ";"-separated list, hinting OpenMP detection"
# <<< Install >>>
#
# - CMAKE_INSTALL_PREFIX "Location to which Psi4 and internally built add-ons are installed (default: /usr/local/psi4)"
# - CMAKE_INSTALL_BINDIR "Location within CMAKE_INSTALL_PREFIX to which executables are installed (default: bin)"
# - CMAKE_INSTALL_LIBDIR "Location within CMAKE_INSTALL_PREFIX to which libraries are installed (default: lib)"
# - CMAKE_INSTALL_DATADIR "Location within CMAKE_INSTALL_PREFIX to which resources are installed (default: share)"
# - CMAKE_INSTALL_INCLUDEDIR "Location within CMAKE_INSTALL_PREFIX to which headers are installed (default: include)"
# - PYMOD_INSTALL_LIBDIR "Location within CMAKE_INSTALL_LIBDIR to which python modules are installed (default: /)
# Must start with: / . Used to imitate python install: /python3.6/site-packages ."
############################ Options: Build What? ############################
option(ENABLE_ambit "Enables the ambit tensor library" OFF)
option(ENABLE_CheMPS2 "Enables CheMPS2 for DMRG (requires HDF5)" OFF)
option(ENABLE_cppe "Enables CPPE for Polarizable Embedding" OFF)
option(ENABLE_adcc "Enables adcc for algebraic-diagrammatic construction methods (can also be added at runtime)" OFF)
option(ENABLE_dkh "Enables DKH integrals (requires Fortran)" OFF)
option(ENABLE_libefp "Enables LIBEFP and PylibEFP for fragments" OFF)
option(ENABLE_erd "Enables use of ERD instead of Libint (requires Fortran)" OFF)
option(ENABLE_simint "Enables use of SIMINT two-electron integral library" OFF)
option(ENABLE_gdma "Enables Stone's GDMA multipole code (requires Fortran)" OFF)
option(ENABLE_PCMSolver "Enables PCMSolver library (requires Fortran)" OFF)
option(ENABLE_snsmp2 "Enables SNSMP2 plugin (can also be added at runtime)" OFF)
option(ENABLE_v2rdm_casscf "Enables V2RDM_CASSCF plugin (requires Fortran; can also be added at runtime)" OFF)
option(ENABLE_psi4fockci "Enables Psi4FockCI plugin (can also be added at runtime)" OFF)
option(ENABLE_cct3 "Enables cct3 plugin (requires Fortran; can also be added at runtime)" OFF)
option(ENABLE_gpu_dfcc "Enables GPU_DFCC plugin for gpu-accelerated df-cc (requires CUDA; can also be added at runtime)" OFF)
option(ENABLE_mdi "Enables MolSSI driver interface" OFF)
option(ENABLE_BrianQC "Enables the BrianQC GPU module (requires CUDA; requires separate installation and licensing of the BrianQC module)" OFF)
# These options are relevant to pasture, expert only
option(ENABLE_ccsort "Enables ccsort plugin installed from psi4pasture" OFF)
option(ENABLE_transqt2 "Enables transqt2 plugin installed from psi4pasture" OFF)
# Append modules added to pasture as needed
if(ENABLE_ccsort OR ENABLE_transqt2)
set(ENABLE_pasture ON)
message(STATUS "Enabling pasture plugins")
endif()
if(ENABLE_gdma OR ENABLE_dkh OR ENABLE_erd OR ENABLE_PCMSolver)
enable_language(Fortran)
set(Fortran_ENABLED ON) # communicate required languages with psi4-core
message(STATUS "Enabling Fortran")
endif()
if(ENABLE_erd)
message(FATAL_ERROR "The Psi4/ERD interface is broken, probably since spring 2017. It's toast (comment this line to try), but disabling for now.")
message(WARNING "ERD will build, link, and run in Psi4 just fine. However, it has not been hooked into Psi4 in all roles, notably gradients, LRC DFT energies, and ESP. So upon activating through ``set integral_package erd``, known failures will be caught and halted, but perhaps other types not tested and identified will give *wrong* answers. Consider this your warning.")
endif()
############################ Options: Build How? #############################
include(psi4OptionsTools)
option_with_print(BUILD_SHARED_LIBS "Build internally built Psi4 add-on libraries as shared, not static" OFF)
option_with_print(ENABLE_OPENMP "Enables OpenMP parallelization" ON)
option_with_print(ENABLE_AUTO_BLAS "Enables CMake to auto-detect BLAS" ON)
option_with_print(ENABLE_AUTO_LAPACK "Enables CMake to auto-detect LAPACK" ON)
option_with_print(ENABLE_PLUGIN_TESTING "Test the plugin templates build and run" OFF)
option_with_print(ENABLE_CYTHONIZE "Compile each python file rather than plaintext (requires cython) !experimental!" OFF)
option_with_flags(ENABLE_XHOST "Enables processor-specific optimization (with MSVC, it enables AVX2 instructions)" ON
"-xHost" "-march=native" "/arch:AVX2")
option_with_flags(ENABLE_CODE_COVERAGE "Enables details on code coverage" OFF
"-ftest-coverage")
option_with_flags(ENABLE_BOUNDS_CHECK "Enables bounds check in Fortran" OFF
"-ftrapuv -check all -fpstkchk" "-fcheck=all" "-fbounds-check -fcheck-array-temporaries")
option_with_flags(ENABLE_ASAN "Enables address sanitizer (requires similarly compiled Python and Numpy)" OFF
"-fsanitize=address -fno-omit-frame-pointer")
option_with_flags(ENABLE_TSAN "Enables thread sanitizer (requires similarly compiled Python and Numpy)" OFF
"-fsanitize=thread -fPIE -pie -fno-omit-frame-pointer")
option_with_flags(ENABLE_UBSAN "Enables undefined behavior sanitizer (requires similarly compiled Python and Numpy)" OFF
"-fsanitize=undefined -fno-omit-frame-pointer")
option_with_flags(ENABLE_MSAN "Enables memory sanitizer (requires similarly compiled Python and Numpy)" OFF
"-fsanitize=memory -fPIE -pie -fno-omit-frame-pointer")
option_with_default(MAX_AM_ERI "Maximum angular momentum for integrals" 5)
option_with_default(CMAKE_BUILD_TYPE "Build type (Release or Debug)" Release)
option_with_default(FC_SYMBOL "The type of Fortran name mangling" 2)
option_with_default(BUILD_FPIC "Compile static libraries with position independent code" ON)
option_with_default(CMAKE_INSTALL_LIBDIR "Directory to which libraries installed" lib)
option_with_default(PYMOD_INSTALL_LIBDIR "Location within CMAKE_INSTALL_LIBDIR to which python modules are installed" /)
option_with_default(ENABLE_GENERIC "Enables mostly static linking of language libraries for shared library" OFF)
option_with_default(CMAKE_INSTALL_MESSAGE "Specify verbosity of installation messages" LAZY)
option_with_default(psi4_CXX_STANDARD "Specify C++ standard for core Psi4" 14)
option_with_default(SIMINT_VECTOR "Vectorization type to use for simint (scalar sse avx avxfma micavx512)" avx)
option_with_default(SPHINX_THEME "Theme for Sphinx documentation and extensions" sphinx_psi_theme)
######################## Process & Validate Options ##########################
include(GNUInstallDirs)
include(autocmake_safeguards)
include(custom_color_messages)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "/usr/local/psi4" CACHE PATH "Install path" FORCE)
endif()
message(STATUS "Psi4 install: ${CMAKE_INSTALL_PREFIX}")
# Python use in psi4 (not incl. external/)
# * interpreter: run the versioner in psi4-core. run tests and build docs in psi4
# * headers: Python.h for pybind11 to build against in psi4-core
# * library: not at all
set(Python_ADDITIONAL_VERSIONS 3.8 3.7 3.6) # adjust with CMake minimum FindPythonInterp
find_package(PythonLibsNew 3.6 REQUIRED)
message(STATUS "${Cyan}Found Python ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}${ColourReset}: ${PYTHON_EXECUTABLE} (found version ${PYTHON_VERSION_STRING})")
set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage)
message(STATUS "Psi4 staging: ${STAGED_INSTALL_PREFIX}")
add_subdirectory(external/common)
add_subdirectory(external/upstream)
# external projects manage their own OpenMP and c++YY flags, so only add to CXX_FLAGS for psi4-core
include(custom_cxxstandard)
include(custom_static_library)
################################ Main Project ################################
include(ExternalProject)
ExternalProject_Add(psi4-core
DEPENDS lapack_external
hdf5_external
ambit_external
chemps2_external
cppe_external
dkh_external
libefp_external
erd_external
gau2grid_external
gdma_external
libint_external
pcmsolver_external
pybind11_external
pylibefp_external
qcelemental_external
qcengine_external
simint_external
libxc_external
mdi_external
brianqc_external
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/psi4
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${STAGED_INSTALL_PREFIX}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_STANDARD=${psi4_CXX_STANDARD}
-DCMAKE_CXX_STANDARD_REQUIRED=ON
-DCMAKE_CXX_EXTENSIONS=OFF
-DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}
-DCMAKE_Fortran_FLAGS=${CMAKE_Fortran_FLAGS}
-DCMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
-DCMAKE_INSTALL_BINDIR=${CMAKE_INSTALL_BINDIR}
-DCMAKE_INSTALL_DATADIR=${CMAKE_INSTALL_DATADIR}
-DCMAKE_INSTALL_INCLUDEDIR=${CMAKE_INSTALL_INCLUDEDIR}
-DCMAKE_INSTALL_MESSAGE=${CMAKE_INSTALL_MESSAGE}
-DPYMOD_INSTALL_LIBDIR=${PYMOD_INSTALL_LIBDIR}
-DMAX_AM_ERI=${MAX_AM_ERI}
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
-DPYTHON_INCLUDE_DIR=${PYTHON_INCLUDE_DIR}
-DPYTHON_LIBRARY=${PYTHON_LIBRARY}
-DPSI4_ROOT=${CMAKE_CURRENT_SOURCE_DIR}
-DENABLE_ambit=${ENABLE_ambit}
-DENABLE_CheMPS2=${ENABLE_CheMPS2}
-DENABLE_dkh=${ENABLE_dkh}
-DENABLE_libefp=${ENABLE_libefp}
-DENABLE_cppe=${ENABLE_cppe}
-DENABLE_erd=${ENABLE_erd}
-DENABLE_simint=${ENABLE_simint}
-DENABLE_gdma=${ENABLE_gdma}
-DENABLE_PCMSolver=${ENABLE_PCMSolver}
-DENABLE_mdi=${ENABLE_mdi}
-DENABLE_BrianQC=${ENABLE_BrianQC}
-DENABLE_OPENMP=${ENABLE_OPENMP}
-DTargetLAPACK_DIR=${TargetLAPACK_DIR}
-DTargetHDF5_DIR=${TargetHDF5_DIR}
-Dambit_DIR=${ambit_DIR}
-DCheMPS2_DIR=${CheMPS2_DIR}
-Ddkh_DIR=${dkh_DIR}
-Dlibefp_DIR=${libefp_DIR}
-Dcppe_DIR=${cppe_DIR}
-Derd_DIR=${erd_DIR}
-Dgau2grid_DIR=${gau2grid_DIR}
-Dgdma_DIR=${gdma_DIR}
-DLibint_DIR=${Libint_DIR}
-DPCMSolver_DIR=${PCMSolver_DIR}
-Dmdi_DIR=${mdi_DIR}
-Dpybind11_DIR=${pybind11_DIR}
-Dpylibefp_DIR=${pylibefp_DIR}
-Dsimint_DIR=${simint_DIR}
-DLibxc_DIR=${Libxc_DIR}
-DBrianQC_DIR=${BrianQC_DIR}
-DFortran_ENABLED=${Fortran_ENABLED}
-DLIBC_INTERJECT=${LIBC_INTERJECT}
-DRESTRICT_KEYWORD=${RESTRICT_KEYWORD}
-DFC_SYMBOL=${FC_SYMBOL}
-DOpenMP_LIBRARY_DIRS=${OpenMP_LIBRARY_DIRS}
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-DENABLE_CYTHONIZE=${ENABLE_CYTHONIZE}
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
USES_TERMINAL_BUILD 1
BUILD_ALWAYS 1)
add_subdirectory(external/downstream)
add_subdirectory(doc)
include(ConfigTesting)
# <<< Install >>>
install(DIRECTORY ${STAGED_INSTALL_PREFIX}/
DESTINATION ${CMAKE_INSTALL_PREFIX}
USE_SOURCE_PERMISSIONS
PATTERN "*.pyc" EXCLUDE)
install(DIRECTORY samples
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/psi4
USE_SOURCE_PERMISSIONS
PATTERN "example_psi4rc_file" EXCLUDE)