diff --git a/CMakeLists.txt b/CMakeLists.txt index 24abbfa20..4c21ad00c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -374,9 +374,8 @@ if(APPLE) endif(APPLE) endif(USE_BUNDLE AND NOT USE_BUNDLE_DIR) -# Check that we have sqlite3 with FTS5 - if(NOT CMAKE_CROSSCOMPILING) + # Check that we have Qt with sqlite driver set(CMAKE_REQUIRED_FLAGS "-std=c++17") set(CMAKE_REQUIRED_LIBRARIES ${QtCore_LIBRARIES} ${QtSql_LIBRARIES}) check_cxx_source_runs(" @@ -387,12 +386,29 @@ if(NOT CMAKE_CROSSCOMPILING) 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');\"); + q.prepare(\"CREATE TABLE test (test TEXT);\"); 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 + #include + 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() # 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.") endif() -if(NOT SQLITE3_FTS5 AND NOT CMAKE_CROSSCOMPILING) - message(WARNING "sqlite3 must be enabled with FTS5. See: https://www.sqlite.org/fts5.html") +if(NOT CMAKE_CROSSCOMPILING) + 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() if(NOT TAGLIB_VERSION VERSION_GREATER_EQUAL 1.12)