Skip to content

Commit 1706ad5

Browse files
nim65sjorisv
authored andcommitted
Tests: fix pybind11
1 parent 068c0a1 commit 1706ad5

File tree

2 files changed

+36
-32
lines changed

2 files changed

+36
-32
lines changed

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
default = self'.packages.pinocchio;
3333
pinocchio = pkgs.python3Packages.pinocchio.overrideAttrs (super: {
3434
propagatedBuildInputs = super.propagatedBuildInputs ++ [ pkgs.example-robot-data ];
35+
nativeCheckInputs = [ pkgs.python3Packages.pybind11 ];
3536
src = pkgs.lib.fileset.toSource {
3637
root = ./.;
3738
fileset = pkgs.lib.fileset.unions [
@@ -78,6 +79,7 @@
7879
pkgs.example-robot-data
7980
self'.packages.libpinocchio
8081
];
82+
nativeCheckInputs = [ pkgs.python3Packages.pybind11 ];
8183
src = pkgs.lib.fileset.toSource {
8284
root = ./.;
8385
fileset = pkgs.lib.fileset.unions [
Lines changed: 34 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
1-
include(FetchContent)
2-
FetchContent_Declare(
3-
pybind11
4-
GIT_REPOSITORY https://github.com/pybind/pybind11
5-
GIT_TAG v3.0.1)
6-
FetchContent_GetProperties(pybind11)
7-
if(NOT pybind11_POPULATED)
8-
FetchContent_Populate(pybind11)
9-
add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR})
10-
11-
# pybind11_add_module(cpp2pybind11 cpp2pybind11.cpp)
12-
#
13-
# BUG: might not work out of the box on OSX with conda:
14-
# https://github.com/pybind/pybind11/issues/3081
15-
if(NOT BUILD_TESTING)
16-
add_library(cpp2pybind11 MODULE EXCLUDE_FROM_ALL cpp2pybind11.cpp)
17-
else()
18-
add_library(cpp2pybind11 MODULE cpp2pybind11.cpp)
19-
endif()
20-
add_dependencies(build_tests cpp2pybind11)
21-
target_link_libraries(cpp2pybind11 PRIVATE pinocchio_pywrap_default pybind11::module
22-
Eigen3::Eigen)
23-
set_target_properties(cpp2pybind11 PROPERTIES PREFIX "" SUFFIX ${PYTHON_EXT_SUFFIX})
24-
25-
if(CMAKE_CXX_STANDARD LESS 14)
26-
message(STATUS "CXX_STANDARD for cpp2pybind11 changed from ${CMAKE_CXX_STANDARD} to 14")
27-
set_target_properties(cpp2pybind11 PROPERTIES CXX_STANDARD 14)
1+
find_package(pybind11 CONFIG QUIET)
2+
if(NOT TARGET pybind11::module)
3+
include(FetchContent)
4+
FetchContent_Declare(
5+
pybind11
6+
GIT_REPOSITORY https://github.com/pybind/pybind11
7+
GIT_TAG v3.0.1)
8+
FetchContent_GetProperties(pybind11)
9+
if(NOT pybind11_POPULATED)
10+
FetchContent_Populate(pybind11)
11+
add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR})
2812
endif()
13+
endif()
2914

30-
if(WIN32)
31-
target_compile_definitions(cpp2pybind11 PRIVATE -DNOMINMAX)
32-
endif(WIN32)
15+
# pybind11_add_module(cpp2pybind11 cpp2pybind11.cpp)
16+
#
17+
# BUG: might not work out of the box on OSX with conda:
18+
# https://github.com/pybind/pybind11/issues/3081
19+
if(NOT BUILD_TESTING)
20+
add_library(cpp2pybind11 MODULE EXCLUDE_FROM_ALL cpp2pybind11.cpp)
21+
else()
22+
add_library(cpp2pybind11 MODULE cpp2pybind11.cpp)
23+
endif()
24+
add_dependencies(build_tests cpp2pybind11)
25+
target_link_libraries(cpp2pybind11 PRIVATE pinocchio_pywrap_default pybind11::module Eigen3::Eigen)
26+
set_target_properties(cpp2pybind11 PROPERTIES PREFIX "" SUFFIX ${PYTHON_EXT_SUFFIX})
3327

34-
add_python_unit_test("test-py-cpp2pybind11" "unittest/python/pybind11/test-cpp2pybind11.py"
35-
"bindings/python" "unittest/python/pybind11")
28+
if(CMAKE_CXX_STANDARD LESS 14)
29+
message(STATUS "CXX_STANDARD for cpp2pybind11 changed from ${CMAKE_CXX_STANDARD} to 14")
30+
set_target_properties(cpp2pybind11 PROPERTIES CXX_STANDARD 14)
3631
endif()
32+
33+
if(WIN32)
34+
target_compile_definitions(cpp2pybind11 PRIVATE -DNOMINMAX)
35+
endif(WIN32)
36+
37+
add_python_unit_test("test-py-cpp2pybind11" "unittest/python/pybind11/test-cpp2pybind11.py"
38+
"bindings/python" "unittest/python/pybind11")

0 commit comments

Comments
 (0)