To use Qt MQTT library in qmake project file (*.pro) QT += mqtt
should be added.
What is CMake pandan for that?
Based on 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 Mqtt REQUIRED)
add_executable(simplemqttclient
mainwindow.ui
mainwindow.cpp
main.cpp
)
target_link_libraries(simplemqttclient Qt5::Widgets Qt5::Mqtt)