jrl-umi3218 / jrl-cmakemodules

CMake utility toolbox
https://jrl-cmakemodules.readthedocs.io/en/master/
Other
57 stars 45 forks source link

add Numpy::Numpy target #517

Closed nim65s closed 2 years ago

nim65s commented 2 years ago

Hi,

This add a Numpy::Numpytarget, which allows our libraries to link to a generic version of "we need numpy include dirs", instead of hardcoding the path to numpy include dirs at configure time in exported targets, thus enabling relocalization.

eg.: in installed ./lib/cmake/eigenpy/eigenpyTargets.cmake, we get:

set_target_properties(eigenpy::eigenpy PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${PACKAGE_PREFIX_DIR}/include"
  INTERFACE_LINK_LIBRARIES "Eigen3::Eigen;Boost::python;Numpy::Numpy"
  INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "include"
)

Instead of the current:

set_target_properties(eigenpy::eigenpy PROPERTIES
  INTERFACE_INCLUDE_DIRECTORIES "/usr/include;/usr/include/python3.10;/usr/lib/python3.10/site-packages/numpy/core/include;${_IMPORT_PREFIX}/include;/usr/include"
  INTERFACE_LINK_LIBRARIES "Eigen3::Eigen;Boost::python"
  INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "/usr/include/python3.10;/usr/lib/python3.10/site-packages/numpy/core/include;include"
)

Which could also be eg. /home/gsaurel/.local/lib/python3.10/site-packages/numpy

nim65s commented 2 years ago

CMake 3.14 Comes with Python3::Numpy. I’ll try this one instead.