Add CMake test for Qt sqlite support

This commit is contained in:
jonas@jkvinge.net 2021-05-13 00:18:06 +02:00
parent efcd35d4a1
commit 5bdbc9f40d
1 changed files with 28 additions and 6 deletions

View File

@ -374,9 +374,8 @@ if(APPLE)
endif(APPLE) endif(APPLE)
endif(USE_BUNDLE AND NOT USE_BUNDLE_DIR) endif(USE_BUNDLE AND NOT USE_BUNDLE_DIR)
# Check that we have sqlite3 with FTS5
if(NOT CMAKE_CROSSCOMPILING) if(NOT CMAKE_CROSSCOMPILING)
# Check that we have Qt with sqlite driver
set(CMAKE_REQUIRED_FLAGS "-std=c++17") set(CMAKE_REQUIRED_FLAGS "-std=c++17")
set(CMAKE_REQUIRED_LIBRARIES ${QtCore_LIBRARIES} ${QtSql_LIBRARIES}) set(CMAKE_REQUIRED_LIBRARIES ${QtCore_LIBRARIES} ${QtSql_LIBRARIES})
check_cxx_source_runs(" check_cxx_source_runs("
@ -387,12 +386,29 @@ if(NOT CMAKE_CROSSCOMPILING)
db.setDatabaseName(\":memory:\"); db.setDatabaseName(\":memory:\");
if (!db.open()) { return 1; } if (!db.open()) { return 1; }
QSqlQuery q(db); QSqlQuery q(db);
q.prepare(\"CREATE VIRTUAL TABLE test_fts USING fts5(test, tokenize = 'unicode61 remove_diacritics 0');\"); q.prepare(\"CREATE TABLE test (test TEXT);\");
if (!q.exec()) return 1; if (!q.exec()) return 1;
} }
" "
SQLITE3_FTS5 QT_SQLITE_TEST
) )
if(QT_SQLITE_TEST)
# Check that we have sqlite3 with FTS5
check_cxx_source_runs("
#include <QSqlDatabase>
#include <QSqlQuery>
int main() {
QSqlDatabase db = QSqlDatabase::addDatabase(\"QSQLITE\");
db.setDatabaseName(\":memory:\");
if (!db.open()) { return 1; }
QSqlQuery q(db);
q.prepare(\"CREATE VIRTUAL TABLE test_fts USING fts5(test, tokenize = 'unicode61 remove_diacritics 0');\");
if (!q.exec()) return 1;
}
"
SQLITE_FTS5_TEST
)
endif()
endif() endif()
# Set up definitions # Set up definitions
@ -439,8 +455,14 @@ elseif(NOT HAVE_GSTREAMER)
message(WARNING "GStreamer is the only engine that is fully implemented. Using other engines is possible but not recommended.") message(WARNING "GStreamer is the only engine that is fully implemented. Using other engines is possible but not recommended.")
endif() endif()
if(NOT SQLITE3_FTS5 AND NOT CMAKE_CROSSCOMPILING) if(NOT CMAKE_CROSSCOMPILING)
message(WARNING "sqlite3 must be enabled with FTS5. See: https://www.sqlite.org/fts5.html") if(QT_SQLITE_TEST)
if(NOT SQLITE_FTS5_TEST)
message(WARNING "sqlite must be enabled with FTS5. See: https://www.sqlite.org/fts5.html")
endif()
else()
message(WARNING "The Qt sqlite driver test failed.")
endif()
endif() endif()
if(NOT TAGLIB_VERSION VERSION_GREATER_EQUAL 1.12) if(NOT TAGLIB_VERSION VERSION_GREATER_EQUAL 1.12)