jrl-umi3218 / jrl-cmakemodules

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

Add relpath.cmake #588

Closed nim65s closed 1 year ago

nim65s commented 1 year ago

with REL_INV_INSTALL_PATH(FILE VARIABLE) to compute the relative inverse install path of FILE and store it into VARIABLE

eg:

rel_inv_install_path("${CMAKE_INSTALL_LIBDIR}/pkgconfig" _PC_REL_INV_INSTALL_PATH)
set(_PKG_CONFIG_PREFIX "\${pcfiledir}/${_PC_REL_INV_INSTALL_PATH}")

and LIB_REL_RPATH(TARGET_INSTALL_DIR VARIABLE) to compute the relative path from this TARGET_INSTALL_DIR to CMAKE_INSTALL_LIBDIR."

eg:

set(${PYWRAP}_INSTALL_DIR ${PYTHON_SITELIB}/${PROJECT_NAME})

if(UNIX)
  lib_rel_rpath(${${PYWRAP}_INSTALL_DIR} ${PYWRAP}_INSTALL_RPATH)
  set_target_properties(${PYWRAP} PROPERTIES INSTALL_RPATH "${${PYWRAP}_INSTALL_RPATH}")
endif()

install(TARGETS ${PYWRAP} DESTINATION ${${PYWRAP}_INSTALL_DIR})

fix. https://github.com/stack-of-tasks/eigenpy/issues/353 ref. https://github.com/jrl-umi3218/jrl-cmakemodules/pull/587

nim65s commented 1 year ago

I was especially not inspired for those macro names, so if someone comes with better ones, don't hesitate.

jcarpent commented 1 year ago

What do you mean by relative inverse? This is no meaningful at first glance.

nim65s commented 1 year ago

if the relative path from CMAKE_INSTALL_PREFIX to ${PYWRAP}_INSTALL_DIR is lib/python3.10/site-packages/eigenpy, its "inverse" is ../../../... Or "revert", I don't know.

Or we can just remove this and state this is from ${PYWRAP}_INSTALL_DIR to CMAKE_INSTALL_PREFIX, it would make more sense, thanks

jcarpent commented 1 year ago

Or we can just remove this and state this is from ${PYWRAP}_INSTALL_DIR to CMAKE_INSTALL_PREFIX, it would make more sense, thanks

I don't get the shortcut. Could you explain a bit more?

nim65s commented 1 year ago

I just removed the "inv" part and inverted the formulation.