Use GNUInstallDirs with CACHE variables for install destinations (fixes #1120)#1152
Merged
facontidavide merged 1 commit intoJul 6, 2026
Conversation
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
force-pushed
the
fix/gnuinstalldirs-cache-install-destinations
branch
from
June 26, 2026 14:38
2897351 to
c178acb
Compare
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>
Collaborator
|
@SteveMacenski if my expensive slop generator isn't wrong, PR #1176 should fix the issue. I will release 4.10.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)withset(... 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.
ament_build.cmakeonly callsmark_as_advanced()on these variables; ament handles installation separately.CMAKE_INSTALL_LIBDIRresolves tolib: no change from current behavior.-DBTCPP_LIB_DESTINATION=...usage: still works, CACHE variable takes precedence.Pre-commit / clang-tidy
Not applicable: this PR changes only
CMakeLists.txt. Theclang-formatandclang-tidyhooks target.cpp/.hpp/.hfiles only.Verified
BTCPP_LIB_DESTINATION: liblib/libbehaviortree_cpp.so-DBTCPP_LIB_DESTINATION=custom/lib->custom/lib/libbehaviortree_cpp.so