Error linking to target QSQLite with cmake
-
Hello, I am attempting to build a project usingI am attempting to build a CMake project that uses QSQLite. I am using Debian 11 (bullseye) and have installed through the apt server
qtdeclarative5-dev
,libqt5sql5
andlibqt5sql5-sqlite
with no errors.The CMake file uses
find_package(Qt5Sql)
to locate the sql package but fails to find the sqlite install. My pc has thelibqsqlite.so
located in the directory/usr/lib/x86_64-linux-gnu/qt5/plugins/sqldrivers
and theQt5SqlConfig.cmake
is found and located in the/usr/lib/x86_64-linux-gnu/cmake/Qt5Sql
.Qt5SqlConfig.cmake
andQt5SqlConfigVersion.cmake
are the only files located in that directory and there is are no plugins forSQLite
on my system.When I run the cmake (3.22.1) command I get the following error:
CMake Error at CMakeLists.txt:113 (add_executable): Target "dvr" links to target "Qt5::QSQLiteDriverPlugin" but the target was not found. Perhaps a find_package() call is missing for an IMPORTED target, or an ALIAS target is missing?
I found on this Github the
Qt5Sql_QSQLiteDriverPlugin.cmake
file which I copied into the/usr/lib/x86_64-linux-gnu/cmake/Qt5Sql
with theQt5SqlConfig.cmake
with thelibqsqlite.so
file but it also gives an error:CMake Error at CMakeHelpers/FindQt5Sql_QSQLiteDriverPlugin.cmake:3 (_populate_Sql_plugin_properties): _populate_Sql_plugin_properties Macro invoked with incorrect arguments for macro named: _populate_Sql_plugin_properties Call Stack (most recent call first): CMakeLists.txt:103 (find_package)
I changed the
Qt5Sql_QSQLiteDriverPlugin.cmake
file toadd_library(Qt5::QSQLiteDriverPlugin MODULE IMPORTED) # _populate_Sql_plugin_properties(QSQLiteDriverPlugin RELEASE "sqldrivers/libqsqlite.so") _populate_Sql_plugin_properties(RELEASE QSQLiteDriverPlugin "sqldrivers/libqsqlite.so" FALSE) list(APPEND Qt5Sql_PLUGINS Qt5::QSQLiteDriverPlugin)
But this also gives an error:
CMake Error at /usr/lib/x86_64-linux-gnu/cmake/Qt5Sql/Qt5SqlConfig.cmake:228 (set_property): set_property could not find TARGET Qt5::RELESE. Perhaps it has not yet been created. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/Qt5Sql/Qt5Sql_QSQLiteDriverPlugin.cmake:4 (_populate_Sql_plugin_properties) /usr/lib/x86_64-linux-gnu/cmake/Qt5Sql/Qt5SqlConfig.cmake:240 (include) CMakeLists.txt:102 (find_package)
Can someone offer me some wisdom and help in adding sqlite to my program. I would like to stay away from building QT from source and using prebuilt Debian libraries if possible.
Thanks in advance.
-
You do not link against a plugin - it's loaded dynamically during runtime.