Skip to content

Use GNUInstallDirs with CACHE variables for install destinations (fixes #1120)#1152

Merged
facontidavide merged 1 commit into
BehaviorTree:masterfrom
wooksong:fix/gnuinstalldirs-cache-install-destinations
Jul 6, 2026
Merged

Use GNUInstallDirs with CACHE variables for install destinations (fixes #1120)#1152
facontidavide merged 1 commit into
BehaviorTree:masterfrom
wooksong:fix/gnuinstalldirs-cache-install-destinations

Conversation

@wooksong

Copy link
Copy Markdown
Contributor

Fixes #1120

Problem

The install destination variables use plain set(), which prevents overriding them from the CMake command line. This blocks Debian/Ubuntu packagers from installing to multiarch directories (e.g. lib/x86_64-linux-gnu).

Solution

include(GNUInstallDirs) with set(... CACHE STRING ...) defaults.

Two override mechanisms:

  • -DBTCPP_LIB_DESTINATION=lib/x86_64-linux-gnu (project-specific)
  • -DCMAKE_INSTALL_LIBDIR=lib/x86_64-linux-gnu (system-wide, standard)

API / ABI / Backward compatibility

No API or ABI changes: this is a build system change only.

  • ROS2/ament builds: unaffected. ament_build.cmake only calls mark_as_advanced() on these variables; ament handles installation separately.
  • Standard Linux: CMAKE_INSTALL_LIBDIR resolves to lib: no change from current behavior.
  • Existing -DBTCPP_LIB_DESTINATION=... usage: still works, CACHE variable takes precedence.

Pre-commit / clang-tidy

Not applicable: this PR changes only CMakeLists.txt. The clang-format and clang-tidy hooks target .cpp/.hpp/.h files only.

Verified

Check Result
Configure (default) BTCPP_LIB_DESTINATION: lib
Build 100% (45 TUs, no warnings)
Install (default) lib/libbehaviortree_cpp.so
Override -DBTCPP_LIB_DESTINATION=custom/lib -> custom/lib/libbehaviortree_cpp.so

Replace hardcoded `set()` with `set(... CACHE STRING ...)` defaulting to
GNUInstallDirs values. This allows Debian/Ubuntu packagers to override
installation directories (e.g. `-DBTCPP_LIB_DESTINATION=lib/x86_64-linux-gnu`)
for multiarch support while preserving backward compatibility.

Fixes BehaviorTree#1120
@wooksong
wooksong force-pushed the fix/gnuinstalldirs-cache-install-destinations branch from 2897351 to c178acb Compare June 26, 2026 14:38
@facontidavide
facontidavide merged commit 4c189d2 into BehaviorTree:master Jul 6, 2026
17 of 27 checks passed
@wooksong
wooksong deleted the fix/gnuinstalldirs-cache-install-destinations branch July 8, 2026 04:25
@SteveMacenski

Copy link
Copy Markdown
Contributor

@facontidavide this breaks the ROS build farm binaries resulting in this conversation ament/ament_cmake#630.

I noted here my workaround to temporarily use the binaries to get going

I would recommend reverting since we cannot set those flags in the ros build farm & this blocks the release of packages that depend on BT.CPP, including Nav2.

facontidavide added a commit that referenced this pull request Jul 22, 2026
The ROS build farm (bloom/debhelper) configures with
-DCMAKE_INSTALL_LIBDIR=lib/<multiarch-triplet>. Since #1152 made the
BTCPP_*_DESTINATION variables honor GNUInstallDirs, farm binaries
installed libbehaviortree_cpp.so to /opt/ros/<distro>/lib/x86_64-linux-gnu,
which breaks ament_export_libraries lookup in downstream packages and is
not on the LD_LIBRARY_PATH set by the ament environment hooks.

Shadow the cache variables with plain set() in the ament build path, so
ROS builds always install to $prefix/lib regardless of
CMAKE_INSTALL_LIBDIR, while standalone builds keep the GNUInstallDirs
override behavior introduced for #1120.

Also add a ros2-lyrical CI job that emulates the build farm flags and
asserts the library lands in $prefix/lib.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
@facontidavide

Copy link
Copy Markdown
Collaborator

@SteveMacenski if my expensive slop generator isn't wrong, PR #1176 should fix the issue.

I will release 4.10.0

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.

Allow overriding installation directories to support multiarch packaging (Debian/Ubuntu) and standalone usage

3 participants