Skip to content

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

Open
wooksong wants to merge 1 commit into
BehaviorTree:masterfrom
wooksong:fix/gnuinstalldirs-cache-install-destinations
Open

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

Conversation

@wooksong

Copy link
Copy Markdown

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
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

1 participant