[PATCH] Add ability to link to static xapian library in generated xapian-config.cmake
anonymous.maarten at gmail.com
anonymous.maarten at gmail.com
Thu Sep 17 13:45:04 BST 2020
From: Anonymous Maarten <anonymous.maarten at gmail.com>
Hello!
The generated xapian-config.cmake does only support shared xapian
libraries.
The patch below allows using a static/shared xapian library
in a cmake project.
This patch was created to allow linking doxygen to a static xapian.
See https://github.com/doxygen/doxygen/issues/8038 for more details.
Kind regards
Maarten
---
xapian-core/cmake/xapian-config.cmake.in | 13 +++++++++++--
xapian-core/configure.ac | 18 +++++++++++++++++-
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/xapian-core/cmake/xapian-config.cmake.in b/xapian-core/cmake/xapian-config.cmake.in
index e2222aee4285..cc634168b829 100644
--- a/xapian-core/cmake/xapian-config.cmake.in
+++ b/xapian-core/cmake/xapian-config.cmake.in
@@ -1,5 +1,14 @@
SET(prefix "@prefix@")
SET(exec_prefix "@exec_prefix@")
-SET(XAPIAN_LIBRARIES "@libdir@/libxapian at LIBRARY_VERSION_SUFFIX@@SHLIBEXT@" CACHE FILEPATH "Libraries for Xapian")
+SET(XAPIAN_SHARED @XAPIAN_CMAKE_SHARED@ CACHE BOOL "Use shared xapian library")
+SET(XAPIAN_SHARED_LIBRARY "@libdir@/libxapian at LIBRARY_VERSION_SUFFIX@@SHLIBEXT@" CACHE FILEPATH "Shared Xapian library")
+SET(XAPIAN_STATIC_LIBRARY "@libdir@/libxapian at LIBRARY_VERSION_SUFFIX@.a" CACHE FILEPATH "Static Xapian library")
+SET(XAPIAN_STATIC_DEP_LIBS "@XAPIAN_CMAKE_LIBS@" CACHE STRING "Dependencies of static xapian library")
+IF(XAPIAN_SHARED)
+ SET(XAPIAN_LIBRARIES "${XAPIAN_SHARED_LIBRARY}")
+ELSE()
+ FIND_PACKAGE(ZLIB REQUIRED)
+ SET(XAPIAN_LIBRARIES "${XAPIAN_STATIC_LIBRARY};${XAPIAN_STATIC_DEP_LIBS};${ZLIB_LIBRARIES}")
+ENDIF()
SET(XAPIAN_INCLUDE_DIR "@incdir@" CACHE PATH "Include path for Xapian")
-SET(XAPIAN_FOUND "TRUE")
+SET(XAPIAN_FOUND ON)
diff --git a/xapian-core/configure.ac b/xapian-core/configure.ac
index 5e83c87ffef0..357996e299fd 100644
--- a/xapian-core/configure.ac
+++ b/xapian-core/configure.ac
@@ -279,10 +279,21 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
#endif
]])], [msvc=no], [msvc=yes])
+XAPIAN_CMAKE_SHARED=
+AC_SUBST([XAPIAN_CMAKE_SHARED])
+
+if test "$enable_shared" = yes; then
+ XAPIAN_CMAKE_SHARED=ON
+else
+ XAPIAN_CMAKE_SHARED=OFF
+fi
+
XAPIAN_LDFLAGS=
XAPIAN_LIBS=
+XAPIAN_CMAKE_LIBS=
AC_SUBST([XAPIAN_LDFLAGS])
AC_SUBST([XAPIAN_LIBS])
+AC_SUBST([XAPIAN_CMAKE_LIBS])
AC_DEFUN([XAPIAN_TEST_FLAGS_],
[
@@ -504,6 +515,7 @@ AC_SEARCH_LIBS([timer_create], [rt],
#endif]])],
[AC_MSG_RESULT([yes])
XAPIAN_LIBS="$LIBS $XAPIAN_LIBS"
+ XAPIAN_CMAKE_LIBS=";rt$XAPIAN_CMAKE_LIBS"
AC_DEFINE([HAVE_TIMER_CREATE], [1], [Define to 1 if you have the 'timer_create' function.])]
,
[AC_MSG_RESULT([no])
@@ -893,6 +905,7 @@ case $enable_backend_glass$enable_backend_honey in
])
if test x != x"$LIBS" ; then
XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
+ dnl CMake finds zlib itself using FindZLIB.cmake
fi
LIBS=$SAVE_LIBS
@@ -908,6 +921,7 @@ case $enable_backend_glass$enable_backend_honey in
win32_need_lws2_32=1
fi
XAPIAN_LIBS="$XAPIAN_LIBS -lrpcrt4"
+ XAPIAN_CMAKE_LIBS="$XAPIAN_CMAKE_LIBS;rpcrt4"
;;
*)
dnl Check for uuid/uuid.h (e2fsprogs/util-linux-ng) or uuid.h
@@ -921,6 +935,7 @@ case $enable_backend_glass$enable_backend_honey in
])
if test x != x"$LIBS" ; then
XAPIAN_LIBS="$XAPIAN_LIBS $LIBS"
+ XAPIAN_CMAKE_LIBS="$XAPIAN_CMAKE_LIBS;uuid"
fi
], [
dnl Try uuid.h as found on FreeBSD/NetBSD/OpenBSD/AIX, with associated
@@ -1019,6 +1034,7 @@ fi
if test "$win32_need_lws2_32" = 1 ; then
XAPIAN_LIBS="$XAPIAN_LIBS -lws2_32"
+ XAPIAN_CMAKE_LIBS="$XAPIAN_CMAKE_LIBS;ws2_32"
fi
AC_ARG_ENABLE([visibility],
@@ -1059,7 +1075,7 @@ dnl We need to actually check for a declaration as OS X has a dummy
dnl implementation in the library which is not prototyped in any header.
AC_CHECK_DECL([fdatasync(int)], [
SAVE_LIBS=$LIBS
- AC_SEARCH_LIBS([fdatasync], [rt], [XAPIAN_LIBS="$LIBS $XAPIAN_LIBS"])
+ AC_SEARCH_LIBS([fdatasync], [rt], [XAPIAN_LIBS="$LIBS $XAPIAN_LIBS"; XAPIAN_CMAKE_LIBS=";rt;$XAPIAN_CMAKE_LIBS"])
LIBS=$SAVE_LIBS
AC_CHECK_FUNCS([fdatasync])
],
--
2.21.3
More information about the Xapian-devel
mailing list