|
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}) |
28 | 12 | endif() |
| 13 | +endif() |
29 | 14 |
|
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}) |
33 | 27 |
|
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) |
36 | 31 | 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