Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include QtMultimedia (or whatever is needed for QSound) module using CMake

Tags:

cmake

qt

My question probably boils down to "what is the module called".

I'd like to use the QSound class in Qt 5.4 and apparently the "Qt5Multimedia" module is not pulled in alongside QtGui and QtCore when calling

find_package(Qt5Widgets REQUIRED)

So I browse my Qt 5.4 installation (locally on Debian) and in fact find a directory

~/sw/Qt/Qt_5_4/5.4/gcc_64/lib/cmake/Qt5Multimedia

However, naively adding

find_package(Qt5Multimedia REQUIRED)

to my CMakeLists.txt fails with this paraphrasis of "File not found error.":

By not providing "FindQt5Multimedia.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"Qt5Multimedia", but CMake did not find one.

So, within said directory, I ask ls -1 and actually get more than I wanted:

Qt5Multimedia_CameraBinServicePlugin.cmake
Qt5MultimediaConfig.cmake
Qt5MultimediaConfigVersion.cmake
Qt5Multimedia_QAlsaPlugin.cmake
Qt5Multimedia_QGstreamerAudioDecoderServicePlugin.cmake
Qt5Multimedia_QGstreamerCaptureServicePlugin.cmake
Qt5Multimedia_QGstreamerPlayerServicePlugin.cmake
Qt5Multimedia_QM3uPlaylistPlugin.cmake
Qt5Multimedia_QPulseAudioPlugin.cmake

Could any of you tell me, which to take, if any, in order to being able to use the QSound class to play some .wav files?

like image 684
Markus-Hermann Avatar asked Sep 27 '22 21:09

Markus-Hermann


1 Answers

Converting my comment into this answer to close this question:

CMake needs to know where the Qt5 specific files are located. Therefore you should add ~/sw/Qt/Qt_5_4/5.4/gcc_64/ either to the environment variable $CMAKE_PREFIX_PATH or set it using

set(CMAKE_PREFIX_PATH "~/sw/Qt/Qt_5_4/5.4/gcc_64/") 

Then CMake will be able to perform find_package(Qt5Multimedia).

like image 142
m.s. Avatar answered Dec 31 '22 20:12

m.s.