37

I don't know a lot about cmake, I'm trying to build a client using cmake and Qt. Getting the following error:

CMake Error at alethzero/CMakeLists.txt:26 (find_package): By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Qt5Widgets", but CMake did not find one.

Could not find a package configuration file provided by "Qt5Widgets" with any of the following names:

Qt5WidgetsConfig.cmake
qt5widgets-config.cmake

Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set "Qt5Widgets_DIR" to a directory containing one of the above files. If "Qt5Widgets" provides a separate development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred!

As far as I understand, I need to add the QT path to CMake. How do I do it? I have Qt installed in /home/user/Programs. All the explanations I find are "just do this or that". I need the exact Terminal commands so I can just learn how to do it in the future.

Thanks!

UPDATE: export CMAKE_PREFIX_PATH=/home/user/Programs did not help me.

JohnAllen
  • 7,317
  • 9
  • 41
  • 65
user3386675
  • 371
  • 1
  • 3
  • 4
  • Also, if you don't have QT on Ubuntu you can install it using `sudo apt-get install qt5-default` – Viliami Feb 06 '19 at 23:22

5 Answers5

21

Well, here you have a solution for Windows: How to find qt5 CMake module on windows

set (CMAKE_PREFIX_PATH "C:\\Qt\\Qt5.0.1\\5.0.1\\msvc2010\\")

For your environment, I think you will have to change the path where Qt is located...

Maybe this will help you:
https://github.com/Cockatrice/Cockatrice/issues/205

Community
  • 1
  • 1
lmiguelmh
  • 3,074
  • 1
  • 37
  • 53
  • 3
    it worked really good answer. why did they gave you a minus i don't get it. the answer didn't work. but yours did – Hani Goc Mar 06 '15 at 15:54
  • 1
    Maybe you could give +1 :) ... Well I think is because this answer is only for Windows, and it appears that the OP is using Linux. At the end the only change will be the path... – lmiguelmh Mar 06 '15 at 16:08
  • for unknown reasons with cmake 3.10. It has not worked, I had to export the variable in shell. – sancelot Mar 28 '18 at 14:37
16

This is documented:

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

The easiest way to use CMake is to set the CMAKE_PREFIX_PATH 
environment variable to the install prefix of Qt 5

Do this

export CMAKE_PREFIX_PATH=/home/user/Programs/<other_stuff>

where references the compiler etc, so that this complete path is valid:

/home/user/Programs/<other_stuff>/bin/qmake*
steveire
  • 10,694
  • 1
  • 37
  • 48
  • 2
    Thank you! I have done that before and I'm still getting the same result. Maybe I should re-install QT from source. (I installed it with their .run package). – user3386675 Mar 06 '14 at 21:20
  • Sorry, I edited the post to give a correct answer. You don't need to compile Qt from source. – steveire Mar 06 '14 at 22:50
  • This is the best answer I think. I set `CCMAKE_PREFIX_PATH` to `C:\Qt\Qt5.5.0\5.5\msvc2013_6` and it worked for me. Note that in QtCreator I did not need to do this. Apparently, QtCreator already takes care of this but if I use cmake independent of QtCreator I have to do this. – Z boson Oct 02 '15 at 13:05
7

I needed this on my macOS after Qt installation with brew install qt5:

export CMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.7.0/
Ebrahim Byagowi
  • 10,338
  • 4
  • 70
  • 81
3

For ubuntu: cmake -DCMAKE_PREFIX_PATH=/home/ryan/Qt/5.11.2/gcc_64 ..

/home/ryan/Qt/ is the Qt installation root path

ryancheung
  • 2,999
  • 3
  • 24
  • 25
2

at an Ubuntu 16.04.4 LTS desktop the solution was

cmake .. -DMAKE_PREFIX_PATH=/usr/include/x86_64-linux-gnu/qt5
fometeo
  • 113
  • 1
  • 6