Commit 909f09ad authored by jcarpent's avatar jcarpent
Browse files

[CMake] Add packaging of the Python wrapper

parent 384ecb78
......@@ -57,6 +57,8 @@ FOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
ENDFOREACH(dep ${PKG_CONFIG_PYWRAP_REQUIRES})
# --- LIBRARY --- #
SET(${PYWRAP}_INSTALL_DIR "${PYTHON_SITELIB}/${PROJECT_NAME}")
SET(${PROJECT_NAME}_PYTHON_HEADERS
eigen_container.hpp
handler.hpp
......@@ -156,11 +158,11 @@ IF(APPLE)
ENDIF(APPLE)
SET_TARGET_PROPERTIES(${PYWRAP} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/python/${PROJECT_NAME}")
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}")
INSTALL(FILES
"${CMAKE_BINARY_DIR}/lib/python/${PROJECT_NAME}/lib${PYWRAP}.so"
DESTINATION ${PYTHON_SITELIB}/${PROJECT_NAME})
"${CMAKE_BINARY_DIR}/bindings/python/${PROJECT_NAME}/bindings/${PYWRAP}.so"
DESTINATION ${${PYWRAP}_INSTALL_DIR})
# --- INSTALL SCRIPTS
SET(PYTHON_FILES
......@@ -176,27 +178,59 @@ FOREACH(python ${PYTHON_FILES})
GET_FILENAME_COMPONENT(pythonFile ${python} NAME)
EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E ${LINK}
${${PROJECT_NAME}_SOURCE_DIR}/bindings/python/${python}
${${PROJECT_NAME}_BINARY_DIR}/lib/python/${PROJECT_NAME}/${pythonFile})
${${PROJECT_NAME}_BINARY_DIR}/bindings/python/${pythonFile})
# Tag pyc file as generated.
SET_SOURCE_FILES_PROPERTIES(
"${${PROJECT_NAME}_BINARY_DIR}/lib/python/${PROJECT_NAME}/${pythonFile}c"
"${${PROJECT_NAME}_BINARY_DIR}/bindings/python/${pythonFile}c"
PROPERTIES GENERATED TRUE)
EXECUTE_PROCESS(COMMAND
${PYTHON_EXECUTABLE} -m py_compile
${${PROJECT_NAME}_BINARY_DIR}/lib/python/${PROJECT_NAME}/${pythonFile})
${${PROJECT_NAME}_BINARY_DIR}/bindings/python/${pythonFile})
# Clean generated files.
SET_PROPERTY(
DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${${PROJECT_NAME}_BINARY_DIR}/lib/python/${PROJECT_NAME}/${pythonFile}c")
"${${PROJECT_NAME}_BINARY_DIR}/bindings/python/${pythonFile}c")
INSTALL(FILES
"${${PROJECT_NAME}_SOURCE_DIR}/bindings/python/${python}"
"${${PROJECT_NAME}_BINARY_DIR}/lib/python/${PROJECT_NAME}/${pythonFile}c"
DESTINATION ${PYTHON_SITELIB}/${PROJECT_NAME})
"${${PROJECT_NAME}_BINARY_DIR}/bindings/python/${pythonFile}c"
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}/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)
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: pinocchiopy
Description: Python bindings of Pinocchio
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}
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