emqx / qmqtt

MQTT client for Qt
https://www.emqx.com
Other
698 stars 337 forks source link

Including QMqtt as a submodule using CMake #220

Closed tom-23 closed 3 years ago

tom-23 commented 3 years ago

Hi there,

I've been using this library for a project I'm developing and I've included it in the following way in my CMakeLists.txt file:

add_subdirectory(lib/qmqtt)
include_directories("lib/qmqtt/src/mqtt")
target_link_libraries(xxx PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::Network qmqtt)

This seems to work fine, but when I try to deploy the project with CPack, I end up with QMqtt being deployed and not my project's application bundle. (I have set up CPack to deploy my application)

Is there any way I could disable CPack generation for this project or am I just being very stupid and not including the project properly (CMake newbie). Thanks!

ejvr commented 3 years ago

The problem appears to be that you are including the root level CMakeLists.txt of mqtt (the one with the 'project' directive). This is something you should not do. I did not write the cmake support in qmqtt, but it looks like it was not intended to be included in another cmake project. Is there a reason you do not deploy qmqtt as a separate bundle? (So just build qmqtt as a standalone, install it so you can compile your own code and use CPack to create a qmqtt bundle, and your own bundle as well).

tom-23 commented 3 years ago

Yeah, I just realised, there isn't really a reason since macdeployqt (or windeployqt) copies the library over. No worries (amazing library btw!)