Skip to content

Commit

Permalink
Merge pull request #13 from henryiii/patch-1
Browse files Browse the repository at this point in the history
WIP: update to pybind11 2.6.0
  • Loading branch information
wxmerkt committed Nov 6, 2020
2 parents 1bfdf9b + 9b73e71 commit b749719
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 13 deletions.
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

0 comments on commit b749719

Please sign in to comment.