Use GNUInstallDirs with CACHE variables for install destinations (fixes #1120)#1152
Open
wooksong wants to merge 1 commit into
Open
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
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