Vcpkg: Question: could we customize the CMAKE_INSTALL_PREFIX when configure cmake.

Created on 8 Jul 2019  路  4Comments  路  Source: microsoft/vcpkg

I am working on using vcpkg to build the ROS packages, the thing is that the ROS packages will use customize CMAKE_INSTALL_PREFIX sometimes to locate the ROS related pacakge.

As you can see in this demo: https://github.com/ros2/ros_workspace/blob/latest/CMakeLists.txt#L11. We cannot set AMENT_PACKAGE_TEMPLATE_DIR successfully if we trigger vcpkg_configure_cmake, because vcpkg will alway overwrite CMAKE_ISNTALL_PREFIX in this line

I wonder if vcpkg could add an option allow user to customize CMAKE_INSTALL_PREFIX rather than set it via -DCMAKE_INSTALL_PREFIX=${CURRENT_PACKAGES_DIR.

question

All 4 comments

I guess that customizing CMAKE_INSTALL_PREFIX in vcpkg would be quite difficult, as in vcpkg the port install in vcpkg/packages/<port>_<triplet>, but then for actual use vcpkg itself (not the port build system) moves all the files in vcpkg/installed/<triplet>, so using a CMAKE_INSTALL_PREFIX different from vcpkg/packages/<port>_<triplet> would break this logic.

However, related to your specific use case, the problem seems that the ros_workspace package has the hardcoded assumption that the python ament_package is installed in the same prefix in which ros_workspace it will be installed. This may be true when building ROS2 for source using colcon, but when building the packages via vcpkg I am afraid it cannot be true. Have you considered the possibility of modifying the ros_workspace to find the installation prefix of ament_package in a more flexible way. The most basic change that would enable that is permit to set the AMENT_PACKAGE_TEMPLATE_DIR variable via CMake options, so that packages can specify manually the actual install prefix of ament_package.

@traversaro Yes, if we change CMAKE_INSTALL_PREFIX, we could break the vcpkg's internal logic.

There are some ROS2's packages are using CMAKE_INSTALL_PREFIX to locate some dependencies. And ROS2 also use AMENT_PREFIX_PATH to locate the dependencies sometimes. These two cmake options play the same part job for locating. In my opinion, the CMAKE_INSTALL_PREFIX should only play a part for setting install location.
So if we can find out the packages which use CMAKE_INSTALL_PREFIX and replace it to AMENT_PREFIX_PATH, it will be more easier to use vcpkg to build ROS2 packages and pack it.

In the specific case of ament_package that is also a python package, perhaps it could make sense to use the python interpreter itself to import the package and find its prefix. However, probably it could make sense to open an issue regarding this in https://github.com/ros2/ros_workspace, as the issue is not vcpkg-specific.

@traversaro Thanks for your advice. The ament_pacakge is a python package but is not installed into the default system PYTHONPATH. When we compile the ROS packages, we will append custom python's Lib/site-packages to PYTHONPATH. So your thought could be a solution.

For now, I am trying to pass CMAKE_PREFIX_PATH or AMENT_PREFIX_PATH to replace CMAKE_INSTALL_PREFIX when ROS's packages use CMAKE_INSTALL_PREFIX to locate dependencies. My lab is still work in process, but I am going to close this issue since the problem seem to be ROS-related.

Was this page helpful?
0 / 5 - 0 ratings