How to properly set AMENT_PREFIX_PATH?
Hi,
I have some doubts about how AMENT_PREFIX_PATH
and CMAKE_PREFIX_PATH
should be set.
According to the ament design documentation http://design.ros2.org/articles/ament...
Therefore ament uses a separate environment variable (AMENT_PREFIX_PATH) for that purpose which is used at runtime. At build time of CMake packages the CMake specific variable can be derived from the generic ament variable.
Now an example where I'm having issues.
I'm cross-compiling some ROS2 packages.
Thus I have a directory ~/sysroot
which contains all the library/headers/binaries of my target system.
This directory also contains a cross-compiled ROS2 SDK.
The cross-compiled ROS2 libraries and headers are respectively located in ~/sysroot/usr/lib
and ~/sysroot/usr/include
together with the system ones.
I cross-compiled the ROS2 SDK, before adding it to the sysroot, without specifying the AMENT_PREFIX_PATH
. In this way the compiler was able to correctly find the needed libraries in the sysroot (e.g. Python).
When I want to cross-compile an additional package, I need to set AMENT_PREFIX_PATH=~/sysroot/usr
to allow the compiler to find the already cross-compiled packages. Leaving this empty results in not finding the required ROS2 dependencies.
However, if my packages require Python, this is not found.
A solution I found is to set the path to the following
AMENT_PREFIX_PATH="~/sysroot/usr;~/sysroot/usr/bin
This works: both Python as well as the ROS2 dependencies are found. However I'm getting a warning:
[0.280s] WARNING:colcon.colcon_ros.prefix_path.ament:The path '/root/sysroot/bin' in the environment variable AMENT_PREFIX_PATH doesn't exist
My intuition is that there could be something strange going on between AMENT_PREFIX_PATH
and how CMAKE_PREFIX_PATH
is automatically set.
Do you have any idea about what's going on?