Skip to content

Commit 9e8f4d2

Browse files
dopplershiftdcamron
authored andcommitted
WIP: Add stub module that uses pybind11
1 parent f4b9347 commit 9e8f4d2

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.15...3.26)
2+
project(
3+
"${SKBUILD_PROJECT_NAME}"
4+
LANGUAGES CXX
5+
VERSION "${SKBUILD_PROJECT_VERSION}")
6+
7+
find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
8+
find_package(pybind11 CONFIG REQUIRED)
9+
10+
pybind11_add_module(_calc_mod MODULE calcmod.cpp)
11+
12+
target_compile_definitions(_calc_mod
13+
PRIVATE VERSION_INFO=${PROJECT_VERSION})
14+
15+
install(TARGETS _calc_mod DESTINATION metpy)

src/calcmod.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#include <pybind11/pybind11.h>
2+
3+
int add(int i, int j) {
4+
return i + j;
5+
}
6+
7+
PYBIND11_MODULE(_calc_mod, m) {
8+
m.doc() = "accelerator module docstring";
9+
m.def("add", &add, "Add two numbers");
10+
}

0 commit comments

Comments
 (0)