-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
230 lines (206 loc) · 11.3 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
############################# Superbuild Project #############################
cmake_minimum_required(VERSION 3.1 FATAL_ERROR) # CMAKE_CXX_STANDARD, BUILD_ALWAYS
project(psi4
LANGUAGES C CXX)
set(psi4_URL "http://www.psicode.org/")
set(psi4_EMAIL "[email protected]")
set(psi4_LICENSE "GNU General Public License, version 2")
set(psi4_DESCRIPTION "Open-Source Quantum Chemistry")
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake
${CMAKE_SOURCE_DIR}/cmake/math)
################ Options: Overview and Not Otherwise Mentioned ###############
# <<< CMake build overview >>>
#
# >>> ls
# external/ LICENSE 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
# 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/python2.7)"
# - PYTHON_LIBRARY "Python library that goes with the interpreter (e.g., /path/to/lib/python2.7.so)"
# - PYTHON_INCLUDE_DIR "Path to the python include files (e.g., /path/to/include/python2.7)"
# - SPHINX_ROOT "Root directory for Sphinx: 'bin/sphinx-build' (or similar) should be in this dir."
#
# For any ${AddOn} of: CheMPS2, dkh, libefp, erd, gdma, libint, pybind11
# - 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"
# <<< Install >>>
#
# - CMAKE_INSTALL_PREFIX "Location to which Psi4 and internally built add-ons are installed (e.g., /path/to/install-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 /"
############################ Options: Build What? ############################
option(ENABLE_AMBIT "Enables the Ambit tensor library" OFF)
option(ENABLE_CheMPS2 "Enables CheMPS2 for DMRG (requires HDF5)" OFF)
option(ENABLE_dkh "Enables DKH integrals (requires Fortran)" OFF)
option(ENABLE_erd "Enables use of ERD instead of LibInt (requires Fortran)" OFF)
option(ENABLE_gdma "Enables Stone's gdma multipole code (requires Fortran)" OFF)
option(ENABLE_g2dma "Enables Stone's gdma multipole code (requires Fortran)" OFF)
option(ENABLE_GTFock "Enables GTFock (requires MPI)" OFF)
option(ENABLE_PCMSolver "Enables PCMSolver library (requires Fortran)" OFF)
# These options are relevant to pasture
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_psi4pasture ON)
message(STATUS "Enabling pasture plugins")
endif()
if(ENABLE_gdma OR ENABLE_dkh OR ENABLE_erd OR ENABLE_PCMSolver) # OR ENABLE_JKFACTORY
enable_language(Fortran)
set(Fortran_ENABLED ON) # communicate required languages with psi4-core
message(STATUS "Enabling Fortran")
endif()
if(ENABLE_erd)
message(WARNING "ERD will build, link, and run in Psi4 just fine. However, it has not been hooked into Psi4 in all roles, so upon activating through ``set integral_package erd``, it will give *wrong* answers for density-fitting (default) calculations, indeed all except for ``set scf_type direct`` will be wrong. Consider this your warning.")
endif()
############################ Options: Build How? #############################
include(Psi4Macros)
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_flags(ENABLE_XHOST "Enables processor-specific optimization" ON
"-xHost" "-march=native")
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" OFF
"-fsanitize=address" "-fno-omit-frame-pointer")
option_with_flags(ENABLE_TSAN "Enables thread sanitizer" OFF
"-fsanitize=thread" "-fno-omit-frame-pointer -pie")
option_with_flags(ENABLE_UBSAN "Enables undefined behavior sanitizer" OFF
"-fsanitize=undefined" "-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 system and math 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" 11)
######################## Process & Validate Options ##########################
include(GNUInstallDirs)
include(autocmake_safeguards)
include(custom_color_messages)
#find_package(PythonLibsNew REQUIRED)
find_package(PythonInterp REQUIRED)
find_package(PythonLibs ${PYTHON_VERSION_MAJOR} REQUIRED)
set(STAGED_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/stage${CMAKE_INSTALL_PREFIX})
add_subdirectory(external)
# external projects manage their own OpenMP and c++YY flags, so only add to CXX_FLAGS for psi4_core
include(autocmake_omp)
include(custom_cxxstandard)
include(autocmake_static_library)
################################ Dependencies ################################
set(MKL_COMPILER_BINDINGS "${CMAKE_CXX_COMPILER_ID}")
set(BLAS_LANG "CXX")
set(LAPACK_LANG "CXX")
include(ConfigMath)
#These packages don't believe in configuration files...
foreach(pkg in pcmsolver)
string(TOUPPER "${pkg}" PKG)
if(NOT ${PKG}_ROOT)
set(${PKG}_ROOT ${STAGED_INSTALL_PREFIX}/external)
endif()
endforeach()
list(APPEND CMAKE_PREFIX_PATH ${STAGED_INSTALL_PREFIX}/external)
################################ Main Project ################################
include(ExternalProject)
ExternalProject_Add(psi4_core
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/psi4
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_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_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}
-DBUILD_FPIC=${BUILD_FPIC}
-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_erd=${ENABLE_erd}
-DENABLE_gdma=${ENABLE_gdma}
-DENABLE_GTFock=${ENABLE_GTFock}
-DENABLE_PCMSolver=${ENABLE_PCMSolver}
-DENABLE_psi4pasture=${ENABLE_psi4pasture}
-DPCMSOLVER_ROOT=${PCMSOLVER_ROOT}
-DCheMPS2_DIR=${CheMPS2_DIR}
-Ddkh_DIR=${dkh_DIR}
-Dlibefp_DIR=${libefp_DIR}
-Derd_DIR=${erd_DIR}
-Dgdma_DIR=${gdma_DIR}
-DGTFock_DIR=${GTFock_DIR}
-Dlibint_DIR=${libint_DIR}
-Dpybind11_DIR=${pybind11_DIR}
-DFortran_ENABLED=${Fortran_ENABLED}
-DLIBC_INTERJECT=${LIBC_INTERJECT}
-DRESTRICT_KEYWORD=${RESTRICT_KEYWORD}
-DFC_SYMBOL=${FC_SYMBOL}
-DDESTDIR=${CMAKE_BINARY_DIR}/stage
CMAKE_CACHE_ARGS -DCMAKE_PREFIX_PATH:PATH=${CMAKE_PREFIX_PATH}
-DLAPACKBLAS_LIBRARIES:LIST=${LAPACKBLAS_LIBRARIES}
-DLAPACKBLAS_INCLUDE_DIRS:LIST=${LAPACKBLAS_INCLUDE_DIRS}
BUILD_ALWAYS 1
INSTALL_COMMAND ${CMAKE_MAKE_PROGRAM} install
DESTDIR=${CMAKE_BINARY_DIR}/stage
)
add_dependencies(psi4_core ambit_external
chemps2_external
dkh_external
libefp_external
erd_external
gdma_external
#gtfock_external
libint_external
pcmsolver_external
pybind11_external)
add_subdirectory(internals/pasture)
add_subdirectory(doc)
include(ConfigTesting)
# <<< Install >>>
install(DIRECTORY ${STAGED_INSTALL_PREFIX}/
DESTINATION ${CMAKE_INSTALL_PREFIX}
USE_SOURCE_PERMISSIONS)
install(DIRECTORY samples
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATADIR}/psi4
USE_SOURCE_PERMISSIONS
PATTERN "example_psi4rc_file" EXCLUDE)
#install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/cmake
# DESTINATION ${CMAKE_INSTALL_PREFIX} USE_SOURCE_PERMISSIONS)