-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
160 lines (134 loc) · 4.55 KB
/
CMakeLists.txt
File metadata and controls
160 lines (134 loc) · 4.55 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
# 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(parallelzone_version "${CMAKE_CURRENT_LIST_DIR}")
project(parallelzone VERSION "${parallelzone_version}" LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
include(get_cmaize)
include(nwx_find_package)
# Work out the project paths
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 the tests?"
BUILD_PYBIND11_PYBINDINGS ON "Should we build pybind11 python bindings?"
BUILD_CPP_JOULES OFF "Enable energy usage tracking with CPP Joules library?"
BUILD_CUDA_BINDINGS OFF "Enable CUDA Bindings"
BUILD_HIP_BINDINGS OFF "Enable HIP Bindings"
BUILD_SYCL_BINDINGS OFF "Enable SYCL Bindings"
BUILD_PAPI_BINDINGS OFF "Enable PAPI Bindings"
)
if (BUILD_CUDA_BINDING OR BUILD_HIP_BINDINGS OR BUILD_SYCL_BINDING)
include(build_device)
endif()
### Dependendencies ###
nwx_find_package(
MPI
REQUIRED
TARGETS
mpi "MPI::MPI_CXX"
)
set(project_depends mpi)
cmaize_find_or_build_dependency(
spdlog
URL github.com/gabime/spdlog
VERSION v1.16.0
BUILD_TARGET spdlog
FIND_TARGET spdlog::spdlog
CMAKE_ARGS SPDLOG_INSTALL=ON
)
list(APPEND project_depends spdlog)
# PAPI bindings are enabled, leading to building PAPI with CUDA or ROCm support
if("${BUILD_PAPI_BINDINGS}")
include(build_papi)
endif ()
if("${BUILD_CPP_JOULES}")
cmaize_find_or_build_dependency(
cpp_joules
BUILD_CPP_JOULES
URL github.com/rishalab/CPPJoules
VERSION main
BUILD_TARGET CPP_Joules
FIND_TARGET CPP_Joules::CPP_Joules
)
list(APPEND project_depends cpp_joules)
endif()
cmaize_find_or_build_dependency(
cereal
URL github.com/USCiLab/cereal
VERSION v1.3.2
BUILD_TARGET cereal
FIND_TARGET cereal::cereal
CMAKE_ARGS JUST_INSTALL_CEREAL=ON
)
list(APPEND project_depends cereal)
cmaize_add_library(
${PROJECT_NAME}
SOURCE_DIR "${project_src_dir}"
INCLUDE_DIRS "${project_inc_dir}"
DEPENDS "${project_depends}"
)
if("${BUILD_CPP_JOULES}")
target_compile_definitions("${PROJECT_NAME}" PRIVATE BUILD_CPP_JOULES)
endif()
# N.B. this is a no-op if BUILD_PYBIND11_PYBINDINGS is not turned on
include(nwx_pybind11)
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(PYTHON_TEST_DIR "${CMAKE_CURRENT_LIST_DIR}/tests/python")
include(get_catch2)
cmaize_add_tests(
test_unit_parallelzone
SOURCE_DIR "${CXX_TEST_DIR}/unit_tests"
INCLUDE_DIRS "${project_src_dir}"
DEPENDS Catch2::Catch2 ${PROJECT_NAME}
)
cmaize_add_tests(
test_parallelzone_docs
SOURCE_DIR "${CXX_TEST_DIR}/doc_snippets"
INCLUDE_DIRS "${project_src_dir}"
DEPENDS Catch2::Catch2 ${PROJECT_NAME}
)
# N.B. these are no-ops if BUILD_PYBIND11_PYBINDINGS is not turned on
nwx_pybind11_tests(
py_parallelzone "${PYTHON_TEST_DIR}/unit_tests/test_parallelzone.py"
)
nwx_pybind11_tests(
py_doc_snippets "${PYTHON_TEST_DIR}/doc_snippets/test_doc_snippets.py"
)
add_test(
NAME "test_pz_under_mpi"
COMMAND "${MPIEXEC_EXECUTABLE}" "${MPIEXEC_NUMPROC_FLAG}" "2"
"${CMAKE_BINARY_DIR}/test_unit_parallelzone"
)
add_test(
NAME "test_pz_docs_under_mpi"
COMMAND "${MPIEXEC_EXECUTABLE}" "${MPIEXEC_NUMPROC_FLAG}" "2"
"${CMAKE_BINARY_DIR}/test_parallelzone_docs"
)
endif()
cmaize_add_package(${PROJECT_NAME} NAMESPACE nwx::)