[Bash-completion-devel] configs for cmake build system
Igor Murzov
e-mail at date.by
Thu Apr 4 09:19:24 UTC 2013
Hi, list :)
I have finally finished integration of cmake configs into
bash-completion. Those configs do pretty much the same
things that pkg-config does. The reason for inclusion of
cmake configs is that some projects use cmake as a build
system and avoid using autotools and pkg-config (most notably
CMake itself).
Here is the patch:
------------------------------------------------------
From b07c113e6746db0d5a2c32d1e91ef90c760987e1 Mon Sep 17 00:00:00 2001
From: Igor Murzov <e-mail at date.by>
Date: Mon, 19 Mar 2012 00:49:57 +0400
Subject: [PATCH] Add config for cmake to bash-completion.
This will allow projects using cmake to get information about
bash-completion. This works much like pkg-config files.
---
.gitignore | 2 ++
Makefile.am | 6 ++++++
bash-completion-config-version.cmake.in | 7 +++++++
bash-completion-config.cmake.in | 11 +++++++++++
configure.ac | 11 ++++++++++-
5 files changed, 36 insertions(+), 1 deletion(-)
create mode 100644 bash-completion-config-version.cmake.in
create mode 100644 bash-completion-config.cmake.in
diff --git a/.gitignore b/.gitignore
index 742b7e3..083411e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,5 @@ doc/*.xml
doc/html*
bash_completion.sh
bash-completion.pc
+bash-completion-config.cmake
+bash-completion-config-version.cmake
diff --git a/Makefile.am b/Makefile.am
index dbbba0c..ea49abb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -11,6 +11,10 @@ profile_DATA = bash_completion.sh
pkgconfigdir = $(datadir)/pkgconfig
pkgconfig_DATA = bash-completion.pc
+cmakeconfigdir = $(libdir)/cmake/$(PACKAGE)/
+cmakeconfig_DATA = bash-completion-config.cmake \
+ bash-completion-config-version.cmake
+
bash_completion.sh: bash_completion.sh.in Makefile
sed -e 's|@pkgdatadir[@]|$(pkgdatadir)|' <$(srcdir)/$@.in >$@
@@ -25,3 +29,5 @@ install-data-hook:
$(DESTDIR)$(pkgdatadir)/bash_completion > $$tmpfile && \
cat $$tmpfile > $(DESTDIR)$(pkgdatadir)/bash_completion && \
rm $$tmpfile
+ sed -i -e 's|\$${prefix}|$(prefix)|' \
+ $(DESTDIR)$(libdir)/cmake/$(PACKAGE)/bash-completion-config.cmake
diff --git a/bash-completion-config-version.cmake.in b/bash-completion-config-version.cmake.in
new file mode 100644
index 0000000..265e075
--- /dev/null
+++ b/bash-completion-config-version.cmake.in
@@ -0,0 +1,7 @@
+set (PACKAGE_VERSION "@VERSION@")
+if (NOT ${PACKAGE_FIND_VERSION} VERSION_GREATER ${PACKAGE_VERSION})
+ set (PACKAGE_VERSION_COMPATIBLE 1)
+ if (${PACKAGE_FIND_VERSION} VERSION_EQUAL ${PACKAGE_VERSION})
+ set (PACKAGE_VERSION_EXACT 1)
+ endif ()
+endif ()
diff --git a/bash-completion-config.cmake.in b/bash-completion-config.cmake.in
new file mode 100644
index 0000000..402b7b6
--- /dev/null
+++ b/bash-completion-config.cmake.in
@@ -0,0 +1,11 @@
+# config file for bash-completion
+# http://bash-completion.alioth.debian.org/
+
+set (BASH_COMPLETION_VERSION "@VERSION@")
+
+set (BASH_COMPLETION_PREFIX "@prefix@")
+set (BASH_COMPLETION_COMPATDIR "@compatdir@")
+set (BASH_COMPLETION_COMPLETIONSDIR "@datarootdir@/@PACKAGE@/completions")
+set (BASH_COMPLETION_HELPERSDIR "@datarootdir@/@PACKAGE@/helpers")
+
+set (BASH_COMPLETION_FOUND "TRUE")
diff --git a/configure.ac b/configure.ac
index 3dd17c6..23d2b4d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,5 +4,14 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip -Wall -Werror])
AC_PROG_LN_S
AC_PROG_MKDIR_P
AC_SUBST(compatdir, $sysconfdir/bash_completion.d)
-AC_CONFIG_FILES([Makefile completions/Makefile doc/Makefile helpers/Makefile test/Makefile bash-completion.pc])
+AC_CONFIG_FILES([
+Makefile
+completions/Makefile
+doc/Makefile
+helpers/Makefile
+test/Makefile
+bash-completion.pc
+bash-completion-config.cmake
+bash-completion-config-version.cmake
+])
AC_OUTPUT
--
1.8.2
------------------------------------------------------
The code is a bit hackish, but i'm not aware of the better way to integrate
cmake configs into autotools. So comments are welcome.
And here is an example of how to use cmake configs to install completion
scripts in the proper path:
------------------------------------------------------
CMakeLists.txt | 7 ++++++
completion/CMakeLists.txt | 3 +++
completion/kcov.bash | 58 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 68 insertions(+)
create mode 100644 completion/CMakeLists.txt
create mode 100644 completion/kcov.bash
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 727e907..66be76f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,6 +21,10 @@ endif(NOT CMAKE_BUILD_TYPE)
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}/cmake)
find_package (PkgConfig REQUIRED)
+find_package (bash-completion)
+if (NOT BASH_COMPLETION_FOUND)
+ message (WARNING "Failed to find bash-completion.")
+endif (NOT BASH_COMPLETION_FOUND)
# ====================================
@@ -41,3 +45,6 @@ set (INSTALL_MAN_PATH DESTINATION ${MAN_DIR})
# ====================================
add_subdirectory (src)
add_subdirectory (doc)
+if (BASH_COMPLETION_FOUND)
+ add_subdirectory (completion)
+endif (BASH_COMPLETION_FOUND)
diff --git a/completion/CMakeLists.txt b/completion/CMakeLists.txt
new file mode 100644
index 0000000..163ff69
--- /dev/null
+++ b/completion/CMakeLists.txt
@@ -0,0 +1,3 @@
+install (FILES kcov.bash
+ DESTINATION ${BASH_COMPLETION_COMPLETIONSDIR}
+ RENAME ${PROJECT_NAME})
------------------------------------------------------
-- Igor
More information about the Bash-completion-devel
mailing list