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