Skip to content

Commit

Permalink
Fix python bindings and related bindings cleanup (#985)
Browse files Browse the repository at this point in the history
  • Loading branch information
traversaro authored Sep 23, 2024
1 parent 5ecb107 commit 75f2c94
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 34 deletions.
39 changes: 21 additions & 18 deletions bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,17 @@
# Authors: Paul Fitzpatrick
# CopyPolicy: Released under the terms of the GNU GPL v2.0.

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR})
# Detect if we are doing a standalone build of the bindings, using an external icub-main
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(ICUB_BINDINGS_BUILD_STANDALONE TRUE)
else()
set(ICUB_BINDINGS_BUILD_STANDALONE FALSE)
endif()

if(ICUB_BINDINGS_BUILD_STANDALONE)
cmake_minimum_required(VERSION 3.16)
project(ICUBBindings)
endif()

# Find YARP for bindings-only builds
find_package(YARP COMPONENTS conf os sig dev math gsl REQUIRED)
Expand All @@ -11,26 +21,16 @@ foreach(_component conf os sig dev math gsl)
include_directories(${YARP_${_component}_INCLUDE_DIRS})
endforeach()

# Work-around for missing paths to OpenCV libraries
find_package(OpenCV)
if(OpenCV_FOUND)
link_directories(${OpenCV_LINK_DIRECTORIES} ${OPENCV_LINK_DIRECTORIES})
# Find ICUB for bindings-only builds
if(ICUB_BINDINGS_BUILD_STANDALONE)
find_package(ICUB REQUIRED)
endif()

set(ICUB_SWIG_LIBRARIES ctrlLib
iDyn
iKin
skinDynLib
optimization)

#TODO this has to been removed as soon as swig fully support target_include_directories
include_directories(${CMAKE_SOURCE_DIR}/src/libraries/iDyn/include)
include_directories(${CMAKE_SOURCE_DIR}/src/libraries/iKin/include)
include_directories(${CMAKE_SOURCE_DIR}/src/libraries/ctrlLib/include)
include_directories(${CMAKE_SOURCE_DIR}/src/libraries/skinDynLib/include)
include_directories(${CMAKE_SOURCE_DIR}/src/libraries/optimization/include)


# for yarp.i
include_directories(${YARP_BINDINGS})

Expand Down Expand Up @@ -58,7 +58,7 @@ if(CREATE_PYTHON)
LANGUAGE python
SOURCES icub.i)
target_link_libraries(${SWIG_MODULE_icub_python_REAL_NAME} Python::Python ${ICUB_SWIG_LIBRARIES})
set_target_properties(${SWIG_MODULE_icub_python_REAL_NAME} PROPERTIES OUTPUT_NAME "_icub")
set_target_properties(${SWIG_MODULE_icub_python_REAL_NAME} PROPERTIES SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)

# installation path is determined reliably on most platforms using distutils
execute_process(COMMAND ${Python_EXECUTABLE} -c "from distutils import sysconfig; print(sysconfig.get_python_lib(1,0,prefix=''))"
Expand Down Expand Up @@ -102,7 +102,9 @@ if(CREATE_RUBY)
target_link_libraries(${SWIG_MODULE_icub_ruby_REAL_NAME} ${RUBY_LIBRARY} ${ICUB_SWIG_LIBRARIES})
target_include_directories(${SWIG_MODULE_icub_ruby_REAL_NAME} SYSTEM PRIVATE ${RUBY_INCLUDE_PATH})
set_target_properties(${SWIG_MODULE_icub_ruby_REAL_NAME} PROPERTIES OUTPUT_NAME "icub"
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/ruby")
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/ruby"
SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)

endif()

if(CREATE_JAVA)
Expand All @@ -120,6 +122,7 @@ if(CREATE_JAVA)
if(APPLE)
set_target_properties(${SWIG_MODULE_icub_java_REAL_NAME} PROPERTIES SUFFIX ".jnilib")
endif(APPLE)
set_target_properties(${SWIG_MODULE_icub_python_REAL_NAME} PROPERTIES SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
endif()

if(CREATE_CSHARP)
Expand All @@ -129,7 +132,7 @@ if(CREATE_CSHARP)
SOURCES icub.i)

target_link_libraries(${SWIG_MODULE_icub_csharp_REAL_NAME} ${SWIG_ICUB_LIBRARIES})
set_target_properties(${SWIG_MODULE_icub_csharp_REAL_NAME} PROPERTIES OUTPUT_NAME "icub" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/csharp")
set_target_properties(${SWIG_MODULE_icub_csharp_REAL_NAME} PROPERTIES OUTPUT_NAME "icub" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/csharp" SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
endif()

if(CREATE_LUA)
Expand All @@ -140,5 +143,5 @@ if(CREATE_LUA)
LANGUAGE lua
SOURCES icub.i)
target_link_libraries(${SWIG_MODULE_icub_lua_REAL_NAME} ${LUA_LIBRARY} ${ICUB_SWIG_LIBRARIES})
set_target_properties(${SWIG_MODULE_icub_lua_REAL_NAME} PROPERTIES OUTPUT_NAME "icub" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/lua")
set_target_properties(${SWIG_MODULE_icub_lua_REAL_NAME} PROPERTIES OUTPUT_NAME "icub" LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/lua" SWIG_USE_TARGET_INCLUDE_DIRECTORIES TRUE)
endif()
16 changes: 0 additions & 16 deletions bindings/icub.i
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,6 @@ using namespace yarp::sig;
#include <iCub/optimization/matrixTransformation.h>
#include <iCub/optimization/neuralNetworks.h>

// iDyn
//#include <iCub/iDyn/iDynInv.h>
//#include <iCub/iDyn/iDyn.h>
//#include <iCub/iDyn/iDynContact.h>
//#include <iCub/iDyn/iDynTransform.h>
//#include <iCub/iDyn/iDynBody.h>

%}

%include <std_vector.i>
Expand Down Expand Up @@ -133,15 +126,6 @@ using namespace yarp::sig;
%include <iCub/optimization/neuralNetworks.h>


// iDyn
//%include <iCub/iDyn/iDynInv.h>

//%ignore notImplemented;
//%include <iCub/iDyn/iDyn.h>
//%include <iCub/iDyn/iDynContact.h>
//%include <iCub/iDyn/iDynTransform.h>
//%include <iCub/iDyn/iDynBody.h>

%{
typedef yarp::os::TypedReader<iCub::skinDynLib::skinContactList> TypedReaderSkinContactList;
typedef yarp::os::TypedReaderCallback<iCub::skinDynLib::skinContactList> TypedReaderCallbackSkinContactList;
Expand Down

0 comments on commit 75f2c94

Please sign in to comment.