如何在CMake项目中使用QtMqtt?
How to use QtMqtt in CMake project?
要在 qmake 项目文件 (*.pro) 中使用 Qt MQTT 库,应添加 QT += mqtt
。
什么是 CMake pandan?
我对CMake脚本不是很精通,不过应该是:
find_package(Qt5Mqtt REQUIRED)
基于the official example of how to use cmake with Qt I have created the CMakeLists.txt to compile one of the official Qt Mqtt examples: Simple MQTT Client Example.
cmake_minimum_required(VERSION 3.1.0)
project(simplemqttclient)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
find_package(Qt5 COMPONENTS Widgets <b>Mqtt</b> REQUIRED)
add_executable(simplemqttclient
mainwindow.ui
mainwindow.cpp
main.cpp
)
target_link_libraries(simplemqttclient Qt5::Widgets <b>Qt5::Mqtt</b>)
要在 qmake 项目文件 (*.pro) 中使用 Qt MQTT 库,应添加 QT += mqtt
。
什么是 CMake pandan?
我对CMake脚本不是很精通,不过应该是:
find_package(Qt5Mqtt REQUIRED)
基于the official example of how to use cmake with Qt I have created the CMakeLists.txt to compile one of the official Qt Mqtt examples: Simple MQTT Client Example.
cmake_minimum_required(VERSION 3.1.0)
project(simplemqttclient)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
find_package(Qt5 COMPONENTS Widgets <b>Mqtt</b> REQUIRED)
add_executable(simplemqttclient
mainwindow.ui
mainwindow.cpp
main.cpp
)
target_link_libraries(simplemqttclient Qt5::Widgets <b>Qt5::Mqtt</b>)