Unverified Commit 9d0ce6f8 authored by Justin Carpentier's avatar Justin Carpentier Committed by GitHub
Browse files

Merge pull request #828 from jcarpent/topic/python

install Python headers anyway
parents 4a87d8e7 1ffcbf8b
#
# Copyright (c) 2016-2018 CNRS INRIA
# Copyright (c) 2016-2019 CNRS INRIA
#
# This file is part of Pinocchio
# pinocchio is free software: you can redistribute it
......@@ -14,7 +14,7 @@
# pinocchio If not, see
# <http://www.gnu.org/licenses/>.
ADD_SUBDIRECTORY(python)
IF(BUILD_PYTHON_INTERFACE)
ADD_SUBDIRECTORY(python)
SET(PYWRAP ${PYWRAP} PARENT_SCOPE)
ENDIF(BUILD_PYTHON_INTERFACE)
#
# Copyright (c) 2015-2018 CNRS INRIA
# Copyright (c) 2015-2019 CNRS INRIA
# Copyright (c) 2015 Wandercraft, 86 rue de Paris 91400 Orsay, France.
#
......@@ -29,26 +29,28 @@ 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 --- #
# The following quiet finding of Eigen is necessary to retrive
# the include directory when packaging Pinocchio in ROS
find_package(Eigen3 QUIET)
if (EIGEN3_FOUND)
include_directories(${EIGEN3_INCLUDE_DIR})
endif()
SET(PKG_CONFIG_PYWRAP_REQUIRES "eigenpy >= 1.4.4")
FOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
ADD_COMPILE_DEPENDENCY(${dep})
ENDFOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
# --- LIBRARY --- #
SET(${PYWRAP}_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/${PROJECT_NAME})
IF(BUILD_PYTHON_INTERFACE)
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 --- #
# The following quiet finding of Eigen is necessary to retrive
# the include directory when packaging Pinocchio in ROS
find_package(Eigen3 QUIET)
if (EIGEN3_FOUND)
include_directories(${EIGEN3_INCLUDE_DIR})
endif()
SET(PKG_CONFIG_PYWRAP_REQUIRES "eigenpy >= 1.4.4")
FOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
ADD_COMPILE_DEPENDENCY(${dep})
ENDFOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
# --- LIBRARY --- #
SET(${PYWRAP}_INSTALL_DIR ${CMAKE_INSTALL_PREFIX}/${PYTHON_SITELIB}/${PROJECT_NAME})
ENDIF(BUILD_PYTHON_INTERFACE)
FILE(GLOB_RECURSE ${PROJECT_NAME}_PYTHON_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/*.hpp
......@@ -113,105 +115,107 @@ MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
SET(${PYWRAP}_SOURCES ${${PROJECT_NAME}_PYTHON_SOURCES})
SET(${PYWRAP}_HEADERS ${${PROJECT_NAME}_PYTHON_HEADERS})
ADD_LIBRARY(${PYWRAP} SHARED ${${PYWRAP}_SOURCES} ${${PYWRAP}_HEADERS})
ADD_DEPENDENCIES(python ${PYWRAP})
IF(BUILD_WITH_COMMIT_VERSION)
TAG_LIBRARY_VERSION(${PYWRAP})
ENDIF(BUILD_WITH_COMMIT_VERSION)
ADD_HEADER_GROUP(${PYWRAP}_HEADERS)
ADD_SOURCE_GROUP(${PYWRAP}_SOURCES)
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(CPPAD_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} "cppad")
ENDIF(CPPAD_FOUND)
IF(CPPADCG_FOUND)
SET_PROPERTY(TARGET ${PYWRAP} PROPERTY CXX_STANDARD 11)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} "cppadcg")
ENDIF(CPPADCG_FOUND)
IF(APPLE)
# We need to change the extension for python bindings
SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES SUFFIX ".so")
ENDIF(APPLE)
SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
INSTALL(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR})
# --- INSTALL SCRIPTS
SET(PYTHON_FILES
__init__.py
deprecated.py
deprecation.py
utils.py
robot_wrapper.py
romeo_wrapper.py
rpy.py
explog.py
shortcuts.py
)
IF(BUILD_PYTHON_INTERFACE)
ADD_LIBRARY(${PYWRAP} SHARED ${${PYWRAP}_SOURCES} ${${PYWRAP}_HEADERS})
ADD_DEPENDENCIES(python ${PYWRAP})
IF(BUILD_WITH_COMMIT_VERSION)
TAG_LIBRARY_VERSION(${PYWRAP})
ENDIF(BUILD_WITH_COMMIT_VERSION)
ADD_HEADER_GROUP(${PYWRAP}_HEADERS)
ADD_SOURCE_GROUP(${PYWRAP}_SOURCES)
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(CPPAD_FOUND)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} "cppad")
ENDIF(CPPAD_FOUND)
IF(CPPADCG_FOUND)
SET_PROPERTY(TARGET ${PYWRAP} PROPERTY CXX_STANDARD 11)
PKG_CONFIG_USE_DEPENDENCY(${PYWRAP} "cppadcg")
ENDIF(CPPADCG_FOUND)
IF(APPLE)
# We need to change the extension for python bindings
SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES SUFFIX ".so")
ENDIF(APPLE)
SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
INSTALL(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR})
# --- INSTALL SCRIPTS
SET(PYTHON_FILES
__init__.py
deprecated.py
deprecation.py
utils.py
robot_wrapper.py
romeo_wrapper.py
rpy.py
explog.py
shortcuts.py
)
FOREACH(python ${PYTHON_FILES})
PYTHON_BUILD(${PROJECT_NAME} ${python})
INSTALL(FILES
"${${PROJECT_NAME}_SOURCE_DIR}/bindings/python/pinocchio/${python}"
DESTINATION ${${PYWRAP}_INSTALL_DIR})
ENDFOREACH(python)
# --- INSTALL VISUALIZATION SCRIPTS
SET(PYTHON_VISUALIZE_FILES
__init__.py
base_visualizer.py
gepetto_visualizer.py
meshcat_visualizer.py
)
FOREACH(python ${PYTHON_FILES})
PYTHON_BUILD(${PROJECT_NAME} ${python})
INSTALL(FILES
"${${PROJECT_NAME}_SOURCE_DIR}/bindings/python/pinocchio/${python}"
DESTINATION ${${PYWRAP}_INSTALL_DIR})
ENDFOREACH(python)
# --- INSTALL VISUALIZATION SCRIPTS
SET(PYTHON_VISUALIZE_FILES
__init__.py
base_visualizer.py
gepetto_visualizer.py
meshcat_visualizer.py
)
FOREACH(python ${PYTHON_VISUALIZE_FILES})
PYTHON_BUILD(${PROJECT_NAME}/visualize ${python})
INSTALL(FILES
"${${PROJECT_NAME}_SOURCE_DIR}/bindings/python/pinocchio/visualize/${python}"
DESTINATION ${${PYWRAP}_INSTALL_DIR}/visualize)
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}/pinocchiopy.pc.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/pinocchiopy.pc")
INSTALL(
FILES "${CMAKE_CURRENT_BINARY_DIR}/pinocchiopy.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)
FOREACH(python ${PYTHON_VISUALIZE_FILES})
PYTHON_BUILD(${PROJECT_NAME}/visualize ${python})
INSTALL(FILES
"${${PROJECT_NAME}_SOURCE_DIR}/bindings/python/pinocchio/visualize/${python}"
DESTINATION ${${PYWRAP}_INSTALL_DIR}/visualize)
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}/pinocchiopy.pc.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/pinocchiopy.pc")
INSTALL(
FILES "${CMAKE_CURRENT_BINARY_DIR}/pinocchiopy.pc"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE)
ENDIF(BUILD_PYTHON_INTERFACE)
Markdown is supported
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