无法制作柯南+ cmake+ QT一起工作。未找到目标的有效QT版本
当我设置设置(cmake_automoc on)
cmake说
src/projqt/cmakelists.txt中的cmake警告(dev):autogen:否 针对目标ProJQT找到的有效QT版本。汽车禁用。 考虑添加:
find_package(qt< qtversion>组件核心)
到您的cmakelists.txt文件。
如果我添加find_package(qt5组件核心)
set> set(cmake_automoc on)
cmake警告在src/projqt/cmakelists.txt:5(find_package):
通过在cmake_module_path中不提供“ findqt5.cmake”,该项目具有
要求Cmake查找“ QT5”提供的软件包配置文件,
但是Cmake找不到一个。
...
我认为柯南提供了一个自定义find_package
首先与柯南相关的行为,然后如果失败,则默认情况下,但看起来它并不像vcpkg一样提供它,就像vcpkg一样,
所有这些操作都在inclage($ {$ {cmake_binary_dir}/conanbuildinfo.cmake)
When I set set(CMAKE_AUTOMOC ON)
cmake says
CMake Warning (dev) in src/ProjQt/CMakeLists.txt: AUTOGEN: No
valid Qt version found for target ProjQt. AUTOMOC disabled.
Consider adding:find_package(Qt<QTVERSION> COMPONENTS Core)
to your CMakeLists.txt file.
If I add find_package(Qt5 COMPONENTS Core)
before set(CMAKE_AUTOMOC ON)
CMake Warning at src/ProjQt/CMakeLists.txt:5 (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.
...
I thought conan provides a custom find_package
which behaviour is conan-related first, then default if failed but it looks like it doesn't provide it like vcpkg does
All these actions are done after include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我又遇到了同一问题,这就是我设法修复它的方式:
generator =“ cmake_find_package_multi”
,如这个问题&lt; pkg&gt; config/target.cmake
files(在我的情况下),我们需要指向cmake在 noreflow noreferrer“> conan docs” “>”autorcc
应该与此配置一起使用:稍后我遇到了两种类型的不同问题……
这是通过移动
q_object
class解决的解决方案。进入标题或添加#include&lt; thisfilename.moc&gt;
在类下方,cmake会自动填充该文件的直接路径而无需嵌套路径。例如,如果我有一个称为“ test.cpp”的文件,我必须这样做:链接器错误,未解决的引用对
metaObject
,qt_metacast
,qt_metacall
,等等……在这种情况下,这意味着MOC的生成源代码未添加到汇编中。
它可以通过添加标头文件以及
.cpp
文件在add_executable
中解决。 生成MOC的
在
q_object
中, 另一种修复方法是修复它的另一种解决方法是在#include&lt; moc_thisfilename.cpp&gt;
中。test.hpp
test.cpp
我尚未找到一种方法来忘记这种Moc Generation Magic,并在包含包含
q_Object 相关的东西
I've encountered the same issue again and this is how I managed to fix it:
generators = "cmake_find_package_multi"
as mentioned in this issue (Again my own issue)<PKG>Config/Target.cmake
files (in my case), we need to point CMake to look for configurations in that folder as specified in conan docs and here in CMake docsAUTOMOC
,AUTOUIC
andAUTORCC
should work with this piece of config:I've encountered two types of different issues later on …
This is resolved either by moving
Q_OBJECT
class into header or adding#include <thisfilename.moc>
below the class, CMake automatically populates direct path to this file without paths nesting. For example if I have a file called "test.cpp" I have to do this:Linker errors with unresolved references to
metaObject
,qt_metacast
,qt_metacall
, etc …In that case it means that moc's generated source code was not added into compilation.
It can be resolved either with adding header files along with
.cpp
files inadd_executable
call:the above has an obvious downside, after each newly created header you have to reconfigure CMake to generate moc stuff
The other way to fix it is to include a file
#include <moc_thisfilename.cpp>
in theQ_OBJECT
's cpp implementation file like that:test.hpp
test.cpp
I haven't yet find a way to forget about this moc generation magic and make CMake autoinclude everything in a smart way when including header containing
Q_OBJECT
related stuff