Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get path of Qt 5 additional plugins

In a Qt 4 project, I build a Windows installer using Inno Setup. The 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 migrate to Qt5. Everything works fine, but I can't find pre-defined variables to get Qt5 equivalent for these plugins paths. Of course, I could hardcode them, but I am looking for a way to define it in a clean and independent way.

like image 391
Antwane Avatar asked Jan 06 '13 15:01

Antwane


1 Answers

Qt5 no longer relies on a CMake module file to find the Qt5 installation, but provides its own CMake config file, which sets up the Qt5 libraries as imported CMake targets. To obtain the actual path to the Qt module library file, query the LOCATION property of the module's CMake target or its config specific variant LOCATION_<Config> version, e.g.:

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 probably also applies to Qt plugins, provided you know the plugin's CMake target name (I haven't verified that).

Also see the Qt5 CMake manual.

like image 158
sakra Avatar answered Oct 20 '22 19:10

sakra