2016-02-25 26 views
0

當我使用下面的代碼:在cmake的,具體怎麼QT5 pacakge路徑

find_package(Qt5Widgets REQUIRED) 
add_executable(ex ex.cc) 
target_link_libraries(ex Qt5::Widgets Qt5::DBus) 

我得到:

Error: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: 

我qtbase路徑是「/媒體/ roroco/disk750 /下載/ QT5/qtbase」,我有編譯它,如何具體在find_package

回答

0
IF(CMAKE_SIZEOF_VOID_P EQUAL 8) 
     SET(CMAKE_PREFIX_PATH $ENV{QT64_LOCATION}) 
     message(STATUS "QT find path: $ENV{QT64_LOCATION}") 
    ELSE() 
     SET(CMAKE_PREFIX_PATH $ENV{QT_LOCATION}) 
     message(STATUS "QT find path: $ENV{QT_LOCATION}") 
    ENDIF() 

這條道路和路徑添加到環境變量如果它沒有定義或硬編碼 - CMAKE_PREFIX_PATH 「C:\ Qt的\ .. \ msvc2010 \」 或路徑在Linux中 即qmake的 「/媒體/ roroco/disk750 /下載/ QT5 /斌/ QMAKE」

你也可以設置默認QT路徑

/usr/lib/x86_64-linux-gnu/qt-default/qtchooser/default.conf 

將其設置爲/媒體/ roroco/disk750 /下載/ QT5 /斌/

+0

我不明白「QT64_LOCATION」,是「/ media/roroco/disk750/Downloads/qt5/qtbase/bin」還是「/ media/roroco/disk750/Downloads/qt5/qtbase」? – hucmarcot

+0

qmake和其他可執行對象的路徑,可能是「/ media/roroco/disk750/Downloads/qt5/qtbase/bin」 – jonezq

0

設置你的CMAKE_PREFIX_PATHQt文件夾。例如:

SET(CMAKE_PREFIX_PATH "C:/Qt/5.5/msvc2013") 

根據您的操作系統,路徑可能有所不同。