1
我想用cmake構建一個cpp/qt5項目,但是編譯返回一個關於QT5的錯誤。MacOS Sierra - cmake失敗,qt5
我和自制安裝QT5,
當我這樣做:
brew --prefix qt5
我得到
/usr/local/Cellar/qt5/5.6.0
所以我在我的項目的build
文件夾,我這樣做:
cmake .. -DCMAKE_PREFIX_PATH=$(brew --prefix qt5) -G Xcode -DBUILD_TESTS=ON -DBUILD_TESTS_COVERAGE=off
回到我這個錯誤:
CMake Error at CMakeLists.txt:124 (find_package):
By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5", but
CMake did not find one.
Could not find a package configuration file provided by "Qt5" with any of
the following names:
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
to a directory containing one of the above files. If "Qt5" provides a
separate development package or SDK, be sure it has been installed.
錯誤在CMakelist.txt行:
## QT5 ##
find_package(Qt5 COMPONENTS Core Gui Widgets Concurrent Qml Quick REQUIRED)
set_target_properties(${BIN_NAME} PROPERTIES AUTOMOC ON)
set_target_properties(${BIN_NAME} PROPERTIES AUTOUIC ON)
target_link_libraries(${BIN_NAME} PUBLIC Qt5::Core PUBLIC Qt5::Widgets PUBLIC Qt5::Gui PUBLIC Qt5::Qml PUBLIC Qt5::Quick PUBLIC Qt5::Concurrent)
#########
我也嘗試將-DQt5_DIR=$(brew --prefix qt5)
添加到命令,同結果。
任何想法? 感謝
進行文件'Qt5Config.cmake'存在於你的QT5安裝中? – Tsyvarev
如何驗證? – F4Ke
我不熟悉brew,但它肯定應該能夠提供已安裝軟件包的文件列表。但在特定情況下,在'/ usr/local/Cellar/qt5/5.6.0'下搜索給定的文件就足夠了:變量'CMAKE_PREFIX_PATH'只是爲搜索內容添加新的*前綴*。至於變量'Qt5_DIR',爲了產生效果,這個目錄應該直接包含所需的文件。 – Tsyvarev