How to configure AMENT_PREFIX_PATH for cross compilation
I am trying to cross compile ROS2 nodes using Emscripten and a custom RMW (to enable communication with other nodes via Javascript). However, when building rmw_implementation
, my custom RMW layer cannot be found. I believe the reason for this is either the ament index is not being installed/copied into the correct location or AMENT_PREFIX_PATH
has not been set correctly. By hacking the CMake, I can see that the index is being searched for under the following paths:
/home/developer/workspace/build/rmw_implementation/ament_cmake_index/share/ament_index/resource_index
/home/developer/workspace/install/rmw_implementation/share/ament_index/resource_index
/home/developer/workspace/install/rosidl_cli/share/ament_index/resource_index
/home/developer/workspace/install/ament_package/share/ament_index/resource_index
/home/developer/workspace/install/ament_index_python/share/ament_index/resource_index
However, currently the only location where the index has been installed is:
/home/developer/emsdk/upstream/emscripten/cache/sysroot/usr/share/ament_index/resource_index
Although I can confirm that setting the environment variable AMENT_PREFIX_PATH
to /home/developer/emsdk/upstream/emscripten/cache/sysroot/usr
works as far as getting this step to compile goes, it feels like a bit of a hack. Is there a cleaner way to have AMENT_PREFIX_PATH
honor either CMAKE_STAGING_PREFIX
, CMAKE_INSTALL_PREFIX
, or CMAKE_FIND_ROOT_PATH
? Alternatively, is there a reason why the index is not available in either of these two directories?
/home/developer/workspace/build/rmw_implementation/ament_cmake_index/share/ament_index/resource_index
/home/developer/workspace/install/rmw_implementation/share/ament_index/resource_index
The following mixin shows how I am enabling cross compilation with Emscripten:
{
"build": {
"emscripten": {
"cmake-args": [
"-DCMAKE_TOOLCHAIN_FILE=/home/developer/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake",
"-DCMAKE_STAGING_PREFIX=/home/developer/emsdk/upstream/emscripten/cache/sysroot/usr",
"-DBUILD_SHARED_LIBS=OFF",
"-DBUILD_TESTING=OFF",
"--no-warn-unused-cli"
],
}
}
}
Asked by allsey87 on 2021-12-27 11:18:43 UTC
Comments
Note that
CMAKE_INSTALL_PREFIX
is actually set to/home/developer/workspace/install/rmw_implementation
, however by settingCMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
toTRUE
from my mixin, the Emscripten toolchain setsCMAKE_INSTALL_PREFIX
to/home/developer/emsdk/upstream/emscripten/cache/sysroot
, which is almost what I want except that it is missing theusr
from the end...Asked by allsey87 on 2021-12-27 11:35:49 UTC
Dropping the
usr
fromCMAKE_STAGING_PREFIX
in my mixin seems to solve the problem, but this all still feels like a bit of a hack to me...Asked by allsey87 on 2021-12-27 11:38:03 UTC