CMake未命中Qt5的QT_DEFINITIONS变量
CMake miss QT_DEFINITIONS variable for Qt5
CMake为Qt4具有特殊变量${QT_DEFINITIONS},该变量包含QT定义,如QT_NO_DEBUG和QT_DEBUG。Qt5没有这样的选项。
如何在cmake中添加标准Qt5定义?
请检查<component>_DEFINITIONS
/<component>_COMPILE_DEFINITIONS
。
这里有一个使用QtWidgets和CMake的例子。两个重要部分:
# Find the QtWidgets library
find_package(Qt5Widgets)
# Add the include directories for the Qt 5 Widgets module to
# the compile lines.
include_directories(${Qt5Widgets_INCLUDE_DIRS})
调用find_package()
将为您设置以下变量:
Qt5Widgets_VERSION_STRING
Qt5Widgets_LIBRARIES
例如,与target_link_libraries
命令一起使用的库列表Qt5Widgets_INCLUDE_DIRS
例如,与include_directories
命令一起使用的库列表Qt5Widgets_DEFINITIONS
例如,与add_definitions
一起使用的定义列表Qt5Widgets_COMPILE_DEFINITIONS
用于COMPILE_DEFINITIONS
目标属性的定义列表Qt5Widgets_FOUND
描述是否成功找到模块的布尔值Qt5Widgets_EXECUTABLE_COMPILE_FLAGS
生成可执行文件时要使用的标志字符串
(引用自上面的链接;名称取决于您在find_package()
调用中搜索的内容)
相关文章:
- Qt VTK交互风格的信号到小部件
- QT在错误的班级中寻找空位
- 如何在选项卡视图Qt中设置一个新项目,并保存以前的项目
- 如何在Qt窗口小部件中使用QStringView(或QStringRef)
- 如何在Qt C++中更改光标
- 如何在MS Visual Studio 2019中运行QT UI
- QT通过C++添加映射QML项目
- libssh 的函数在构建 libssh 时无法在 Qt 和 cmake 错误中找到
- 如何将点击的信号和插槽添加到qt中的自定义按钮中
- Qt C++静态thread_local QNetworkAccessManager是线程应用程序的好选择吗
- 使用Qt C++计算类似Git的SHA1哈希
- Qt focusObjectChanged example?
- 如何在cpp文件之间切换窗口?在Qt中
- Qt和C++:将QLineEdit添加到QTabWidget中
- 从数据库实时显示QT c++中的数据
- Qt Quick-如何仅从c++代码与qml属性交互
- 无法使用Qt Creator在Windows中构建yaml-cpp
- 如何在Qt中取消捕获字符串
- Qt SQLite没有查询或参数计数不匹配
- Qt SQlite无法创建表