summaryrefslogtreecommitdiffstats
path: root/Auxiliary/bash-completion/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Auxiliary/bash-completion/CMakeLists.txt')
-rw-r--r--Auxiliary/bash-completion/CMakeLists.txt24
1 files changed, 16 insertions, 8 deletions
diff --git a/Auxiliary/bash-completion/CMakeLists.txt b/Auxiliary/bash-completion/CMakeLists.txt
index c0a8899..06d22c2 100644
--- a/Auxiliary/bash-completion/CMakeLists.txt
+++ b/Auxiliary/bash-completion/CMakeLists.txt
@@ -1,8 +1,16 @@
-# Always install completion file in local dir
-# in order to be sure to always be able to install
-# in a local user directory rooted in a single directory.
-# packager should either patch that out or
-# add symlinks to the files in appropriate places
-# /etc/bash_completion.d/
-# DATADIR/completions (may be /usr/share/<package>/completions
-install(FILES cmake cpack ctest DESTINATION ${CMAKE_DATA_DIR}/completions)
+# We need to integrate into the system install, or this will silently fail to
+# accomplish anything at all, and packagers won't even know it exists. Use the
+# `<sharedir>/bash-completion/completions/` hierarchy by default, rooted in
+# CMake's XDGDATA_DIR definition of the sharedir. This works with installation
+# to `/usr` or `/usr/local` (or any prefix which bash-completion is configured
+# with) as well as a simple installation by a local user into their home
+# directory *if* the prefix is `$HOME/.local` since `.local/share/` is part of
+# the bash-completion search path too.
+# For more complex installations, packagers can set CMAKE_BASH_COMP_DIR to
+# another system location.
+
+set(CMAKE_BASH_COMP_DIR_DEFAULT ${CMAKE_XDGDATA_DIR}/bash-completion/completions)
+if (NOT CMAKE_BASH_COMP_DIR)
+ set(CMAKE_BASH_COMP_DIR "${CMAKE_BASH_COMP_DIR_DEFAULT}")
+endif()
+install(FILES cmake cpack ctest DESTINATION ${CMAKE_BASH_COMP_DIR})