Skip to content

Commit

Permalink
Create idyntree-pybind11 library
Browse files Browse the repository at this point in the history
  • Loading branch information
GiulioRomualdi committed Nov 25, 2021
1 parent b3df484 commit 52f51c4
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ if(NOT IDYNTREE_ONLY_DOCS)
list(APPEND _IDYNTREE_EXPORTED_DEPENDENCIES_ONLY_STATIC assimp)
endif()

add_subdirectory(bindings)

include(InstallBasicPackageFiles)
install_basic_package_files(iDynTree VARS_PREFIX ${VARS_PREFIX}
VERSION ${${VARS_PREFIX}_VERSION}
Expand All @@ -78,8 +80,6 @@ if(NOT IDYNTREE_ONLY_DOCS)
PRIVATE_DEPENDENCIES ${_IDYNTREE_EXPORTED_DEPENDENCIES_ONLY_STATIC})

include(AddUninstallTarget)

add_subdirectory(bindings)
endif()

# add a dox target to generate doxygen documentation
Expand Down
28 changes: 26 additions & 2 deletions bindings/pybind11/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
set(libraryname idyntree-pybind11)

add_library(${libraryname} INTERFACE)
target_link_libraries(${libraryname} INTERFACE idyntree-core)

# Specify include directories for both compilation and installation process.
# The $<INSTALL_PREFIX> generator expression is useful to ensure to create
# relocatable configuration files, see https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html
# creating-relocatable-packages
target_include_directories(${libraryname} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"<INSTALL_INTERFACE:<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}>")

# Specify installation targets, typology and destination folders.
install(TARGETS ${libraryname}
EXPORT ${PROJECT_NAME})

install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/include/iDynTree/pybind11/VectorCasters.h"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/iDynTree/pybind11")

add_library(iDynTree::${libraryname} ALIAS ${libraryname})
set_property(GLOBAL APPEND PROPERTY ${VARS_PREFIX}_TARGETS ${libraryname})

pybind11_add_module(pybind11_idyntree SYSTEM idyntree.cpp
error_utilities.h error_utilities.cpp
idyntree_core.h idyntree_core.cpp
error_utilities.h error_utilities.cpp
idyntree_model.h idyntree_model.cpp
idyntree_sensors.h idyntree_sensors.cpp
idyntree_modelio_urdf.h idyntree_modelio_urdf.cpp
idyntree_vector_casters.h)
)

target_link_libraries(pybind11_idyntree PUBLIC idyntree-core
idyntree-model
idyntree-sensors
idyntree-modelio)
idyntree-modelio
iDynTree::idyntree-pybind11)

# The generated Python dynamic module must have the same name as the pybind11
# module, i.e. `bindings`.
Expand Down
2 changes: 1 addition & 1 deletion bindings/pybind11/idyntree_core.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "idyntree_core.h"
#include "idyntree_vector_casters.h"

#include <iDynTree/pybind11/VectorCasters.h>
#include <iDynTree/Core/Axis.h>
#include <iDynTree/Core/Direction.h>
#include <iDynTree/Core/MatrixDynSize.h>
Expand Down
2 changes: 1 addition & 1 deletion bindings/pybind11/idyntree_model.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "idyntree_model.h"
#include "idyntree_vector_casters.h"
#include <iDynTree/pybind11/VectorCasters.h>

#include "error_utilities.h"

Expand Down
3 changes: 2 additions & 1 deletion bindings/pybind11/idyntree_modelio_urdf.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <iDynTree/pybind11/VectorCasters.h>

#include "idyntree_modelio_urdf.h"
#include "idyntree_vector_casters.h"

#include "error_utilities.h"

Expand Down
2 changes: 1 addition & 1 deletion bindings/pybind11/idyntree_sensors.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#include "idyntree_vector_casters.h"
#include <iDynTree/pybind11/VectorCasters.h>
#include "idyntree_sensors.h"
#include "error_utilities.h"

Expand Down
File renamed without changes.

0 comments on commit 52f51c4

Please sign in to comment.