2014-03-06 176 views
19

我不知道了很多關於cmake的,我試圖建立使用cmake和Qt的客戶端。獲取以下錯誤:「Qt5Widgets」的安裝前綴添加到CMAKE_PREFIX_PATH

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!

據我所知,我需要添加QT路徑到CMake。我該怎麼做?我已將Qt安裝在/ home/user/Programs中。我發現的所有解釋都是「只是做這個或那個」。我需要確切的終端命令,所以我可以在將來學會如何做。

謝謝!

UPDATE:export CMAKE_PREFIX_PATH=/home/user/Programs沒有幫助我。

回答

12

這是記載:

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 

做這個

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

其中引用的編譯器等,使這一完整路徑是有效的:

/home/user/Programs/<other_stuff>/bin/qmake* 
+2

謝謝!我之前完成了這個工作,而且我仍然得到相同的結果。也許我應該從源代碼重新安裝QT。 (我用它們的.run包安裝它)。 – user3386675

+0

對不起,我編輯帖子給出正確的答案。你不需要從源代碼編譯Qt。 – steveire

+1

顯然這個正確的答案有兩個downvotes。這是爲什麼? – steveire

10

啊,你有一個Windows的解決方案:How to find qt5 CMake module on windows

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

對於您的環境,我想你將不得不改變其中的Qt所在的路徑...

也許這將幫助你:
https://github.com/Cockatrice/Cockatrice/issues/205

+1

它工作真的很好的答案。他們爲什麼給你一個減號我不明白。答案沒有奏效。但你的確做過 –

+0

也許你可以給+1 :)嗯,我認爲是因爲這個答案只適用於Windows,而且看起來OP在使用Linux。最後唯一的變化將是路徑... – lmiguelmh

+0

感謝您提供完整的路徑! – steventaitinger

1

brew install qt5需要這個Qt的安裝後,我的MacOS:

export CMAKE_PREFIX_PATH=/usr/local/Cellar/qt5/5.7.0/