diff --git a/CMakeLists.txt b/CMakeLists.txt
index 88f73944c..f97cb94c0 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -126,6 +126,28 @@ if(ENABLE_VISUALISATIONS)
add_subdirectory(3rdparty/libprojectm)
endif(ENABLE_VISUALISATIONS)
+# Test whether libsqlite3 is available and if FTS3 is enabled in it
+if(WIN32 OR APPLE)
+ option(STATIC_SQLITE "Compile and use a static sqlite3 library" ON)
+else(WIN32 OR APPLE)
+ try_run(FTS_TEST_RUN FTS_TEST_COMPILE
+ ${CMAKE_CURRENT_BINARY_DIR}/sqlite3_fts_test
+ ${CMAKE_SOURCE_DIR}/cmake/sqlite3_fts_test.cpp
+ CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=sqlite3")
+ if(NOT FTS_TEST_COMPILE OR FTS_TEST_RUN EQUAL 1 OR FTS_TEST_RUN STREQUAL "FAILED_TO_RUN")
+ option(STATIC_SQLITE "Compile and use a static sqlite3 library" ON)
+ else(NOT FTS_TEST_COMPILE OR FTS_TEST_RUN EQUAL 1 OR FTS_TEST_RUN STREQUAL "FAILED_TO_RUN")
+ option(STATIC_SQLITE "Compile and use a static sqlite3 library" OFF)
+ endif(NOT FTS_TEST_COMPILE OR FTS_TEST_RUN EQUAL 1 OR FTS_TEST_RUN STREQUAL "FAILED_TO_RUN")
+endif(WIN32 OR APPLE)
+
+set(HAVE_STATIC_SQLITE ${STATIC_SQLITE})
+if(STATIC_SQLITE)
+ message(STATUS "Building static qsqlite plugin")
+ add_definitions(-DQT_STATICPLUGIN)
+ add_subdirectory(3rdparty/qsqlite)
+endif(STATIC_SQLITE)
+
# Subdirectories
add_subdirectory(3rdparty/qtsingleapplication)
add_subdirectory(3rdparty/qtiocompressor)
@@ -138,12 +160,6 @@ add_subdirectory(tests)
add_subdirectory(dist)
add_subdirectory(debian)
-if (WIN32 OR APPLE)
- message(STATUS "Building static qsqlite plugin")
- add_definitions(-DQT_STATICPLUGIN)
- add_subdirectory(3rdparty/qsqlite)
-endif(WIN32 OR APPLE)
-
# Uninstall support
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
diff --git a/cmake/sqlite3_fts_test.cpp b/cmake/sqlite3_fts_test.cpp
new file mode 100644
index 000000000..7e4873b84
--- /dev/null
+++ b/cmake/sqlite3_fts_test.cpp
@@ -0,0 +1,32 @@
+/* This file is part of Clementine.
+
+ Clementine is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Clementine is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Clementine. If not, see .
+*/
+
+#include
+
+int main(int argc, char** argv) {
+ sqlite3* db;
+
+ int ret = sqlite3_open(":memory:", &db);
+ if (ret)
+ return 1;
+
+ char* error = 0;
+ ret = sqlite3_exec(db, "CREATE VIRTUAL TABLE foo USING fts3()", 0, 0, &error);
+ if (ret != SQLITE_OK)
+ return 1;
+
+ return 0;
+}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 970592ed7..bfd70f056 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -523,10 +523,10 @@ else (APPLE)
endif (APPLE)
# Link against the qsqlite plugin on windows and mac
-if(WIN32 OR APPLE)
+if(HAVE_STATIC_SQLITE)
set(3RDPARTY_SQLITE_LIBRARY qsqlite)
target_link_libraries(clementine_lib qsqlite)
-endif(WIN32 OR APPLE)
+endif(HAVE_STATIC_SQLITE)
add_dependencies(clementine_lib qtsingleapplication)
diff --git a/src/config.h.in b/src/config.h.in
index 09c743dbb..a209b665a 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -36,4 +36,6 @@
#cmakedefine HAVE_LIBXINE
#cmakedefine HAVE_QT_PHONON
+#cmakedefine HAVE_STATIC_SQLITE
+
#endif // CONFIG_H_IN
diff --git a/src/core/database.cpp b/src/core/database.cpp
index 6325d6dd2..ed135fbe9 100644
--- a/src/core/database.cpp
+++ b/src/core/database.cpp
@@ -14,6 +14,7 @@
along with Clementine. If not, see .
*/
+#include "config.h"
#include "database.h"
#include
@@ -215,7 +216,7 @@ void Database::StaticInit() {
sFTSTokenizer->xNext = &Database::FTSNext;
sFTSTokenizer->xClose = &Database::FTSClose;
-#ifndef Q_WS_X11
+#ifdef HAVE_STATIC_SQLITE
// We statically link libqsqlite.dll on windows and mac so these symbols are already
// available
_sqlite3_create_function = sqlite3_create_function;
@@ -226,7 +227,7 @@ void Database::StaticInit() {
_sqlite3_user_data = sqlite3_user_data;
sLoadedSqliteSymbols = true;
return;
-#else // Q_WS_X11
+#else // HAVE_STATIC_SQLITE
QString plugin_path = QLibraryInfo::location(QLibraryInfo::PluginsPath) +
"/sqldrivers/libqsqlite";
diff --git a/src/main.cpp b/src/main.cpp
index feb8a4241..03201bf1e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -55,7 +55,7 @@
#endif
// Load sqlite plugin on windows and mac.
-#ifndef Q_WS_X11
+#ifdef HAVE_STATIC_SQLITE
# include
Q_IMPORT_PLUGIN(qsqlite)
#endif
@@ -110,7 +110,6 @@ int main(int argc, char *argv[]) {
qRegisterMetaType("GstEnginePipeline*");
#endif
-
lastfm::ws::ApiKey = LastFMService::kApiKey;
lastfm::ws::SharedSecret = LastFMService::kSecret;