-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
57 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
*/build | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
nanobind | ||
GIT_REPOSITORY https://github.com/wjakob/nanobind.git | ||
GIT_TAG b0e24d5b0ab0d518317d6b263a257ae72d4d29a2 # v1.5.2 | ||
) | ||
list(APPEND FetchContents nanobind) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
nanobind_add_module(nanobind_cxxmod add.hpp cxxmod.cpp) | ||
set_target_properties(nanobind_cxxmod PROPERTIES OUTPUT_NAME cxxmod CXX_STANDARD 17) | ||
|
||
configure_file(pytest.py.in pytest.py @ONLY) | ||
add_test(NAME nanobind_pytest COMMAND ${Python_EXECUTABLE} pytest.py) | ||
|
||
add_executable(nanobind_cxxtest cxxtest.cpp) | ||
set_target_properties(nanobind_cxxtest PROPERTIES OUTPUT_NAME cxxtest) | ||
add_test(NAME nanobind_cxxtest COMMAND cxxtest) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#ifndef ADD_HPP | ||
#define ADD_HPP | ||
|
||
inline int add(int i, int j) { | ||
return i + j; | ||
} | ||
|
||
#endif // ADD_HPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#include <nanobind/nanobind.h> | ||
#include "add.hpp" | ||
|
||
NB_MODULE(cxxmod, m) { | ||
m.doc() = "nanobind example plugin"; | ||
m.def("add", &add, "Add two numbers"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <iostream> | ||
#include "add.hpp" | ||
|
||
int main() { | ||
std::cout << "add(1,2) = " << add(1,2) << std::endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!@Python_EXECUTABLE@ | ||
import cxxmod | ||
print('add(1,2) = {}'.format(cxxmod.add(1,2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#!@PYTHON_EXECUTABLE@ | ||
#!@Python_EXECUTABLE@ | ||
import cxxmod | ||
print('add(1,2) = {}'.format(cxxmod.add(1,2))) |