[geary] Fix detection of Sqlite3 SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER enum in cmake
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary] Fix detection of Sqlite3 SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER enum in cmake
- Date: Mon, 19 Sep 2016 21:41:30 +0000 (UTC)
commit 5a53da3cba9f2308ffc6c582bee9a655704f3eea
Author: Gautier Pelloux-Prayer <gautier+git damsy net>
Date: Mon Sep 19 17:08:48 2016 +0200
Fix detection of Sqlite3 SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER enum in cmake
CMakeLists.txt | 41 +++++++++++++++++++++++++++++----
cmake/FindIntltool.cmake | 4 +-
src/sqlite3-unicodesn/CMakeLists.txt | 6 ++--
src/sqlite3-unicodesn/static.c | 2 +-
4 files changed, 42 insertions(+), 11 deletions(-)
---
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 34fed8f..b23b332 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,11 +86,42 @@ pkg_check_modules(LIBMESSAGINGMENU QUIET messaging-menu>=12.10.2)
pkg_check_modules(ENCHANT QUIET enchant)
-pkg_check_modules(SQLITE311 QUIET sqlite3>=3.11.0)
-pkg_check_modules(SQLITE312 QUIET sqlite3>=3.12.0)
-if (SQLITE311_FOUND AND NOT SQLITE312_FOUND)
- message(WARNING "SQLite 3.11.x found. Ensure it has been compiled with -DSQLITE_ENABLE_FTS3_TOKENIZER or
upgrade to SQLite 3.12.x. See https://bugzilla.gnome.org/show_bug.cgi?id=763203 for details.")
-endif ()
+pkg_check_modules(SQLITE3 sqlite3)
+if (NOT ${SQLITE3_VERSION} VERSION_LESS 3.12)
+ include(CheckSymbolExists)
+ check_symbol_exists(SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER sqlite3.h HAVE_FTS3_TOKENIZER)
+ if (NOT HAVE_FTS3_TOKENIZER)
+ message(FATAL_ERROR "SQLite3 is missing FTS3 tokenizer support. Please compile it with
-DSQLITE_ENABLE_FTS3."
+ " See https://bugzilla.gnome.org/show_bug.cgi?id=763203 for details.")
+ endif()
+else()
+ # detect that the current sqlite3 library has FTS3 support (at run time)
+ include(CMakePushCheckState)
+ include(CheckCSourceRuns)
+ cmake_push_check_state(RESET)
+ set(CMAKE_REQUIRED_LIBRARIES sqlite3)
+ check_c_source_runs("
+ #include <sqlite3.h>
+ #include <stdlib.h>
+ int main() {
+ sqlite3 *db;
+ char tmpfile[] = \"sqliteXXXXXX\";
+ mkstemp(tmpfile);
+ if (sqlite3_open(tmpfile, &db) == SQLITE_OK) {
+ return sqlite3_exec(db, \"CREATE VIRTUAL TABLE mail USING fts3(subject, body);\", 0, 0, 0);
+ }
+ return -1;
+ }
+ " HAVE_FTS3)
+ cmake_pop_check_state()
+ if (NOT HAVE_FTS3)
+ if (${SQLITE3_VERSION} VERSION_LESS 3.11)
+ message(FATAL_ERROR "SQLite3 is missing FTS3 support. Please compile it with
-DSQLITE_ENABLE_FTS3.")
+ else()
+ message(FATAL_ERROR "SQLite3 is missing FTS3 tokenizer support. Please compile it with
-DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_TOKENIZER.")
+ endif()
+ endif()
+endif()
# intl
include(Gettext)
diff --git a/cmake/FindIntltool.cmake b/cmake/FindIntltool.cmake
index 3699bb8..e43a29e 100644
--- a/cmake/FindIntltool.cmake
+++ b/cmake/FindIntltool.cmake
@@ -18,13 +18,13 @@ if (INTLTOOL_MERGE_FOUND)
${CMAKE_CURRENT_SOURCE_DIR}/${appstream_name}.in ${appstream_name}
)
install (FILES ${CMAKE_CURRENT_BINARY_DIR}/${appstream_name} DESTINATION
${CMAKE_INSTALL_PREFIX}/share/appdata)
- endmacro (INTLTOOL_MERGE_DESKTOP appstream_name po_dir)
+ endmacro (INTLTOOL_MERGE_APPDATA appstream_name po_dir)
macro (INTLTOOL_MERGE_DESKTOP desktop_id po_dir)
add_custom_target (geary.desktop ALL
${INTLTOOL_MERGE_EXECUTABLE} --desktop-style ${CMAKE_SOURCE_DIR}/${po_dir}
${CMAKE_CURRENT_SOURCE_DIR}/${desktop_id}.in ${desktop_id}
)
- install (FILES ${CMAKE_CURRENT_BINARY_DIR}/geary.desktop DESTINATION
${CMAKE_INSTALL_PREFIX}/share/applications)
+ install (FILES ${CMAKE_CURRENT_BINARY_DIR}/geary.desktop DESTINATION
${CMAKE_INSTALL_PREFIX}/share/applications)
endmacro (INTLTOOL_MERGE_DESKTOP desktop_id po_dir)
macro (INTLTOOL_MERGE_AUTOSTART_DESKTOP desktop_id po_dir)
add_custom_target (geary-autostart.desktop ALL
diff --git a/src/sqlite3-unicodesn/CMakeLists.txt b/src/sqlite3-unicodesn/CMakeLists.txt
index e531fa2..92eab41 100644
--- a/src/sqlite3-unicodesn/CMakeLists.txt
+++ b/src/sqlite3-unicodesn/CMakeLists.txt
@@ -23,9 +23,9 @@ add_definitions(
-DSQLITE_ENABLE_FTS4_UNICODE61
)
-if (SQLITE312_FOUND)
- message(STATUS "SQLite 3.12 support: ON")
- add_definitions(-DSQLITE_3_12)
+if (HAVE_FTS3_TOKENIZER)
+ message(STATUS "SQLite FTS3 tokenizer support: ON")
+ add_definitions(-DHAVE_FTS3_TOKENIZER)
endif ()
include_directories(
diff --git a/src/sqlite3-unicodesn/static.c b/src/sqlite3-unicodesn/static.c
index df1115f..b9b3dd1 100644
--- a/src/sqlite3-unicodesn/static.c
+++ b/src/sqlite3-unicodesn/static.c
@@ -28,7 +28,7 @@ static int registerTokenizer(
sqlite3_stmt *pStmt;
const char *zSql = "SELECT fts3_tokenizer(?, ?)";
-#ifdef SQLITE_3_12
+#ifdef HAVE_FTS3_TOKENIZER
/* Enable the 2-argument form of fts3_tokenizer in SQLite >= 3.12 */
rc = sqlite3_db_config(db,SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER,1,0);
if( rc!=SQLITE_OK ){
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]