Commit 6f9d3fdf authored by ggory15's avatar ggory15
Browse files

simplified CMakeLists for binding python

parent 254d97a0
......@@ -189,9 +189,10 @@ ENDFOREACH(header ${HEADERS})
ADD_SUBDIRECTORY(src)
# --- BINDINGS ----------------------------------------------------------------
SET(PYWRAP ${PROJECT_NAME}_pywrap)
ADD_SUBDIRECTORY(bindings)
IF(BUILD_PYTHON_INTERFACE)
SET(PYWRAP ${PROJECT_NAME}_pywrap)
ADD_SUBDIRECTORY(bindings)
ENDIF(BUILD_PYTHON_INTERFACE)
# --- UNIT TESTS ---------------------------------------------------------------
ADD_SUBDIRECTORY(unittest)
......
......@@ -29,10 +29,23 @@ MACRO(SYMLINK_AND_INSTALL_HEADERS HEADERS SUBPATH)
ENDFOREACH(header)
ENDMACRO(SYMLINK_AND_INSTALL_HEADERS HEADERS SUBPATH)
FUNCTION(REMOVE_PATH_FROM_LIST list_name path_name dest_list)
SET(list_name_)
FOREACH(header ${list_name})
STRING(REGEX REPLACE "${path_name}" "" header ${header})
LIST(APPEND list_name_ ${header})
ENDFOREACH(header ${list_name_})
SET(${dest_list} ${list_name_} PARENT_SCOPE)
ENDFUNCTION(REMOVE_PATH_FROM_LIST)
# --- PYTHON TARGET --- #
ADD_CUSTOM_TARGET(python)
SET_TARGET_PROPERTIES(python PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD True)
SET(PYWRAP ${PROJECT_NAME}_pywrap)
SET(PYWRAP ${PYWRAP} PARENT_SCOPE)
# --- DEPENDENCIES --- #
SET(PKG_CONFIG_PYWRAP_REQUIRES "eigenpy >= 1.4.0")
FOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
......@@ -42,54 +55,33 @@ ENDFOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
# --- LIBRARY --- #
SET(${PYWRAP}_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/${PROJECT_NAME})
SET(${PROJECT_NAME}_PYTHON_HEADERS
robots/robot-wrapper.hpp
robots/expose-robots.hpp
constraint/constraint-bound.hpp
constraint/constraint-equality.hpp
constraint/constraint-inequality.hpp
constraint/expose-constraints.hpp
contacts/expose-contact.hpp
contacts/contact.hpp
trajectories/expose-trajectories.hpp
trajectories/trajectory-euclidian.hpp
trajectories/trajectory-se3.hpp
trajectories/trajectory-base.hpp
tasks/expose-tasks.hpp
tasks/task-com-equality.hpp
tasks/task-se3-equality.hpp
tasks/task-joint-posture.hpp
utils/container.hpp
solvers/expose-solvers.hpp
solvers/solver-HQP-eiquadprog.hpp
solvers/HQPData.hpp
solvers/HQPOutput.hpp
formulations/formulation.hpp
formulations/expose-formulations.hpp
)
SET(${PROJECT_NAME}_PYTHON_SOURCES
module.cpp
robots/robot-wrapper.cpp
constraint/constraint-bound.cpp
constraint/constraint-equality.cpp
constraint/constraint-inequality.cpp
contacts/contact.cpp
trajectories/trajectory-euclidian.cpp
trajectories/trajectory-se3.cpp
trajectories/trajectory-base.cpp
tasks/task-com-equality.cpp
tasks/task-se3-equality.cpp
tasks/task-joint-posture.cpp
solvers/solver-HQP-eiquadprog.cpp
solvers/HQPData.cpp
solvers/HQPOutput.cpp
formulations/formulation.cpp
)
FILE(GLOB_RECURSE ${PROJECT_NAME}_PYTHON_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/constraint/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/contacts/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/formulations/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/robots/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/solvers/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/tasks/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/trajectories/*.hpp
${CMAKE_CURRENT_SOURCE_DIR}/utils/*.hpp
)
FILE(GLOB_RECURSE ${PROJECT_NAME}_PYTHON_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/constraint/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/contacts/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/formulations/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/robots/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/solvers/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/tasks/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/trajectories/*.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils/*.cpp
)
REMOVE_PATH_FROM_LIST("${${PROJECT_NAME}_PYTHON_HEADERS}" "${CMAKE_CURRENT_SOURCE_DIR}/" ${PROJECT_NAME}_PYTHON_HEADERS)
REMOVE_PATH_FROM_LIST("${${PROJECT_NAME}_PYTHON_SOURCES}" "${CMAKE_CURRENT_SOURCE_DIR}/" ${PROJECT_NAME}_PYTHON_SOURCES)
LIST(APPEND HEADERS ${${PROJECT_NAME}_PYTHON_HEADERS})
LIST(REMOVE_DUPLICATES HEADERS)
# Headers of the python binding
MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/include/tsid/bindings/python")
......@@ -122,6 +114,10 @@ PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} eigenpy)
TARGET_LINK_LIBRARIES(${PYWRAP} ${PROJECT_NAME})
TARGET_LINK_BOOST_PYTHON(${PYWRAP})
IF(HPP_FCL_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} hpp-fcl)
ENDIF(HPP_FCL_FOUND)
IF(APPLE)
# We need to change the extension for python bindings
SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES SUFFIX ".so")
......@@ -134,7 +130,7 @@ INSTALL(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR})
# --- INSTALL SCRIPTS
SET(PYTHON_FILES
__init__.py
__init__.py
)
FOREACH(python ${PYTHON_FILES})
......@@ -142,37 +138,3 @@ FOREACH(python ${PYTHON_FILES})
"${${PROJECT_NAME}_SOURCE_DIR}/bindings/python/${python}"
DESTINATION ${${PYWRAP}_INSTALL_DIR})
ENDFOREACH(python)
# --- PACKAGING --- #
# Format string
SET(_PKG_CONFIG_PYWRAP_LIBDIR ${${PYWRAP}_INSTALL_DIR})
SET(_PKG_CONFIG_PYWRAP_BINDIR ${${PYWRAP}_INSTALL_DIR})
SET(_PKG_CONFIG_PYWRAP_CONFLICTS)
SET(_PKG_CONFIG_PYWRAP_REQUIRES "${PROJECT_NAME}")
FOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
SET(_PKG_CONFIG_PYWRAP_REQUIRES "${_PKG_CONFIG_PYWRAP_REQUIRES}, ${dep}")
ENDFOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
SET(_PKG_CONFIG_PYWRAP_LIBS "-L\${libdir} -l${PYWRAP}")
IF(APPLE)
SET(_PKG_CONFIG_PYWRAP_LIBS "${_PKG_CONFIG_PYWRAP_LIBS} -Wl,-undefined,dynamic_lookup,${Boost_${UPPERCOMPONENT}_LIBRARY}")
ELSE(APPLE)
SET(_PKG_CONFIG_PYWRAP_LIBS "${_PKG_CONFIG_PYWRAP_LIBS} ${LIBINCL_KW}boost_python")
ENDIF(APPLE)
SET(_PKG_CONFIG_PYWRAP_CFLAGS "-I\${includedir} -I/usr/local/include")
SET(_PKG_CONFIG_PYWRAP_CFLAGS "${_PKG_CONFIG_PYWRAP_CFLAGS} -I${PYTHON_INCLUDE_DIRS}")
FOREACH(cflags ${CFLAGS_DEPENDENCIES})
SET(_PKG_CONFIG_PYWRAP_CFLAGS "${_PKG_CONFIG_PYWRAP_CFLAGS} ${cflags}")
ENDFOREACH(cflags ${CFLAGS_DEPENDENCIES})
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/tsidpy.pc.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/tsidpy.pc")
INSTALL(
FILES "${CMAKE_CURRENT_BINARY_DIR}/tsidpy.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)
prefix=${_PKG_CONFIG_PREFIX}
exec_prefix=${_PKG_CONFIG_EXEC_PREFIX}
libdir=${_PKG_CONFIG_PYWRAP_LIBDIR}
bindir=${_PKG_CONFIG_PYWRAP_BINDIR}
pkglibdir=${_PKG_CONFIG_PKGLIBDIR}
includedir=${_PKG_CONFIG_INCLUDEDIR}
datarootdir=${_PKG_CONFIG_DATAROOTDIR}
pkgdatarootdir=${_PKG_CONFIG_PKGDATAROOTDIR}
docdir=${_PKG_CONFIG_DOCDIR}
doxygendocdir=${_PKG_CONFIG_DOXYGENDOCDIR}
Name: tsidpy
Description: Python bindings of TSID
URL: ${_PKG_CONFIG_URL}
Version: ${_PKG_CONFIG_VERSION}
Requires: ${_PKG_CONFIG_PYWRAP_REQUIRES}
Conflicts: ${_PKG_CONFIG_PYWRAP_CONFLICTS}
Libs: ${_PKG_CONFIG_PYWRAP_LIBS}
Cflags: ${_PKG_CONFIG_PYWRAP_CFLAGS}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment