-
Notifications
You must be signed in to change notification settings - Fork 14
/
CMakeLists.txt
175 lines (149 loc) · 5.67 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
cmake_policy(SET CMP0048 NEW) # project_VERSION* variables populated from project(... VERSION x.x.x) string
project(v2rdm_casscf
VERSION 0.9
LANGUAGES CXX C Fortran)
set(v2rdm_casscf_AUTHORS "A. Eugene DePrince III")
set(v2rdm_casscf_DESCRIPTION "Variational 2-RDM-driven CASSCF plugin to Psi4")
set(v2rdm_casscf_URL "github.com/edeprince3/v2rdm_casscf")
set(v2rdm_casscf_LICENSE "GPL 2+")
cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
# <<< Options >>>
include(psi4OptionsTools)
option_with_print(ENABLE_OPENMP "Enable threadsafe linking to OpenMP parallelized programs." ON)
option_with_print(ENABLE_OPENRDM "Enables connection with OpenRDM program." OFF)
#if (APPLE AND (CMAKE_CXX_COMPILER_ID MATCHES GNU))
# option_with_flags(ENABLE_XHOST "Enable processor-specific optimization" OFF)
#else ()
# option_with_flags(ENABLE_XHOST "Enable processor-specific optimization" ON)
# #"-xHost") # "-march=native")
#endif()
# <<< Prepare >>>
include(custom_color_messages)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
include(custom_color_messages)
set(TargetOpenMP_FIND_COMPONENTS "CXX Fortran")
find_package(psi4 1.0 REQUIRED)
set(PN ${PROJECT_NAME})
# PYMOD_INSTALL_LIBDIR If set, installs python modules to
# ${CMAKE_INSTALL_LIBDIR}${PYMOD_INSTALL_LIBDIR}/v2rdm_casscf rather than
# the default read off parent Psi4
# install alongside psi4 module by default, but overrideable
get_filename_component(psi4_CMAKE_INSTALL_PREFIX ${psi4_INCLUDE_DIR} DIRECTORY)
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${psi4_CMAKE_INSTALL_PREFIX} CACHE PATH "Install path" FORCE)
endif()
message(STATUS "Plugin install prefix: ${CMAKE_INSTALL_PREFIX}")
if(PYMOD_INSTALL_LIBDIR)
set(PYMOD_INSTALL_FULLDIR "${CMAKE_INSTALL_LIBDIR}${PYMOD_INSTALL_LIBDIR}/${PN}")
else()
file(RELATIVE_PATH _tmp ${psi4_CMAKE_INSTALL_PREFIX} ${psi4_LIBRARY})
# e.g., _tmp = lib/psi4/core.so
get_filename_component(_tmp2 ${_tmp} DIRECTORY)
get_filename_component(_tmp3 ${_tmp2} DIRECTORY)
set(PYMOD_INSTALL_FULLDIR "${_tmp3}/${PN}")
endif()
message(STATUS "Plugin module install: ${PYMOD_INSTALL_FULLDIR}")
include(custom_static_library)
# <<< Build >>>
if (CMAKE_Fortran_COMPILER_ID MATCHES Intel)
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -heap-arrays")
endif()
add_psi4_plugin(v2rdm_casscf
backtransform_tpdm.cc
basis.cc
cg_solver.cc
checkpoint.cc
d2.cc
d3.cc
d4.cc
diis.cc
exponentiate_step.cc
extended_koopmans.cc
fcidump.cc
g2.cc
gpu_transform_3index_teint.cc
integraltransform_sort_so_tpdm.cc
integraltransform_tpdm_unrestricted.cc
natural_orbitals.cc
oei.cc
orbital_lagrangian.cc
plugin.cc
python_api.cc
q2.cc
sortintegrals.cc
spin.cc
t1.cc
t2.cc
tei.cc
threeindexintegrals.cc
transform_ints.cc
update_primal.cc
update_transformation_matrix.cc
v2rdm_helper.cc
v2rdm_solver.cc
write_3pdm.cc
write_tpdm.cc
write_opdm.cc
write_tpdm_iwl.cc
focas_data.F90
focas_diis.F90
focas_driver.F90
focas_energy.F90
focas_exponential.F90
focas_genfock.F90
focas_gradient.F90
focas_gradient_hessian.F90
focas_hessian.F90
focas_interface.F90
focas_redundant.F90
focas_semicanonical.F90
focas_transform_driver.F90
focas_transform_oeints.F90
focas_transform_teints.F90
)
#==================================================================
if(${ENABLE_OPENRDM})
string(COMPARE EQUAL "${openrdm_DIR}" "" _bool_result)
if(${_bool_result})
message(FATAL_ERROR "${Red}Please set the \"openrdm_DIR\" variable to .../build/stage/share/cmake/openrdm${ColourReset}")
else()
# set(openrdm_DIR "/home/sina/MOLSSI/RDMInoles-Prototype/build/stage/share/cmake/openrdm")
find_package(openrdm 0.2.0 CONFIG REQUIRED)
if(openrdm_FOUND)
message(STATUS "${Cyan}OpenRDM (${openrdm_VERSION}) is found in${ColourReset}: ${openrdm_DIR}")
endif()
target_link_libraries(${PROJECT_NAME} PRIVATE openrdm::openrdm)
endif()
endif()
#==================================================================
target_link_libraries(v2rdm_casscf PRIVATE ${LIBC_INTERJECT})
configure_file(__init__.py.in __init__.py @ONLY)
# <<< Install >>>
install(TARGETS v2rdm_casscf
EXPORT "${PN}Targets"
LIBRARY DESTINATION ${PYMOD_INSTALL_FULLDIR})
install(FILES extras.py pymodule.py LICENSE README.md
${CMAKE_CURRENT_BINARY_DIR}/__init__.py
DESTINATION ${PYMOD_INSTALL_FULLDIR})
install(DIRECTORY tests/
DESTINATION ${PYMOD_INSTALL_FULLDIR}/tests
FILES_MATCHING PATTERN "v2rdm*/input.dat"
PATTERN "*.py"
PATTERN "old-tests" EXCLUDE)
# <<< Export Config >>>
# GNUInstallDirs "DATADIR" wrong here; CMake search path wants "share".
set(CMAKECONFIG_INSTALL_DIR "share/cmake/${PN}")
configure_package_config_file(cmake/${PN}Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PN}Config.cmake"
INSTALL_DESTINATION ${CMAKECONFIG_INSTALL_DIR})
write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PN}ConfigVersion.cmake
VERSION ${${PN}_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PN}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PN}ConfigVersion.cmake
DESTINATION ${CMAKECONFIG_INSTALL_DIR})
install(EXPORT "${PN}Targets"
NAMESPACE "${PN}::"
DESTINATION ${CMAKECONFIG_INSTALL_DIR})