Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: update to pybind11 2.6.0 #13

Merged
merged 4 commits into from
Nov 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 29 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.4)
project(pybind11_catkin)

find_package(catkin REQUIRED)
include(ExternalProject)

ExternalProject_Add(pybind11_src
# URL "https://github.com/pybind/pybind11/archive/master.zip" # broken as of July 31, 2020
URL "https://github.com/pybind/pybind11/archive/v2.5.0.zip"
URL "https://github.com/pybind/pybind11/archive/v2.6.0.zip"
UPDATE_COMMAND ""
CMAKE_ARGS -DPYBIND11_PYTHON_VERSION=${PYTHON_VERSION_STRING}
-DPYBIND11_TEST:BOOL=OFF -DPYBIND11_INSTALL:BOOL=ON
-DCMAKE_INSTALL_PREFIX:PATH=${PROJECT_BINARY_DIR}/install
CMAKE_ARGS -DPYBIND11_NOPYTHON=TRUE
-DPYBIND11_TEST=OFF
-DPYBIND11_INSTALL=ON
-DCMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}/install
-DCMAKE_INSTALL_INCLUDEDIR=${CATKIN_DEVEL_PREFIX}/include/${PROJECT_NAME}
)
# We need to copy the entire content of the cmake/pybind11 folder to the correct place but with a different structure:
ExternalProject_Add_Step(pybind11_src CopyToDevel
COMMENT "Copying to devel"
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/install/share/cmake/pybind11/pybind11Tools.cmake ${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake
COMMAND ${CMAKE_COMMAND} -E copy ${PROJECT_BINARY_DIR}/install/share/cmake/pybind11/FindPythonLibsNew.cmake ${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_BINARY_DIR}/install/include/pybind11/ ${CATKIN_DEVEL_PREFIX}/include/${PROJECT_NAME}/pybind11/
COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_BINARY_DIR}/install/share/cmake/pybind11/ ${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake
DEPENDEES install
)

Expand All @@ -30,9 +30,26 @@ install(
DIRECTORY ${CATKIN_DEVEL_PREFIX}/include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
)

# We glob the entire _original_ pybind11 cmake directory since there would be a few
# files in the devel-share directory which we do *not* want to copy as they will be
# regenerated in the install space:
# - pybind11_catkin.cmake
# - pybind11_catkinConfig-version.cmake
# - pybind11_catkinConfig.cmake
# file(GLOB PYBIND11_CMAKE_FILES ${PROJECT_BINARY_DIR}/install/share/cmake/pybind11/*.cmake)

set(PYBIND11_CMAKE_FILES
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/FindPythonLibsNew.cmake
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/pybind11Config.cmake
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/pybind11ConfigVersion.cmake
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/pybind11NewTools.cmake
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/pybind11Targets.cmake
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/pybind11Common.cmake
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/pybind11Tools.cmake
)

install(
FILES
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/FindPythonLibsNew.cmake
${CATKIN_DEVEL_PREFIX}/share/${PROJECT_NAME}/cmake/pybind11Tools.cmake
FILES ${PYBIND11_CMAKE_FILES}
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/cmake
)
4 changes: 3 additions & 1 deletion cmake/pybind11_catkin.cmake.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0.2)
cmake_minimum_required(VERSION 3.4)

# As of July 31, 2020 pybind11 upgraded to CMake version 3.8 (effectively dropping 16.04).
# To be able to configure, we need to set CMP0069 (interprocedural optimization) to NEW
Expand All @@ -8,6 +8,8 @@ cmake_minimum_required(VERSION 3.0.2)
# This finds python includes and libs and defines pybind11_add_module()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}")
set(PYBIND11_PYTHON_VERSION ${PYTHON_VERSION_STRING})
include(pybind11Config)
include(pybind11Common)
include(pybind11Tools)

# set variables used by pybind11_add_module()
Expand Down