Get the way to additional Qt 5 plugins

In a Qt 4 project, I create a Windows installer using Inno Setup. Required libraries (qsqlite.dll, qjpeg4.dll, etc.) are included in the script with CMake variables such as QT_QSQLITE_PLUGIN_RELEASE or QT_QJPEG_PLUGIN_RELEASE .

ex: setup.iss.in:

 [Files] Source: "myapp.exe"; DestDir: {app} Source: "${QT_QSQLITE_PLUGIN_RELEASE}"; DestDir: {app}/sqldrivers Source: "${QT_QJPEG_PLUGIN_RELEASE}"; DestDir: {app}/imageformats 

Now the project should switch to Qt5. Everything works fine, but I cannot find the predefined variables to get the Qt5 equivalent for these plugin paths. Of course, I could hardcode them, but I'm looking for a way to define it in a clean and independent way.

+6
source share
3 answers

As in Qt 5.2, plugins are available as IMPORTED targets:

http://doc.qt.io/qt-5/cmake-manual.html#imported-targets

https://codereview.qt-project.org/#change,63100

Read the LOCATION property from IMPORTED targets, not the configuration-specific LOCATION_ property. CMake will handle the configuration part.

+4
source

Qt5 no longer relies on a CMake module file to find a Qt5 installation, but provides its own CMake configuration file, which installs Qt5 libraries as imported CMake targets. To get the actual path to the Qt module library file, request the LOCATION property for the CMake target object or its configuration version version LOCATION_<Config> , for example:

 find_package(Qt5Core) get_target_property(QtCore_location_Release Qt5::Core LOCATION_Release) find_package(Qt5Widgets) get_target_property(QtWidgets_location_Release Qt5::Widgets LOCATION_Release) 

This strategy is probably also applicable to Qt plugins if you know the target name of the CMake plugin (I have not confirmed this yet).

Also see the Qt5 CMake manual.

+11
source

Based on steveire's answer, you will get absolute paths to the QSqlite and QJpeg plugins:

 find_package(Qt5Gui) find_package(Qt5Sql) get_target_property(qsqlite_loc Qt5::QSQLiteDriverPlugin LOCATION_Release) message("QSqlite DLL: ${qsqlite_loc}") get_target_property(qjpeg_loc Qt5::QJpegPlugin LOCATION_Release) message("QJpeg DLL: ${qjpeg_loc}") 
0
source

All Articles