lib: centralize xapian include, enable move semantics

Only include xapian.h in one place, so we can have consistent options.
With that in place, we can enable C++ move semantics.

We don't do anything with that yet, but we check in the meson.build file
to see if we have the required xapian version.
This commit is contained in:
Dirk-Jan C. Binnema
2024-04-30 19:29:16 +03:00
parent 32bb79b316
commit 5a48664033
12 changed files with 30 additions and 30 deletions

View File

@ -19,7 +19,6 @@
#ifndef MU_DOCUMENT_HH__ #ifndef MU_DOCUMENT_HH__
#define MU_DOCUMENT_HH__ #define MU_DOCUMENT_HH__
#include <xapian.h>
#include <utility> #include <utility>
#include <string> #include <string>
#include <vector> #include <vector>

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2022-2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2022-2024 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -24,7 +24,7 @@
#include <string_view> #include <string_view>
#include <algorithm> #include <algorithm>
#include <array> #include <array>
#include <xapian.h> #include <mu-xapian-db.hh>
#include <utils/mu-utils.hh> #include <utils/mu-utils.hh>
#include <utils/mu-option.hh> #include <utils/mu-option.hh>

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2022-2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2022-2024 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -25,6 +25,8 @@
#include <vector> #include <vector>
#include <iostream> #include <iostream>
#include "mu-xapian-db.hh"
#include "mu-contact.hh" #include "mu-contact.hh"
#include "mu-priority.hh" #include "mu-priority.hh"
#include "mu-flags.hh" #include "mu-flags.hh"
@ -33,8 +35,6 @@
#include "mu-message-part.hh" #include "mu-message-part.hh"
#include "mu-message-file.hh" #include "mu-message-file.hh"
#include <xapian.h>
#include "utils/mu-utils.hh" #include "utils/mu-utils.hh"
#include "utils/mu-option.hh" #include "utils/mu-option.hh"
#include "utils/mu-result.hh" #include "utils/mu-result.hh"

View File

@ -29,8 +29,6 @@
#include <variant> #include <variant>
#include <unordered_map> #include <unordered_map>
#include <xapian.h>
#include "mu-xapian-db.hh" #include "mu-xapian-db.hh"
#include <utils/mu-utils.hh> #include <utils/mu-utils.hh>

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2021 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2021-2024 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -24,7 +24,7 @@
#include <unordered_map> #include <unordered_map>
#include <memory> #include <memory>
#include <xapian.h> #include "mu-xapian-db.hh"
#include "mu-query-results.hh" #include "mu-query-results.hh"

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2023-2024 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -16,11 +16,9 @@
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
** **
*/ */
#include <memory>
#include <string> #include <string>
#include <array>
#include <xapian.h> #include "mu-xapian-db.hh"
#include "utils/mu-sexp.hh" #include "utils/mu-sexp.hh"
#include "utils/mu-result.hh" #include "utils/mu-result.hh"

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2022 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2022-2024 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify it ** This program is free software; you can redistribute it and/or modify it
** under the terms of the GNU General Public License as published by the ** under the terms of the GNU General Public License as published by the
@ -33,12 +33,11 @@
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <xapian.h>
#include <glib.h> #include <glib.h>
#include <mu-xapian-db.hh>
#include <utils/mu-utils.hh> #include <utils/mu-utils.hh>
#include <utils/mu-option.hh> #include <utils/mu-option.hh>
#include <mu-xapian-db.hh>
#include <message/mu-message.hh> #include <message/mu-message.hh>

View File

@ -1,5 +1,5 @@
/* /*
** Copyright (C) 2008-2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl> ** Copyright (C) 2008-2024 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
** **
** This program is free software; you can redistribute it and/or modify ** This program is free software; you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by ** it under the terms of the GNU General Public License as published by
@ -26,13 +26,12 @@
#include <cmath> #include <cmath>
#include <stdlib.h> #include <stdlib.h>
#include <xapian.h>
#include <glib/gstdio.h> #include <glib/gstdio.h>
#include "mu-xapian-db.hh"
#include "mu-query-results.hh" #include "mu-query-results.hh"
#include "mu-query-match-deciders.hh" #include "mu-query-match-deciders.hh"
#include "mu-query-threads.hh" #include "mu-query-threads.hh"
#include "mu-xapian-db.hh"
#include "mu-query-parser.hh" #include "mu-query-parser.hh"

View File

@ -26,8 +26,6 @@
#include <ctime> #include <ctime>
#include <memory> #include <memory>
#include <xapian.h>
#include "mu-contacts-cache.hh" #include "mu-contacts-cache.hh"
#include "mu-xapian-db.hh" #include "mu-xapian-db.hh"
#include "mu-config.hh" #include "mu-config.hh"

View File

@ -29,10 +29,17 @@
#include <glib.h> #include <glib.h>
#include <xapian.h>
#include <utils/mu-result.hh> #include <utils/mu-result.hh>
#include <utils/mu-utils.hh> #include <utils/mu-utils.hh>
/* starting with 1.4.6, Xapian supports C++ move semantics,
* but only with XAPIAN_MOVE_SEMANTICS defined
*/
#ifndef XAPIAN_MOVE_SEMANTICS
#define XAPIAN_MOVE_SEMANTICS
#endif /*XAPIAN_MOVE_SEMANTICS*/
#include <xapian.h>
namespace Mu { namespace Mu {
// LCOV_EXCL_START // LCOV_EXCL_START

View File

@ -191,13 +191,16 @@ gio_unix_dep = dependency('gio-unix-2.0', version: '>= 2.60')
gmime_dep = dependency('gmime-3.0', version: '>= 3.2') gmime_dep = dependency('gmime-3.0', version: '>= 3.2')
thread_dep = dependency('threads') thread_dep = dependency('threads')
# we need Xapian 1.4; if we have 1.4.23, we have some newer APIs. # we need Xapian 1.4
xapian_dep = dependency('xapian-core', version:'>= 1.4.23', required:false) xapian_dep = dependency('xapian-core', version:'>= 1.4', required:true)
if xapian_dep.found() xapver = xapian_dep.version()
if xapver.version_compare('>= 1.4.6')
message('xapian ' + xapver + ' supports c++ move-semantics')
config_h_data.set('HAVE_XAPIAN_MOVE_SEMANTICS', 1)
endif
if xapver.version_compare('>= 1.4.23')
message('xapian ' + xapver + ' supports ngrams')
config_h_data.set('HAVE_XAPIAN_FLAG_NGRAMS', 1) config_h_data.set('HAVE_XAPIAN_FLAG_NGRAMS', 1)
else
xapian_dep = dependency('xapian-core', version:'>= 1.4')
message('Found xapian ' + xapian_dep.version())
endif endif
# optionally, use Compact Language Detector2 if we can find it. # optionally, use Compact Language Detector2 if we can find it.

View File

@ -21,7 +21,6 @@
#include "mu-cmd.hh" #include "mu-cmd.hh"
#include <message/mu-message.hh> #include <message/mu-message.hh>
#include <xapian.h>
#include "utils/mu-utils.hh" #include "utils/mu-utils.hh"
#include <glib.h> #include <glib.h>