From fcd18961d50075235e9fc3751660068726ee5d82 Mon Sep 17 00:00:00 2001 From: Joris Vaillant Date: Fri, 20 Oct 2023 16:23:09 +0200 Subject: [PATCH] [cmake] Don't use GLOB/GLOB_RECURSE to find sources --- CMakeLists.txt | 68 ++++++ bindings/python/CMakeLists.txt | 73 +----- sources.cmake | 395 +++++++++++++++++++++++++++++++++ src/CMakeLists.txt | 72 +----- 4 files changed, 486 insertions(+), 122 deletions(-) create mode 100644 sources.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2a74952f3f..ae4df9d713 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -198,6 +198,74 @@ IF(BUILD_WITH_HPP_FCL_SUPPORT) ENDIF(BUILD_PYTHON_INTERFACE) ENDIF(BUILD_WITH_HPP_FCL_SUPPORT) +# Sources definition +INCLUDE(sources.cmake) + +IF(BUILD_WITH_URDF_SUPPORT) + LIST(APPEND ${PROJECT_NAME}_CORE_SOURCES ${${PROJECT_NAME}_URDF_SOURCES}) + LIST(APPEND ${PROJECT_NAME}_CORE_PUBLIC_HEADERS ${${PROJECT_NAME}_URDF_PUBLIC_HEADERS}) +ENDIF(BUILD_WITH_URDF_SUPPORT) + +IF(BUILD_WITH_LIBPYTHON) + LIST(APPEND ${PROJECT_NAME}_CORE_PUBLIC_HEADERS + ${${PROJECT_NAME}_LIBPYTHON_PUBLIC_HEADERS}) + LIST(APPEND ${PROJECT_NAME}_BINDINGS_PYTHON_SOURCES + ${${PROJECT_NAME}_BINDINGS_PYTHON_LIBPYTHON_SOURCES}) + LIST(APPEND ${PROJECT_NAME}_BINDINGS_PYTHON_PUBLIC_HEADERS + ${${PROJECT_NAME}_BINDINGS_PYTHON_LIBPYTHON_PUBLIC_HEADERS}) +ENDIF(BUILD_WITH_LIBPYTHON) + +IF(BUILD_WITH_HPP_FCL_SUPPORT) + LIST(APPEND ${PROJECT_NAME}_CORE_PUBLIC_HEADERS + ${${PROJECT_NAME}_HPP_FCL_PUBLIC_HEADERS}) + LIST(APPEND ${PROJECT_NAME}_BINDINGS_PYTHON_SOURCES + ${${PROJECT_NAME}_BINDINGS_PYTHON_HPP_FCL_SOURCES}) + LIST(APPEND ${PROJECT_NAME}_BINDINGS_PYTHON_PUBLIC_HEADERS + ${${PROJECT_NAME}_BINDINGS_PYTHON_HPP_FCL_PUBLIC_HEADERS}) +ENDIF(BUILD_WITH_HPP_FCL_SUPPORT) + +IF(BUILD_WITH_OPENMP_SUPPORT) + LIST(APPEND ${PROJECT_NAME}_BINDINGS_PYTHON_SOURCES + ${${PROJECT_NAME}_BINDINGS_PYTHON_OPENMP_SOURCES}) + LIST(APPEND ${PROJECT_NAME}_BINDINGS_PYTHON_PUBLIC_HEADERS + ${${PROJECT_NAME}_BINDINGS_PYTHON_OPENMP_PUBLIC_HEADERS}) + IF(BUILD_WITH_HPP_FCL_SUPPORT) + LIST(APPEND ${PROJECT_NAME}_BINDINGS_PYTHON_SOURCES + ${${PROJECT_NAME}_BINDINGS_PYTHON_HPP_FCL_OPENMP_SOURCES}) + LIST(APPEND ${PROJECT_NAME}_BINDINGS_PYTHON_PUBLIC_HEADERS + ${${PROJECT_NAME}_BINDINGS_PYTHON_HPP_FCL_OPENMP_PUBLIC_HEADERS}) + ENDIF(BUILD_WITH_HPP_FCL_SUPPORT) +ENDIF() + +# List headers to install +LIST(APPEND ${PROJECT_NAME}_HEADERS + ${${PROJECT_NAME}_CORE_PUBLIC_HEADERS} + ) +IF(BUILD_PYTHON_INTERFACE) + LIST(APPEND ${PROJECT_NAME}_HEADERS + ${${PROJECT_NAME}_BINDINGS_PYTHON_PUBLIC_HEADERS} + ) +ENDIF(BUILD_PYTHON_INTERFACE) + +# Macros to update souces path in subdirs +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) + +FUNCTION(PREPEND_PATH_FROM_LIST list_name path_name dest_list) + SET(list_name_) + FOREACH(header ${${list_name}}) + SET(header "${path_name}/${header}") + LIST(APPEND list_name_ ${header}) + ENDFOREACH(header ${list_name_}) + SET(${dest_list} ${list_name_} PARENT_SCOPE) +ENDFUNCTION(PREPEND_PATH_FROM_LIST) + # Enforce the preprocessed version of boost::list and boost::vector # This information is redundant with the content of include/pinocchio/container/boost-container-limits.hpp # but it avoids any compilation issue. diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index e2705a3866..05dd837537 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -9,59 +9,16 @@ include(${JRL_CMAKE_MODULES}/python-helpers.cmake) SET(PYWRAP ${PROJECT_NAME}_pywrap) SET(PYWRAP ${PYWRAP} PARENT_SCOPE) -FILE(GLOB_RECURSE ${PROJECT_NAME}_PYTHON_HEADERS - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/bindings/*.hpp - ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/bindings/*.hxx - ) - -FILE(GLOB_RECURSE ${PROJECT_NAME}_PYTHON_SOURCES - RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp - ) - -SET(SOURCE_HEADERS_ROOT "../../include/${PROJECT_NAME}/bindings/python") - -# Parser for Python model -IF(NOT BUILD_WITH_LIBPYTHON) - LIST(REMOVE_ITEM ${PROJECT_NAME}_PYTHON_HEADERS - ${SOURCE_HEADERS_ROOT}/parsers/python.hpp - ) - LIST(REMOVE_ITEM ${PROJECT_NAME}_PYTHON_SOURCES - parsers/python/model.cpp - ) -ENDIF(NOT BUILD_WITH_LIBPYTHON) - -# Python exposition of FCL -IF(NOT BUILD_WITH_HPP_FCL_PYTHON_BINDINGS) - LIST(REMOVE_ITEM ${PROJECT_NAME}_PYTHON_HEADERS - ${SOURCE_HEADERS_ROOT}/multibody/fcl/transform.hpp - ) - LIST(REMOVE_ITEM ${PROJECT_NAME}_PYTHON_SOURCES - multibody/fcl/expose-fcl.cpp - ) -ENDIF(NOT BUILD_WITH_HPP_FCL_PYTHON_BINDINGS) - -IF(NOT BUILD_WITH_OPENMP_SUPPORT) - LIST(FILTER ${PROJECT_NAME}_PYTHON_HEADERS EXCLUDE REGEX "^${SOURCE_HEADERS_ROOT}/multibody/pool") - LIST(FILTER ${PROJECT_NAME}_PYTHON_SOURCES EXCLUDE REGEX "^multibody/pool") - LIST(FILTER ${PROJECT_NAME}_PYTHON_HEADERS EXCLUDE REGEX "^${SOURCE_HEADERS_ROOT}/algorithm/parallel") - LIST(FILTER ${PROJECT_NAME}_PYTHON_SOURCES EXCLUDE REGEX "^algorithm/parallel") -ELSE(NOT BUILD_WITH_OPENMP_SUPPORT) - IF(NOT BUILD_WITH_HPP_FCL_SUPPORT) - LIST(REMOVE_ITEM ${PROJECT_NAME}_PYTHON_HEADERS - ${SOURCE_HEADERS_ROOT}/multibody/pool/geometry.hpp - ) - LIST(REMOVE_ITEM ${PROJECT_NAME}_PYTHON_SOURCES - algorithm/parallel/geometry.cpp - ) - ENDIF(NOT BUILD_WITH_HPP_FCL_SUPPORT) -ENDIF(NOT BUILD_WITH_OPENMP_SUPPORT) - # --- COMPILE WRAPPER +REMOVE_PATH_FROM_LIST(${PROJECT_NAME}_BINDINGS_PYTHON_SOURCES + "bindings/python/" + ${PROJECT_NAME}_BINDINGS_PYTHON_SOURCES) +PREPEND_PATH_FROM_LIST(${PROJECT_NAME}_BINDINGS_PYTHON_PUBLIC_HEADERS + "../../" + ${PROJECT_NAME}_BINDINGS_PYTHON_PUBLIC_HEADERS) MAKE_DIRECTORY("${${PROJECT_NAME}_BINARY_DIR}/bindings/python/${PROJECT_NAME}") -SET(${PYWRAP}_SOURCES ${${PROJECT_NAME}_PYTHON_SOURCES}) -SET(${PYWRAP}_HEADERS ${${PROJECT_NAME}_PYTHON_HEADERS}) +SET(${PYWRAP}_SOURCES ${${PROJECT_NAME}_BINDINGS_PYTHON_SOURCES}) +SET(${PYWRAP}_HEADERS ${${PROJECT_NAME}_BINDINGS_PYTHON_PUBLIC_HEADERS}) IF(BUILD_PYTHON_INTERFACE) ADD_CUSTOM_TARGET(python) @@ -140,15 +97,6 @@ IF(BUILD_PYTHON_INTERFACE) DESTINATION ${${PYWRAP}_INSTALL_DIR} ) - FOREACH(header ${${PYWRAP}_HEADERS}) - GET_FILENAME_COMPONENT(header_path ${header} PATH) - STRING(REPLACE "../../" "" non_relative_header_path ${header_path}) - INSTALL(FILES ${header} - DESTINATION ${CMAKE_INSTALL_PREFIX}/${non_relative_header_path} - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) - ENDFOREACH(header) - - # --- INSTALL SCRIPTS SET(PYTHON_FILES __init__.py @@ -222,9 +170,10 @@ IF(BUILD_PYTHON_INTERFACE) SET(DOXYGEN_GENERATE_HTML YES) SET(DOXYGEN_GENERATE_LATEX NO) SET(DOXYGEN_PROJECT_NAME "Pinocchio PyBind11 helpers.") + SET(_source_headers_root "../../include/${PROJECT_NAME}/bindings/python") DOXYGEN_ADD_DOCS(doc_pybind11 - ${SOURCE_HEADERS_ROOT}/pybind11.hpp - ${SOURCE_HEADERS_ROOT}/pybind11-all.hpp + ${_source_headers_root}/pybind11.hpp + ${_source_headers_root}/pybind11-all.hpp USE_STAMP_FILE COMMENT "Generating documentation of the PyBind11 helpers.") ENDIF() diff --git a/sources.cmake b/sources.cmake new file mode 100644 index 0000000000..a0e9aca375 --- /dev/null +++ b/sources.cmake @@ -0,0 +1,395 @@ +# Define Pinocchio sources and headers + +SET(${PROJECT_NAME}_CORE_SOURCES + src/utils/file-explorer.cpp + ) + +SET(${PROJECT_NAME}_CORE_PUBLIC_HEADERS + include/pinocchio/deprecated-macros.hpp + include/pinocchio/spatial/motion-dense.hpp + include/pinocchio/spatial/explog.hpp + include/pinocchio/spatial/explog-quaternion.hpp + include/pinocchio/spatial/log.hxx + include/pinocchio/spatial/spatial-axis.hpp + include/pinocchio/spatial/fcl-pinocchio-conversions.hpp + include/pinocchio/spatial/symmetric3.hpp + include/pinocchio/spatial/act-on-set.hpp + include/pinocchio/spatial/fwd.hpp + include/pinocchio/spatial/se3-base.hpp + include/pinocchio/spatial/cartesian-axis.hpp + include/pinocchio/spatial/motion.hpp + include/pinocchio/spatial/motion-ref.hpp + include/pinocchio/spatial/force-ref.hpp + include/pinocchio/spatial/skew.hpp + include/pinocchio/spatial/force-base.hpp + include/pinocchio/spatial/motion-zero.hpp + include/pinocchio/spatial/force-tpl.hpp + include/pinocchio/spatial/force.hpp + include/pinocchio/spatial/force-dense.hpp + include/pinocchio/spatial/inertia.hpp + include/pinocchio/spatial/log.hpp + include/pinocchio/spatial/motion-tpl.hpp + include/pinocchio/spatial/se3-tpl.hpp + include/pinocchio/spatial/act-on-set.hxx + include/pinocchio/spatial/se3.hpp + include/pinocchio/spatial/motion-base.hpp + include/pinocchio/algorithm/check.hxx + include/pinocchio/algorithm/crba.hxx + include/pinocchio/algorithm/dynamics.hpp + include/pinocchio/algorithm/kinematics.hxx + include/pinocchio/algorithm/aba-derivatives.hpp + include/pinocchio/algorithm/centroidal-derivatives.hpp + include/pinocchio/algorithm/contact-dynamics.hxx + include/pinocchio/algorithm/regressor.hxx + include/pinocchio/algorithm/frames.hxx + include/pinocchio/algorithm/joint-configuration.hxx + include/pinocchio/algorithm/energy.hpp + include/pinocchio/algorithm/center-of-mass.hxx + include/pinocchio/algorithm/geometry.hpp + include/pinocchio/algorithm/center-of-mass-derivatives.hpp + include/pinocchio/algorithm/aba.hpp + include/pinocchio/algorithm/cholesky.hpp + include/pinocchio/algorithm/kinematics.hpp + include/pinocchio/algorithm/rnea.hxx + include/pinocchio/algorithm/regressor.hpp + include/pinocchio/algorithm/frames.hpp + include/pinocchio/algorithm/kinematics-derivatives.hxx + include/pinocchio/algorithm/jacobian.hxx + include/pinocchio/algorithm/rnea-derivatives.hpp + include/pinocchio/algorithm/rnea-second-order-derivatives.hxx + include/pinocchio/algorithm/joint-configuration.hpp + include/pinocchio/algorithm/model.hxx + include/pinocchio/algorithm/contact-dynamics.hpp + include/pinocchio/algorithm/centroidal.hxx + include/pinocchio/algorithm/model.hpp + include/pinocchio/algorithm/rnea-derivatives.hxx + include/pinocchio/algorithm/compute-all-terms.hpp + include/pinocchio/algorithm/jacobian.hpp + include/pinocchio/algorithm/rnea-second-order-derivatives.hpp + include/pinocchio/algorithm/copy.hpp + include/pinocchio/algorithm/centroidal.hpp + include/pinocchio/algorithm/kinematics-derivatives.hpp + include/pinocchio/algorithm/check.hpp + include/pinocchio/algorithm/energy.hxx + include/pinocchio/algorithm/geometry.hxx + include/pinocchio/algorithm/rnea.hpp + include/pinocchio/algorithm/parallel/geometry.hpp + include/pinocchio/algorithm/parallel/aba.hpp + include/pinocchio/algorithm/parallel/rnea.hpp + include/pinocchio/algorithm/centroidal-derivatives.hxx + include/pinocchio/algorithm/cholesky.hxx + include/pinocchio/algorithm/default-check.hpp + include/pinocchio/algorithm/center-of-mass.hpp + include/pinocchio/algorithm/frames-derivatives.hxx + include/pinocchio/algorithm/aba-derivatives.hxx + include/pinocchio/algorithm/crba.hpp + include/pinocchio/algorithm/compute-all-terms.hxx + include/pinocchio/algorithm/aba.hxx + include/pinocchio/algorithm/center-of-mass-derivatives.hxx + include/pinocchio/algorithm/frames-derivatives.hpp + include/pinocchio/codegen/code-generator-algo.hpp + include/pinocchio/codegen/cppadcg.hpp + include/pinocchio/codegen/code-generator-base.hpp + include/pinocchio/macros.hpp + include/pinocchio/autodiff/casadi/spatial/se3-tpl.hpp + include/pinocchio/autodiff/casadi/utils/static-if.hpp + include/pinocchio/autodiff/casadi/math/matrix.hpp + include/pinocchio/autodiff/casadi/math/quaternion.hpp + include/pinocchio/autodiff/cppad.hpp + include/pinocchio/autodiff/cppad/spatial/log.hxx + include/pinocchio/autodiff/cppad/spatial/se3-tpl.hpp + include/pinocchio/autodiff/cppad/algorithm/aba.hpp + include/pinocchio/autodiff/cppad/utils/static-if.hpp + include/pinocchio/autodiff/cppad/math/eigen_plugin.hpp + include/pinocchio/autodiff/cppad/math/quaternion.hpp + include/pinocchio/autodiff/casadi.hpp + include/pinocchio/utils/string-generator.hpp + include/pinocchio/utils/version.hpp + include/pinocchio/utils/openmp.hpp + include/pinocchio/utils/helpers.hpp + include/pinocchio/utils/axis-label.hpp + include/pinocchio/utils/file-explorer.hpp + include/pinocchio/utils/cast.hpp + include/pinocchio/utils/eigen-fix.hpp + include/pinocchio/utils/static-if.hpp + include/pinocchio/utils/timer.hpp + include/pinocchio/deprecated-namespaces.hpp + include/pinocchio/math/comparison-operators.hpp + include/pinocchio/math/multiprecision.hpp + include/pinocchio/math/tensor.hpp + include/pinocchio/math/cppadcg.hpp + include/pinocchio/math/rpy.hpp + include/pinocchio/math/cppad.hpp + include/pinocchio/math/fwd.hpp + include/pinocchio/math/taylor-expansion.hpp + include/pinocchio/math/matrix-block.hpp + include/pinocchio/math/matrix.hpp + include/pinocchio/math/multiprecision-mpfr.hpp + include/pinocchio/math/casadi.hpp + include/pinocchio/math/sign.hpp + include/pinocchio/math/sincos.hpp + include/pinocchio/math/rotation.hpp + include/pinocchio/math/quaternion.hpp + include/pinocchio/math/rpy.hxx + include/pinocchio/container/boost-container-limits.hpp + include/pinocchio/container/aligned-vector.hpp + include/pinocchio/fwd.hpp + include/pinocchio/serialization/data.hpp + include/pinocchio/serialization/vector.hpp + include/pinocchio/serialization/static-buffer.hpp + include/pinocchio/serialization/frame.hpp + include/pinocchio/serialization/geometry.hpp + include/pinocchio/serialization/joints-constraint.hpp + include/pinocchio/serialization/joints-model.hpp + include/pinocchio/serialization/symmetric3.hpp + include/pinocchio/serialization/archive.hpp + include/pinocchio/serialization/joints-motion.hpp + include/pinocchio/serialization/model.hpp + include/pinocchio/serialization/fwd.hpp + include/pinocchio/serialization/motion.hpp + include/pinocchio/serialization/eigen.hpp + include/pinocchio/serialization/joints-data.hpp + include/pinocchio/serialization/spatial.hpp + include/pinocchio/serialization/joints-transform.hpp + include/pinocchio/serialization/force.hpp + include/pinocchio/serialization/joints.hpp + include/pinocchio/serialization/serializable.hpp + include/pinocchio/serialization/inertia.hpp + include/pinocchio/serialization/aligned-vector.hpp + include/pinocchio/serialization/se3.hpp + include/pinocchio/multibody/constraint-generic.hpp + include/pinocchio/multibody/data.hpp + include/pinocchio/multibody/frame.hpp + include/pinocchio/multibody/geometry.hpp + include/pinocchio/multibody/pool/geometry.hpp + include/pinocchio/multibody/pool/model.hpp + include/pinocchio/multibody/visitor.hpp + include/pinocchio/multibody/constraint-base.hpp + include/pinocchio/multibody/fcl.hpp + include/pinocchio/multibody/model.hxx + include/pinocchio/multibody/liegroup/liegroup-base.hpp + include/pinocchio/multibody/liegroup/liegroup-algo.hpp + include/pinocchio/multibody/liegroup/special-euclidean.hpp + include/pinocchio/multibody/liegroup/liegroup-base.hxx + include/pinocchio/multibody/liegroup/liegroup.hpp + include/pinocchio/multibody/liegroup/cartesian-product-variant.hpp + include/pinocchio/multibody/liegroup/liegroup-algo.hxx + include/pinocchio/multibody/liegroup/fwd.hpp + include/pinocchio/multibody/liegroup/liegroup-variant-visitors.hxx + include/pinocchio/multibody/liegroup/special-orthogonal.hpp + include/pinocchio/multibody/liegroup/cartesian-product-variant.hxx + include/pinocchio/multibody/liegroup/liegroup-generic.hpp + include/pinocchio/multibody/liegroup/cartesian-product.hpp + include/pinocchio/multibody/liegroup/liegroup-collection.hpp + include/pinocchio/multibody/liegroup/vector-space.hpp + include/pinocchio/multibody/liegroup/liegroup-variant-visitors.hpp + include/pinocchio/multibody/model.hpp + include/pinocchio/multibody/fwd.hpp + include/pinocchio/multibody/force-set.hpp + include/pinocchio/multibody/joint/joint-spherical.hpp + include/pinocchio/multibody/joint/joint-data-base.hpp + include/pinocchio/multibody/joint/joint-revolute-unaligned.hpp + include/pinocchio/multibody/joint/joint-planar.hpp + include/pinocchio/multibody/joint/joint-composite.hxx + include/pinocchio/multibody/joint/joint-basic-visitors.hpp + include/pinocchio/multibody/joint/joint-free-flyer.hpp + include/pinocchio/multibody/joint/joint-common-operations.hpp + include/pinocchio/multibody/joint/joint-model-base.hpp + include/pinocchio/multibody/joint/joint-prismatic.hpp + include/pinocchio/multibody/joint/joint-spherical-ZYX.hpp + include/pinocchio/multibody/joint/joint-composite.hpp + include/pinocchio/multibody/joint/joint-translation.hpp + include/pinocchio/multibody/joint/fwd.hpp + include/pinocchio/multibody/joint/joint-mimic.hpp + include/pinocchio/multibody/joint/joint-base.hpp + include/pinocchio/multibody/joint/joint-prismatic-unaligned.hpp + include/pinocchio/multibody/joint/joint-revolute.hpp + include/pinocchio/multibody/joint/joint-revolute-unbounded.hpp + include/pinocchio/multibody/joint/joint-generic.hpp + include/pinocchio/multibody/joint/joints.hpp + include/pinocchio/multibody/joint/joint-basic-visitors.hxx + include/pinocchio/multibody/joint/joint-revolute-unbounded-unaligned.hpp + include/pinocchio/multibody/joint/joint-collection.hpp + include/pinocchio/multibody/geometry.hxx + include/pinocchio/multibody/fcl.hxx + include/pinocchio/multibody/constraint.hpp + include/pinocchio/multibody/visitor/joint-unary-visitor.hpp + include/pinocchio/multibody/visitor/fusion.hpp + include/pinocchio/multibody/visitor/joint-binary-visitor.hpp + include/pinocchio/multibody/data.hxx + include/pinocchio/eigen-macros.hpp + include/pinocchio/deprecation.hpp + include/pinocchio/core/unary-op.hpp + include/pinocchio/core/binary-op.hpp + include/pinocchio/parsers/python.hpp + include/pinocchio/parsers/urdf.hpp + include/pinocchio/parsers/sample-models.hpp + include/pinocchio/parsers/utils.hpp + include/pinocchio/parsers/urdf/types.hpp + include/pinocchio/parsers/urdf/utils.hpp + include/pinocchio/parsers/urdf/model.hxx + include/pinocchio/parsers/urdf/geometry.hxx + include/pinocchio/parsers/srdf.hpp + include/pinocchio/parsers/sample-models.hxx + include/pinocchio/parsers/srdf.hxx + ) + +SET(${PROJECT_NAME}_URDF_SOURCES + src/parsers/urdf/model.cpp + src/parsers/urdf/geometry.cpp + src/parsers/urdf/utils.cpp + ) + +SET(${PROJECT_NAME}_URDF_PUBLIC_HEADERS + include/pinocchio/parsers/urdf.hpp + include/pinocchio/parsers/urdf/model.hxx + include/pinocchio/parsers/urdf/geometry.hxx + include/pinocchio/parsers/urdf/utils.hpp + include/pinocchio/parsers/urdf/types.hpp + ) + +SET(${PROJECT_NAME}_LIBPYTHON_PUBLIC_HEADERS + include/pinocchio/parsers/python.hpp + ) + +SET(${PROJECT_NAME}_HPP_FCL_PUBLIC_HEADERS + include/pinocchio/spatial/fcl-pinocchio-conversions.hpp + ) + +SET(_binary_headers_root ${${PROJECT_NAME}_BINARY_DIR}/include/pinocchio) +SET(${PROJECT_NAME}_CORE_PRIVATE_HEADERS + ${_binary_headers_root}/config.hpp + ${_binary_headers_root}/deprecated.hpp + ${_binary_headers_root}/warning.hpp + ) + +# Define Pinocchio Python binding sources and headers + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_PUBLIC_HEADERS + include/pinocchio/bindings/python/spatial/explog.hpp + include/pinocchio/bindings/python/spatial/motion.hpp + include/pinocchio/bindings/python/spatial/force.hpp + include/pinocchio/bindings/python/spatial/inertia.hpp + include/pinocchio/bindings/python/spatial/se3.hpp + include/pinocchio/bindings/python/algorithm/algorithms.hpp + include/pinocchio/bindings/python/pybind11-all.hpp + include/pinocchio/bindings/python/pybind11.hpp + include/pinocchio/bindings/python/utils/constant.hpp + include/pinocchio/bindings/python/utils/version.hpp + include/pinocchio/bindings/python/utils/pickle-vector.hpp + include/pinocchio/bindings/python/utils/std-vector.hpp + include/pinocchio/bindings/python/utils/printable.hpp + include/pinocchio/bindings/python/utils/dependencies.hpp + include/pinocchio/bindings/python/utils/conversions.hpp + include/pinocchio/bindings/python/utils/copyable.hpp + include/pinocchio/bindings/python/utils/registration.hpp + include/pinocchio/bindings/python/utils/pickle-map.hpp + include/pinocchio/bindings/python/utils/list.hpp + include/pinocchio/bindings/python/utils/std-aligned-vector.hpp + include/pinocchio/bindings/python/utils/eigen.hpp + include/pinocchio/bindings/python/utils/std-map.hpp + include/pinocchio/bindings/python/utils/deprecation.hpp + include/pinocchio/bindings/python/utils/namespace.hpp + include/pinocchio/bindings/python/fwd.hpp + include/pinocchio/bindings/python/serialization/serialization.hpp + include/pinocchio/bindings/python/serialization/serializable.hpp + include/pinocchio/bindings/python/multibody/data.hpp + include/pinocchio/bindings/python/multibody/frame.hpp + include/pinocchio/bindings/python/multibody/geometry-model.hpp + include/pinocchio/bindings/python/multibody/model.hpp + include/pinocchio/bindings/python/multibody/joint/joint-derived.hpp + include/pinocchio/bindings/python/multibody/joint/joints-models.hpp + include/pinocchio/bindings/python/multibody/joint/joints-variant.hpp + include/pinocchio/bindings/python/multibody/joint/joints-datas.hpp + include/pinocchio/bindings/python/multibody/joint/joint.hpp + include/pinocchio/bindings/python/multibody/liegroups.hpp + include/pinocchio/bindings/python/multibody/geometry-data.hpp + include/pinocchio/bindings/python/multibody/geometry-object.hpp + include/pinocchio/bindings/python/parsers/urdf.hpp + include/pinocchio/bindings/python/parsers/sample-models.hpp + include/pinocchio/bindings/python/parsers/srdf.hpp + ) + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_SOURCES + bindings/python/spatial/expose-force.cpp + bindings/python/spatial/expose-inertia.cpp + bindings/python/spatial/expose-SE3.cpp + bindings/python/spatial/expose-motion.cpp + bindings/python/spatial/expose-explog.cpp + bindings/python/spatial/expose-skew.cpp + bindings/python/algorithm/expose-model.cpp + bindings/python/algorithm/expose-centroidal.cpp + bindings/python/algorithm/expose-aba.cpp + bindings/python/algorithm/expose-algorithms.cpp + bindings/python/algorithm/expose-com.cpp + bindings/python/algorithm/expose-frames.cpp + bindings/python/algorithm/expose-energy.cpp + bindings/python/algorithm/expose-contact-dynamics.cpp + bindings/python/algorithm/expose-rnea-derivatives.cpp + bindings/python/algorithm/expose-kinematics.cpp + bindings/python/algorithm/expose-geometry.cpp + bindings/python/algorithm/expose-aba-derivatives.cpp + bindings/python/algorithm/expose-joints.cpp + bindings/python/algorithm/expose-rnea.cpp + bindings/python/algorithm/expose-cholesky.cpp + bindings/python/algorithm/expose-regressor.cpp + bindings/python/algorithm/expose-kinematics-derivatives.cpp + bindings/python/algorithm/expose-cat.cpp + bindings/python/algorithm/expose-frames-derivatives.cpp + bindings/python/algorithm/expose-centroidal-derivatives.cpp + bindings/python/algorithm/expose-jacobian.cpp + bindings/python/algorithm/expose-kinematic-regressor.cpp + bindings/python/algorithm/expose-crba.cpp + bindings/python/module.cpp + bindings/python/utils/version.cpp + bindings/python/utils/dependencies.cpp + bindings/python/utils/conversions.cpp + bindings/python/math/expose-rpy.cpp + bindings/python/serialization/serialization.cpp + bindings/python/multibody/expose-model.cpp + bindings/python/multibody/expose-liegroups.cpp + bindings/python/multibody/expose-geometry.cpp + bindings/python/multibody/expose-frame.cpp + bindings/python/multibody/expose-data.cpp + bindings/python/multibody/joint/expose-joints.cpp + bindings/python/parsers/expose-parsers.cpp + bindings/python/parsers/urdf/model.cpp + bindings/python/parsers/urdf/geometry.cpp + bindings/python/parsers/srdf.cpp + bindings/python/parsers/sample-models.cpp + ) + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_LIBPYTHON_SOURCES + bindings/python/parsers/python/model.cpp + ) + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_LIBPYTHON_PUBLIC_HEADERS + include/pinocchio/bindings/python/parsers/python.hpp + ) + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_HPP_FCL_SOURCES + bindings/python/multibody/fcl/expose-fcl.cpp + ) + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_HPP_FCL_PUBLIC_HEADERS + include/pinocchio/bindings/python/multibody/fcl/transform.hpp + ) + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_OPENMP_SOURCES + bindings/python/multibody/pool/expose-pool.cpp + bindings/python/algorithm/parallel/aba.cpp + bindings/python/algorithm/parallel/expose-parallel.cpp + bindings/python/algorithm/parallel/rnea.cpp + ) + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_OPENMP_PUBLIC_HEADERS + include/pinocchio/bindings/python/multibody/pool/model.hpp + ) + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_HPP_FCL_OPENMP_SOURCES + bindings/python/algorithm/parallel/geometry.cpp + ) + +SET(${PROJECT_NAME}_BINDINGS_PYTHON_HPP_FCL_OPENMP_PUBLIC_HEADERS + include/pinocchio/bindings/python/multibody/pool/geometry.hpp + ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b730c1150d..e87c3f8c47 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,55 +7,19 @@ # --- INCLUDE ---------------------------------------- # ---------------------------------------------------- -# Find all headers with a relative path to avoid conflict with root path -# when applying filters -FILE(GLOB_RECURSE PUBLIC_HEADERS - RELATIVE - ${CMAKE_CURRENT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/*.hpp - ${PROJECT_SOURCE_DIR}/include/${PROJECT_NAME}/*.hxx - ) - -SET(SOURCE_HEADERS_ROOT "../include/${PROJECT_NAME}") -SET(BINARY_HEADERS_ROOT "${${PROJECT_NAME}_BINARY_DIR}/include/${PROJECT_NAME}") - -# Remove bindings -LIST(FILTER PUBLIC_HEADERS EXCLUDE REGEX "^${SOURCE_HEADERS_ROOT}/bindings/.*") - -# Add generated headers -LIST(APPEND PRIVATE_HEADERS - ${BINARY_HEADERS_ROOT}/config.hpp - ${BINARY_HEADERS_ROOT}/deprecated.hpp - ${BINARY_HEADERS_ROOT}/warning.hpp) - -IF(BUILD_WITH_URDF_SUPPORT) - LIST(APPEND ${PROJECT_NAME}_SOURCES - parsers/urdf/model.cpp - parsers/urdf/geometry.cpp - parsers/urdf/utils.cpp - ) -ELSE(BUILD_WITH_URDF_SUPPORT) - LIST(REMOVE_ITEM PUBLIC_HEADERS - ${SOURCE_HEADERS_ROOT}/parsers/urdf.hpp - ${SOURCE_HEADERS_ROOT}/parsers/urdf/model.hxx - ${SOURCE_HEADERS_ROOT}/parsers/urdf/geometry.hxx - ${SOURCE_HEADERS_ROOT}/parsers/urdf/utils.hpp - ${SOURCE_HEADERS_ROOT}/parsers/urdf/types.hpp - ) -ENDIF() - -# Parser for Python model -IF(NOT BUILD_WITH_LIBPYTHON) - LIST(REMOVE_ITEM PUBLIC_HEADERS ${SOURCE_HEADERS_ROOT}/parsers/python.hpp) -ENDIF(BUILD_WITH_LIBPYTHON) - -LIST(APPEND ${PROJECT_NAME}_SOURCES utils/file-explorer.cpp) - # Extract the compile definitions of the project for export GET_DIRECTORY_PROPERTY(CURRENT_COMPILE_DEFINITIONS COMPILE_DEFINITIONS) +REMOVE_PATH_FROM_LIST(${PROJECT_NAME}_CORE_SOURCES "src/" ${PROJECT_NAME}_CORE_SOURCES) +PREPEND_PATH_FROM_LIST(${PROJECT_NAME}_CORE_PUBLIC_HEADERS + "../" + ${PROJECT_NAME}_CORE_PUBLIC_HEADERS) + # Create target libpinocchio.so -ADD_LIBRARY(${PROJECT_NAME} SHARED ${PUBLIC_HEADERS} ${PRIVATE_HEADERS} ${${PROJECT_NAME}_SOURCES}) +ADD_LIBRARY(${PROJECT_NAME} SHARED + ${${PROJECT_NAME}_CORE_SOURCES} + ${${PROJECT_NAME}_CORE_PUBLIC_HEADERS} + ${${PROJECT_NAME}_CORE_PRIVATE_HEADERS}) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE CXX INSTALL_RPATH "\$ORIGIN" @@ -68,10 +32,6 @@ ADD_LIBRARY(${PROJECT_NAME}_headers INTERFACE) # Exclude parts from hppfcl which is not header only IF(BUILD_WITH_HPP_FCL_SUPPORT) LIST(REMOVE_ITEM CURRENT_COMPILE_DEFINITIONS PINOCCHIO_WITH_HPP_FCL) -ELSE(BUILD_WITH_HPP_FCL_SUPPORT) - LIST(REMOVE_ITEM PUBLIC_HEADERS - ${SOURCE_HEADERS_ROOT}/spatial/fcl-pinocchio-conversions.hpp - ) ENDIF(BUILD_WITH_HPP_FCL_SUPPORT) TARGET_COMPILE_DEFINITIONS(${PROJECT_NAME}_headers INTERFACE ${CURRENT_COMPILE_DEFINITIONS}) @@ -131,9 +91,9 @@ IF(hpp-fcl_FOUND) TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC hpp-fcl::hpp-fcl) ENDIF(hpp-fcl_FOUND) -ADD_HEADER_GROUP(PUBLIC_HEADERS) -ADD_HEADER_GROUP(PRIVATE_HEADERS) -ADD_SOURCE_GROUP(${PROJECT_NAME}_SOURCES) +ADD_SOURCE_GROUP(${PROJECT_NAME}_CORE_SOURCES) +ADD_HEADER_GROUP(${PROJECT_NAME}_CORE_PUBLIC_HEADERS) +ADD_HEADER_GROUP(${PROJECT_NAME}_CORE_PRIVATE_HEADERS) INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${TARGETS_EXPORT_NAME} @@ -146,11 +106,3 @@ INSTALL(TARGETS ${PROJECT_NAME}_headers LIBRARY DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_FULL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR}) - -FOREACH(header ${PUBLIC_HEADERS}) - GET_FILENAME_COMPONENT(header_path ${header} PATH) - STRING(REPLACE "../" "" non_relative_header_path ${header_path}) - INSTALL(FILES ${header} - DESTINATION ${CMAKE_INSTALL_PREFIX}/${non_relative_header_path} - PERMISSIONS OWNER_READ GROUP_READ WORLD_READ OWNER_WRITE) -ENDFOREACH(header)