[英]How to configure cmake-based project for a build with Qt
here is a doc about that, but it doesn't look correct for me , so I've copied cmake instructions into my cmakelists.txt and it doesn't work. 这是关于此的文档,但对我来说似乎不正确,因此我将cmake指令复制到了我的cmakelists.txt中,但它不起作用。 it's clear why it doesn't work - because there is no one instruction how to search qt:
很明显为什么它不起作用-因为没有一条指令可以搜索qt:
I suppose two cases: 我想两种情况:
but nothing about that. 但那没什么。
the instruction : 说明:
find_package(Qt5Widgets)
refers to extra cmake script from qt kit , isn't it? 指的是来自qt kit的额外的cmake脚本,不是吗? I see the directory with that name (annd contains *.cmake scripts but another names) but there is no the script with this name
我看到具有该名称的目录(Annd包含* .cmake脚本,但另一个名称),但是没有具有该名称的脚本
these are the only .cmake files with qt in names in cmake 3.6 : 这些是cmake 3.6中唯一带有qt名称的.cmake文件:
cmake-3.6\Modules\DeployQt4.cmake
cmake-3.6\Modules\FindosgQt.cmake
cmake-3.6\Modules\FindQt.cmake
cmake-3.6\Modules\FindQt3.cmake
cmake-3.6\Modules\FindQt4.cmake
cmake-3.6\Modules\Qt4ConfigDependentSettings.cmake
cmake-3.6\Modules\Qt4Macros.cmake
cmake-3.6\Modules\UseQt4.cmake
=================== ===================
C:\\dev\\tools\\CLion.RC\\bin\\cmake\\bin\\cmake.exe -DCMAKE_BUILD_TYPE=Debug -G "CodeBlocks - MinGW Makefiles" C:\\dev\\workspace\\algolist.v2 CMake Warning at CMakeLists.txt:14 (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.
C:\\ dev \\ tools \\ CLion.RC \\ bin \\ cmake \\ bin \\ cmake.exe -DCMAKE_BUILD_TYPE =调试-G“ CodeBlocks-MinGW Makefiles” C:\\ dev \\ workspace \\ algolist.v2 CMake在CMakeLists.txt:14发出警告(find_package):通过不在CMAKE_MODULE_PATH中提供“ FindQt5Widgets.cmake”,该项目要求CMake查找“ Qt5Widgets”提供的软件包配置文件,但CMake找不到一个。
Could not find a package configuration file provided by "Qt5Widgets" with any of the following names:
找不到“ Qt5Widgets”提供的具有以下任何名称的程序包配置文件:
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.
将“ Qt5Widgets”的安装前缀添加到CMAKE_PREFIX_PATH或将“ Qt5Widgets_DIR”设置为包含上述文件之一的目录。 If "Qt5Widgets" provides a separate development package or SDK, be sure it has been installed.
如果“ Qt5Widgets”提供了单独的开发包或SDK,请确保已安装它。
CMake Error at CMakeLists.txt:20 (target_link_libraries): Cannot specify link libraries for target "helloworld" which is not built by
CMakeLists.txt:20(target_link_libraries)的CMake错误:无法为目标“ helloworld”指定链接库,该链接库不是由
this project.这个项目。
-- Configuring incomplete, errors occurred!
-配置不完整,发生错误! See also "C:/dev/workspace/algolist.v2/cmake-build-debug/CMakeFiles/CMakeOutput.log".
另请参见“ C:/dev/workspace/algolist.v2/cmake-build-debug/CMakeFiles/CMakeOutput.log”。
seems it found Qt5Widgets, but absolutely not clear how it does this... so it looks for cmake files inside Qt5Widgets folder, in Qt kit. 似乎它找到了Qt5Widgets,但绝对不清楚它是如何做到的...因此它在Qt工具包中的Qt5Widgets文件夹中查找cmake文件。 I can add this folder to the path but I don't think this is a valid way, because there is a lot of subfolders with cmake files
我可以将此文件夹添加到路径中,但我认为这不是有效的方法,因为有很多带有cmake文件的子文件夹
Qt5.8 beta, built with MinGW, Win10, cmake 3.6 Qt5.8 Beta,使用MinGW,Win10,cmake 3.6构建
You need to use CMAKE_PREFIX_PATH . 您需要使用CMAKE_PREFIX_PATH 。
For example: 例如:
cmake.exe -DCMAKE_PREFIX_PATH="C:/path/to/Qt/5.X/compiler/lib/cmake"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.