What package do I need to build a Qt 5 & CMake application?

I just stumbled upon this question while trying to compile KeePassX 2.0.

What helped me was to use apt-file to search for the missing packages:

For example running this:

apt-file search Qt5CoreConfig.cmake

Returned the following packages:

qtbase5-dev: /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreConfig.cmake

qtbase5-gles-dev: /usr/lib/x86_64-linux-gnu/cmake/Qt5Core/Qt5CoreConfig.cmake

These packages can then be installed with apt or apt-get, e.g.:

sudo apt install qtbase5-dev


Two things I was missing:

  • After an unsuccessful build, I must remove CMakeCache.txt (or simply clear the build directory); otherwise cmake will report the same error even if the needed package has been installed.

  • The packages which provide the *.cmake configuration files have names of the form qt*5-dev, e.g. for the error in my question, qtcore5-dev.


If you tried the above solutions and it didn't work, also try apt-get install libqt5opengl5-dev, that worked for me.