-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
193 lines (162 loc) · 5.88 KB
/
CMakeLists.txt
File metadata and controls
193 lines (162 loc) · 5.88 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
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
# Copyright 2022 NWChemEx-Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.14)
# Downloads common CMake modules used throughout NWChemEx
include(cmake/get_nwx_cmake.cmake)
# Sets the version to whatever git thinks it is
include(get_version_from_git)
get_version_from_git(pluginplay_version "${CMAKE_CURRENT_LIST_DIR}")
project(pluginplay VERSION "${pluginplay_version}" LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
include(get_cmaize)
include(nwx_find_package)
# Work out full paths to the project's include/source dirs
set(project_inc_dir "${CMAKE_CURRENT_LIST_DIR}/include/${PROJECT_NAME}")
set(project_src_dir "${CMAKE_CURRENT_LIST_DIR}/src/${PROJECT_NAME}")
# Builds C++ API documentation
include(nwx_cxx_api_docs)
nwx_cxx_api_docs("README.md" "${project_inc_dir}" "${project_src_dir}")
### Options ###
cmaize_option_list(
BUILD_TESTING OFF "Should we build unit tests?"
BUILD_PYBIND11_PYBINDINGS ON "Build Pybind11 Python bindings?"
BUILD_ROCKSDB OFF "Enable RocksDB backend of the cache?"
)
### Dependendencies ###
include(get_utilities)
include(get_parallelzone)
cmaize_find_or_build_dependency(
libfort
URL github.com/seleznevae/libfort
BUILD_TARGET fort
FIND_TARGET libfort::fort
CMAKE_ARGS FORT_ENABLE_TESTING=OFF
)
find_package(Boost REQUIRED)
## Optional Dependencies ##
cmaize_find_optional_dependency(
RocksDB
BUILD_ROCKSDB
URL github.com/facebook/rocksdb
FIND_TARGET RocksDB::rocksdb-shared
)
set(pluginplay_depends utilities parallelzone libfort Boost::boost RocksDB)
# As of 1.0.0 CMaize does not support multiple build or find targets. This will
# be fixed in a future feature release. For now we handle the exposed CMake
# targets separately instead of a CMaize target
include(nwx_pybind11)
if("${BUILD_PYBIND11_PYBINDINGS}")
nwx_find_package(
Python3
# NOTE: Right now only the first component is added to find_dependency()
# so Development is listed first since it provides Python3::Python
COMPONENTS Development Interpreter
REQUIRED
TARGETS
python Python3::Python
)
nwx_find_pybind11()
nwx_find_package(
pybind11
# pybind11 won't be found if it is built in the above nwx_find_pybind11().
# QUIET helps hide the error that would be output and even though
# pybind11 is REQUIRED, we will ignore the error here for now.
QUIET
# REQUIRED
TARGETS
pybind11_headers pybind11::headers
pybind11_embed pybind11::embed
)
list(
APPEND pluginplay_depends
pybind11_headers pybind11_embed python
)
endif()
cmaize_add_library(
${PROJECT_NAME}
SOURCE_DIR "${project_src_dir}"
INCLUDE_DIRS "${project_inc_dir}"
DEPENDS "${pluginplay_depends}"
)
# TODO: Update source to use BUILD_PYBIND11_PYBINDINGS, then goes away when
# CMaize supports mulitple targets
if("${BUILD_PYBIND11_PYBINDINGS}")
target_compile_definitions("${PROJECT_NAME}" PUBLIC BUILD_PYBIND11)
endif()
nwx_add_pybind11_module(
${PROJECT_NAME}
SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/src/python"
DEPENDS "${PROJECT_NAME}"
)
if("${BUILD_TESTING}")
set(cxx_test_dir "${CMAKE_CURRENT_LIST_DIR}/tests/cxx")
set(tests_src_dir "${cxx_test_dir}/unit_tests/${PROJECT_NAME}")
set(regression_test_dir "${cxx_test_dir}/regression_tests")
set(examples_src_dir "${cxx_test_dir}/doc_snippets")
### C++ Testing ###
include(get_catch2)
cmaize_add_tests(
test_unit_${PROJECT_NAME}
SOURCE_DIR ${tests_src_dir}
INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/${PROJECT_NAME}"
DEPENDS Catch2::Catch2 ${PROJECT_NAME}
)
cmaize_add_tests(
test_regression_${PROJECT_NAME}
SOURCE_DIR ${regression_test_dir}
INCLUDE_DIRS "${CMAKE_CURRENT_LIST_DIR}/src/${PROJECT_NAME}"
DEPENDS Catch2::Catch2 ${PROJECT_NAME}
)
cmaize_add_tests(
test_${PROJECT_NAME}_docs
SOURCE_DIR "${cxx_test_dir}/doc_snippets"
INCLUDE_DIRS "${project_src_dir}"
DEPENDS Catch2::Catch2 ${PROJECT_NAME}
)
### Python Tests ###
set(python_test_dir "${CMAKE_CURRENT_LIST_DIR}/tests/python")
# In the python tests we will pass Python into PluginPlay, we will then
# need to know that C++ can handle those Python types. To this end we
# create a series of Python bindings for unit testing this functionality
# which live in the py_test_pluginplay library.
nwx_add_pybind11_module(
py_test_pluginplay
INSTALL OFF
SOURCE_DIR "${python_test_dir}/unit_tests"
INCLUDE_DIRS "${project_inc_dir}"
DEPENDS ${PROJECT_NAME}
)
nwx_pybind11_tests(
py_pluginplay ${python_test_dir}/unit_tests/test_pluginplay.py
SUBMODULES parallelzone
)
cmaize_add_library(
${PROJECT_NAME}_examples
SOURCE_DIR ${examples_src_dir}
INCLUDE_DIRS ${examples_src_dir}
DEPENDS Catch2::Catch2 ${PROJECT_NAME}
)
nwx_add_pybind11_module(
${PROJECT_NAME}_examples
INSTALL OFF
SOURCE_DIR "${python_test_dir}/doc_snippets"
DEPENDS parallelzone ${PROJECT_NAME} ${PROJECT_NAME}_examples
)
nwx_pybind11_tests(
py_${PROJECT_NAME}_docs
"${python_test_dir}/doc_snippets/test_doc_snippets.py"
SUBMODULES parallelzone pluginplay
)
endif()
cmaize_add_package(${PROJECT_NAME} NAMESPACE nwx::)