-
Notifications
You must be signed in to change notification settings - Fork 18
/
CMakeLists.txt
144 lines (121 loc) · 4.84 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
cmake_minimum_required(VERSION 3.12)
project(qforte)
# Specify the required C++ standard
set (CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# optionally use OpenMP, if so use OpenMP compatible compiler
OPTION(USE_OpenMP "Use OpenMP to enamble <omp.h>" OFF)
OPTION(CODE_COVERAGE "Enable compilation with code coverage flags" OFF)
# Add profiling flags for clang
if(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message("-- Enabling code coverage for Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message("-- Enabling code coverage for GCC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -g -O0")
endif()
# # Add required flags (GCC & LLVM/Clang)
# target_compile_options(qforte
# -O0 # no optimization
# -g # generate debug info
# --coverage # sets all required flags
# )
# if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.13)
# target_link_options(qforte --coverage)
# else()
# target_link_libraries(qforte --coverage)
# endif()
endif(CODE_COVERAGE AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
#if(ENABLE_CODECOV)
# message("-- Enabling code coverage")
# if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# message("-- Enabling code coverage for Clang")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-instr-generate -fcoverage-mapping")
# endif()
#
# if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# message("-- Enabling code coverage for GCC")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
# endif()
#endif()
# if(USE_OpenMP)
# set(CMAKE_C_COMPILER "/usr/local/Cellar/llvm/10.0.1/bin/clang")
# set(CMAKE_CXX_COMPILER "/usr/local/Cellar/llvm/10.0.1/bin/clang++")
# set(OPENMP_LIBRARIES "/usr/local/Cellar/llvm/10.0.1/lib")
# set(OPENMP_INCLUDES "/usr/local/Cellar/llvm/10.0.1/include")
# # if(CMAKE_C_COMPILER_ID MATCHES "Clang")
# # set(OpenMP_C "${CMAKE_C_COMPILER}")
# # set(OpenMP_C_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
# # set(OpenMP_C_LIB_NAMES "libomp" "libgomp" "libiomp5")
# # set(OpenMP_libomp_LIBRARY ${OpenMP_C_LIB_NAMES})
# # set(OpenMP_libgomp_LIBRARY ${OpenMP_C_LIB_NAMES})
# # set(OpenMP_libiomp5_LIBRARY ${OpenMP_C_LIB_NAMES})
# # endif()
# # if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# # set(OpenMP_CXX "${CMAKE_CXX_COMPILER}")
# # set(OpenMP_CXX_FLAGS "-fopenmp=libomp -Wno-unused-command-line-argument")
# # set(OpenMP_CXX_LIB_NAMES "libomp" "libgomp" "libiomp5")
# # set(OpenMP_libomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
# # set(OpenMP_libgomp_LIBRARY ${OpenMP_CXX_LIB_NAMES})
# # set(OpenMP_libiomp5_LIBRARY ${OpenMP_CXX_LIB_NAMES})
# # endif()
# endif()
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /std:c++17")
#set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Set source directory
set(SOURCE_DIR "src/qforte")
# Tell CMake that headers are also in SOURCE_DIR
include_directories(${SOURCE_DIR})
# Generate Python module
find_package(pybind11 CONFIG REQUIRED)
add_subdirectory(lib/fmt)
pybind11_add_module(qforte ${SOURCES} "${SOURCE_DIR}/bindings.cc"
"${SOURCE_DIR}/helpers.cc"
"${SOURCE_DIR}/find_irrep.cc"
"${SOURCE_DIR}/make_gate.cc"
"${SOURCE_DIR}/qubit_basis.cc"
"${SOURCE_DIR}/circuit.cc"
"${SOURCE_DIR}/computer.cc"
"${SOURCE_DIR}/gate.cc"
"${SOURCE_DIR}/qubit_operator.cc"
"${SOURCE_DIR}/qubit_op_pool.cc"
"${SOURCE_DIR}/sq_operator.cc"
"${SOURCE_DIR}/sq_op_pool.cc"
"${SOURCE_DIR}/sparse_tensor.cc"
"${SOURCE_DIR}/timer.cc")
target_link_libraries(qforte PRIVATE fmt-header-only)
# specify open MP flags
if(USE_OpenMP)
find_package(OpenMP REQUIRED)
if(OpenMP_CXX_FOUND)
target_link_libraries(qforte PUBLIC OpenMP::OpenMP_CXX)
endif()
endif(USE_OpenMP)
SET(TEST_DIR "tests")
SET(TESTS ${SOURCES}
"${TEST_DIR}/test_main.cc"
"${TEST_DIR}/test_math.cc")
# Generate a test executable
include_directories(lib/catch2/single_include/catch2)
include_directories(lib/fmt/include)
add_executable("${PROJECT_NAME}_test" ${TESTS})
#include_directories(${SOURCE_DIR})
#include_directories(lib/catch2/single_include/catch2)
include_directories(lib/fmt/include)
add_executable("${PROJECT_NAME}_benchmarks"
benchmarks/benchmarks.cc
"${SOURCE_DIR}/helpers.cc"
"${SOURCE_DIR}/find_irrep.cc"
"${SOURCE_DIR}/make_gate.cc"
"${SOURCE_DIR}/qubit_basis.cc"
"${SOURCE_DIR}/circuit.cc"
"${SOURCE_DIR}/computer.cc"
"${SOURCE_DIR}/gate.cc"
"${SOURCE_DIR}/qubit_operator.cc"
"${SOURCE_DIR}/qubit_op_pool.cc"
"${SOURCE_DIR}/sparse_tensor.cc"
"${SOURCE_DIR}/timer.cc")
target_link_libraries(qforte_benchmarks PRIVATE fmt-header-only)