How to configure AMENT_PREFIX_PATH for cross compilation

asked 2021-12-27 10:18:43 -0500

allsey87 gravatar image

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:


However, currently the only location where the index has been installed is:


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?


The following mixin shows how I am enabling cross compilation with Emscripten:

    "build": {
        "emscripten": {
            "cmake-args": [
edit retag flag offensive close merge delete


Note that CMAKE_INSTALL_PREFIX is actually set to /home/developer/workspace/install/rmw_implementation, however by setting CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT to TRUE from my mixin, the Emscripten toolchain sets CMAKE_INSTALL_PREFIX to /home/developer/emsdk/upstream/emscripten/cache/sysroot, which is almost what I want except that it is missing the usr from the end...

allsey87 gravatar image allsey87  ( 2021-12-27 10:35:49 -0500 )edit

Dropping the usr from CMAKE_STAGING_PREFIX in my mixin seems to solve the problem, but this all still feels like a bit of a hack to me...

allsey87 gravatar image allsey87  ( 2021-12-27 10:38:03 -0500 )edit