-
Notifications
You must be signed in to change notification settings - Fork 54
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
143 lines (105 loc) · 3.83 KB
/
CMakeLists.txt
File metadata and controls
143 lines (105 loc) · 3.83 KB
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
# Set the compiler as described here: https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F
#
# Verify that Cmake is up to date
#
CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
set (CMAKE_CXX_STANDARD 14)
#SET(CMAKE_LEGACY_CYGWIN_WIN32 0)
#
# Project name
#
project("libra")
#
# User-defined Find modules
#
LIST(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules)
#
# Try using the PCH - it will only work if you have the right version of cmake
#
option(USING_PCH "Build using pre-compiled header support" ON)
option(WITH_OPENMP "Use OpenMP for parallelization" ON)
#
# OpenMP
#
if(WITH_OPENMP)
find_package(OpenMP REQUIRED)
endif()
#
# Python library
#
MESSAGE(STATUS "Looking for Python libraries...")
#FIND_PACKAGE(Python3 3.6 REQUIRED COMPONENTS Interpreter Development)
FIND_PACKAGE(Python3 3.6 REQUIRED COMPONENTS Development)
#IF(Python3_FOUND)
# MESSAGE("Success!")
# INCLUDE_DIRECTORIES("${PYTHON_INCLUDE_DIRS}")
IF(NOT Python3_FOUND)
MESSAGE(STATUS "Unable to find correct Python version. If your Python include/libraries are installed in a non-standard location")
MESSAGE(STATUS "Try using -DPython3_ROOT_DIR=\${path_to_the_python_root_dir}")
MESSAGE(FATAL_ERROR)
ENDIF()
MESSAGE(STATUS "Found Python libraries directory: ${Python3_LIBRARIES}")
MESSAGE(STATUS "Found Python include directory: ${Python3_INCLUDE_DIRS}")
SET(LIBRA_Python3_VERSION "${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
#
# Boost library
#
MESSAGE(STATUS "Looking for Boost libraries...")
SET(Boost_NO_BOOST_CMAKE TRUE) # to fix the problem of finding python37 libs
SET(Boost_USE_STATIC_LIBS=OFF)
SET(Boost_USE_MULTITHREADED=OFF)
SET(Boost_USE_STATIC_RUNTIME=OFF)
FIND_PACKAGE(Boost 1.74.0 REQUIRED COMPONENTS regex python${LIBRA_Python3_VERSION})
IF(Boost_FOUND)
INCLUDE_DIRECTORIES("${Boost_INCLUDE_DIRS}")
ENDIF()
MESSAGE(STATUS "Found Boost libraries directory: ${Boost_LIBRARIES}")
MESSAGE(STATUS "Found Boost include directory: ${Boost_INCLUDE_DIRS}")
MESSAGE(STATUS "Looking for Eigen3 library...")
FIND_PACKAGE(Eigen3)
IF(EIGEN3_FOUND)
INCLUDE_DIRECTORIES("${EIGEN3_INCLUDE_DIR}")
SET(EIGEN3_INCLUDE_DIRS "${EIGEN3_INCLUDE_DIR}")
MESSAGE(STATUS "Found Eigen3 include directory: ${EIGEN3_INCLUDE_DIR}")
ELSEIF(NOT EIGEN3_FOUND)
MESSAGE(FATAL_ERROR "Unable to find Eigen3")
ENDIF()
MESSAGE(STATUS "Looking for libint2 libraries...")
FIND_PACKAGE(Libint2 CONFIG 2.7.1 REQUIRED COMPONENTS shared gss impure_sh onebody_d0_l6 g12_d0_l4 g12_d1_l4 eri_c4_d0_l5 eri_c4_d1_l4) #gss e5 g5)
if(Libint2_FOUND)
MESSAGE(STATUS "Found libint2 include directory: ${LIBINT2_INCLUDE_DIRS}")
INCLUDE_DIRECTORIES(Libint2::int2 Libint2::cxx Libint2::int2-cxx Libint2::impure_sh Libint2::gss Libint2::onebody_d0_l6 Libint::g12_d0_l4 Libint2::g12_d1_l4 Libint2::shared Libint2::cxx_ho Libint2::c Libint2::eri_c4_d0_l5 Libint2::eri_c4_d1_l4)
endif()
#
# GNU compiler definitions
#
IF(CMAKE_COMPILER_IS_GNUCXX)
# For Linux
ADD_DEFINITIONS("-Wall -Wl,-z,defs")
# For Cygwin
# ADD_DEFINITIONS("-Wall -DCYGWIN")
ELSE()
MESSAGE(FATAL_ERROR "CMakeLists.txt has not been tested/written for your compiler.")
ENDIF()
#
# Cmake configuration
#
MESSAGE(STATUS "Setting up the CMake configuration...")
IF(NOT CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "RELEASE")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
ENDIF()
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
#
# Set the libraries
#
if(NOT WITH_OPENMP)
SET(ext_libs Boost::regex Boost::python${LIBRA_Python3_VERSION} Python3::Python)
else()
SET(ext_libs Boost::regex Boost::python${LIBRA_Python3_VERSION} Python3::Python OpenMP::OpenMP_C OpenMP::OpenMP_CXX)
endif()
#
# Now building the project
#
MESSAGE("Going into subdirectory src...")
ADD_SUBDIRECTORY("src")