summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-04-19 22:03:37 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-04-28 09:56:32 +0200
commit27c850b2ea3d004b380921de6664c50e6d54d4f5 (patch)
tree222f6237e2755336a35ae27152b8fc6983e9db60
parentd2199ca8e63365c2d1f03b88a7f6042b6d3c171d (diff)
Fix determining ZXING_CFLAGS for --with-system-zxing
While at least Linux distros typically provide the zxing include files in a dedicated ZXing sub-directory (i.e., /usr/include/ZXing/), the bundled external/zxing does not (it rather provides them in workdir/UnpackedTarball/zxing/core/src/, cf. RepositoryExternal.mk). Therefore, source files like cui/source/dialogs/QrCodeGenDialog.cxx #include <BarcodeFormat.h> etc. rather than #include <ZXing/BarcodeFormat.h> etc., and for --with-system-zxing ad92c7dfa64c9e08aa2bcf612a9a4a68e9deae22 "fix system zxing build" simply hardcoded ZXING_CFLAGS=-I/usr/include/ZXing (i.e., the typical location for these include files). However, for e.g. a Fedora Flatpak-from-RPM build of --with-system-zxing LibreOffice, the include files will be in /app/include/ZXing/ rather than in /usr/include/ZXing/. (And which AC_CHECK_HEADER would find via CPLUS_INCLUDE_PATH containing /app/include for such a build. But the hardcoded ZXING_CFLAGS then caused compiling e.g. cui/source/dialogs/QrCodeGenDialog.cxx to fail because it didn't find BarcodeFormat.h etc. in the hardcoded /usr/include/ZXing/.) So when checking for the sample zxing include file (MultiFormatWriter.h), try any $CPLUS_INCLUDE_PATH paths one by one (and with a fallback to /usr/include). (The explicit unset ac_cv_header_MultiFormatWriter_h is needed so that the second and later iterations of the for loop don't erroneously reuse a cached "no" result.) Change-Id: Id85f9960ffd3759c7960ef3a81982b85bc3c04c1 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133189 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--configure.ac28
1 files changed, 25 insertions, 3 deletions
diff --git a/configure.ac b/configure.ac
index 1d432bc77a7b..a43d6bddd344 100644
--- a/configure.ac
+++ b/configure.ac
@@ -11143,10 +11143,32 @@ else
if test "$with_system_zxing" = "yes"; then
AC_MSG_RESULT([external])
SYSTEM_ZXING=TRUE
+ ZXING_CFLAGS=
AC_LANG_PUSH([C++])
- AC_CHECK_HEADER(ZXing/MultiFormatWriter.h, [],
- [AC_MSG_ERROR(zxing headers not found.)], [#include <stdexcept>])
- ZXING_CFLAGS=-I/usr/include/ZXing
+ save_CXXFLAGS=$CXXFLAGS
+ save_IFS=$IFS
+ IFS=$P_SEP
+ for i in $CPLUS_INCLUDE_PATH /usr/include; do
+ dnl Reset IFS as soon as possible, to avoid unexpected side effects (and the
+ dnl "/usr/include" fallback makes sure we get here at least once; resetting rather than
+ dnl unsetting follows the advice at <http://git.savannah.gnu.org/gitweb/?p=autoconf.git;
+ dnl a=commit;h=e51c9919f2cf70185b7916ac040bc0bbfd0f743b> "Add recommendation on (not)
+ dnl unsetting IFS."):
+ IFS=$save_IFS
+ dnl TODO: GCC and Clang treat empty paths in CPLUS_INCLUDE_PATH like ".", but we simply
+ dnl ignore them here:
+ if test -z "$i"; then
+ continue
+ fi
+ dnl TODO: White space in $i would cause problems:
+ CXXFLAGS="$save_CXXFLAGS -I$i/ZXing"
+ AC_CHECK_HEADER(MultiFormatWriter.h, [ZXING_CFLAGS=-I$i/ZXing; break],
+ [unset ac_cv_header_MultiFormatWriter_h], [#include <stdexcept>])
+ done
+ CXXFLAGS=$save_CXXFLAGS
+ if test -z "$ZXING_CFLAGS"; then
+ AC_MSG_ERROR(zxing headers not found.)
+ fi
AC_CHECK_LIB([ZXing], [main], [ZXING_LIBS=-lZXing],
[ AC_CHECK_LIB([ZXingCore], [main], [ZXING_LIBS=-lZXingCore],
[ AC_MSG_ERROR(zxing C++ library not found.) ])], [])