Skip to content

fix: remove hardcoded cmake install path#535

Open
khangtpham25 wants to merge 2 commits into
jrl-umi3218:masterfrom
khangtpham25:fix/cmake-install-libdir
Open

fix: remove hardcoded cmake install path#535
khangtpham25 wants to merge 2 commits into
jrl-umi3218:masterfrom
khangtpham25:fix/cmake-install-libdir

Conversation

@khangtpham25

Copy link
Copy Markdown
Contributor

Hi @ThomasDuvinage,

This fix the installation path of mc_rtc_tutorials.

The error happen when CMAKE_INSTALL_PREFIX is usr/ (since mc_rtc is installed through apt), CMAKE_INSTALL_LIBDIR is set to lib/x86_64-linux-gnu/ instead of just lib/. More details can be found here

@arntanguy

arntanguy commented May 26, 2026

Copy link
Copy Markdown
Collaborator

This most likely will break things for Nix builds, I'll double check.

ref: #495 where indeed I never tried mixing installation from packages with cmake builds.

cmake-format messes up comments when reflowing lines that are longer
than the desired length. Disable it entirely, manually formatted
comments are always better.
@arntanguy arntanguy force-pushed the fix/cmake-install-libdir branch from 83a1669 to d1b1c2a Compare June 12, 2026 17:02
@arntanguy

arntanguy commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

My apologies for taking so long to get to it. My latest changes should fix it for both Nix and ubuntu packages.

For a bit of background on the complexities behind this:

  • Historically we were always installing runtime dependencies (controlllers, plugins, etc) in mc_rtc's install prefix.
  • This was done to simplify setup, as then mc_rtc would know at compile time where to load runtime dependencies from: paths relative to its own install prefix (e.g <mc_rtc_prefix>/lib/mc_controllers, etc)
  • src/mc_rtcMacros.cmake provides macros to simplify installing runtime dependencies from user projects. In particular this defines MC_RTC_LIBDIR (resp BINDIR, DOCDIR)
  • This introduces two issues:
    • We are modifying the global install tree. This means that when mc_rtc is installed in a global system path (/usr/local/lib, ...), the user needs to install as sudo as runtime dependencies are installed there too
    • Modifying mc_rtc's install tree is dirty, and is in fact impossible in Nix, as outputs from a derivation are immutable in the Nix store (mc-rtc's path in the nix store is a hash of all inputs that were used to generate it, installing in it would break immutability).

Thus we introduced MC_RTC_HONOR_INSTALL_PREFIX boolean option. When a user project is built with it ON, it modifies mc_rtcMacros behaviour to install runtime dependencies in their own user-provided install prefix (through -DCMAKE_INSTALL_PREFIX). This allows for instance in Nix to have all runtime dependencies in their own install path in the nix store (thus in Nix, MC_RTC_HONOR_INSTALL_PREFIX=ON by default). Note that on other systems such as ubuntu this also allows to have mc_rtc installed system-wide (e.g through apt), but still install your controllers in a custom user install prefix.

But now to add a bit of additional complexity:

  • for FSM states, we still need to know where mc_rtc's default states are for controllers to use them. Actually I'm not sure why this wasn't handled at compile-time, we should probably change this in the future.
  • for reasons I did not fully understand, when building in the Nix sandbox, paths generated by GNUInstallDir are always absolute, that is CMAKE_INSTALL_LIBDIR = CMAKE_INSTALL_FULL_LIBDIR. On other systems, CMAKE_INSTALL_LIBDIR is relative while CMAKE_INSTALL_FULL_LIBDIR is absolute.

@khangtpham25 I have only tested for Nix, could you please confirm that the issue is resolved on your build against ubuntu packages?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants