[Bash-completion-devel] configs for cmake build system
Igor Murzov
e-mail at date.by
Fri Apr 5 16:33:17 UTC 2013
On Thu, 04 Apr 2013 16:32:24 +0300
Ville Skyttä <ville.skytta at iki.fi> wrote:
> On 2013-04-04 12:19, Igor Murzov wrote:
> > Hi, list :)
>
> Hi from a cmake n00b, just a couple of quick comments:
>
> > +cmakeconfigdir = $(libdir)/cmake/$(PACKAGE)/
>
> This doesn't sound quite right to me, wouldn't somewhere in $(datadir)
> be more appropriate?
Technically, this doesn't matter where to put cmake configs,
until cmake can find them. But since bash-completion is 'noarch',
$(datadir) looks more appropriate. So i fixed this path.
> > + sed -i -e 's|\$${prefix}|$(prefix)|' \
> > + $(DESTDIR)$(libdir)/cmake/$(PACKAGE)/bash-completion-config.cmake
>
> See the existing code in install-data-hook for a portable way to
> accomplish this -- the -i arg to sed is non-portable.
Fixed :)
> > +cmakeconfig_DATA = bash-completion-config.cmake \
> > + bash-completion-config-version.cmake
>
> This (and the dir above) naming convention seems different from other
> cmake things I have around, BashCompletion would look more similar.
I personally dislike naming it 'BashCompletion'. It's a bit difficult
for me to read all these camel-case names. Moreover, if the config
is named 'BashCompletionConfig.cmake', then it has to name variables
like this: BASHCOMPLETION_COMPLETIONSDIR, which i find too hard to
read.
Moreover, both
find_package(Bash-Completion)
and
find_package(bash-completion)
work fine with bash-completion-config.cmake, but
BashCompletionConfig.cmake can be found only by
find_package(BashCompletion)
IMO, since project is officially called 'bash-completion',
`find_package(bash-completion)` should work :)
Here is a v2:
-------------------------------------------------------
From 0d6728e409083bbe6927bf9e53a58f1ccdcd588d 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 | 11 ++++++++++-
bash-completion-config-version.cmake.in | 7 +++++++
bash-completion-config.cmake.in | 11 +++++++++++
configure.ac | 11 ++++++++++-
5 files changed, 40 insertions(+), 2 deletions(-)
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..b9e865e 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 = $(datadir)/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 >$@
@@ -22,6 +26,11 @@ EXTRA_DIST = CHANGES $(sysconf_DATA) $(pkgdata_DATA) bash_completion.sh.in \
install-data-hook:
tmpfile=`mktemp $${TMPDIR:-/tmp}/bash_completion.XXXXXX` && \
sed -e 's|=/etc/bash_completion\.d|=$(compatdir)|' \
- $(DESTDIR)$(pkgdatadir)/bash_completion > $$tmpfile && \
+ $(DESTDIR)$(pkgdatadir)/bash_completion > $$tmpfile && \
cat $$tmpfile > $(DESTDIR)$(pkgdatadir)/bash_completion && \
+ sed -e 's|\$${prefix}|$(prefix)|' \
+ $(DESTDIR)$(datadir)/cmake/$(PACKAGE)/bash-completion-config.cmake \
+ > $$tmpfile && \
+ cat $$tmpfile > \
+ $(DESTDIR)$(datadir)/cmake/$(PACKAGE)/bash-completion-config.cmake && \
rm $$tmpfile
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
-------------------------------------------------------
-- Igor
More information about the Bash-completion-devel
mailing list