jbagg / QtZeroConf

Qt wrapper class for ZeroConf libraries across various platforms.
Other
69 stars 51 forks source link

Qt6 cmake compat #53

Closed marc-cpdesign closed 1 year ago

marc-cpdesign commented 2 years ago

Hi, I just realised that this change will also need to update the .pro and .pri files, I can do this if you are otherwise ok with the PR

jbagg commented 2 years ago

Hi Marc, I'm ok with everything but the changes to the includes to the header and source files. (second last commit). Is there any issue in removing the second last commit from the pull request and leaving the paths for future discussion? I have been using QtSerialPort as an example. If you checkout qt 6.2 and ascend into qtserialport/src/serialport, you will see that QtSerialPort's includes also do not have the QtSerialPort's prefix. I'm not familiar enough with cmake to know how they do this.

include "qserialport.h"

include "qserialportinfo.h"

include "qserialportinfo_p.h"

include "qserialport_p.h"

marc-cpdesign commented 1 year ago

Hi @jbagg , apologies for my slow follow up here (I missed your comment until now).

The current master (ie without this series) currently is not usable when installed and consumed from another project via FindPackage unless the consuming project includes header via "QtZeroConf/qzeroconf.h" ... in this case the include directories use the 'INSTALL_INTERFACE' from:

target_include_directories(QtZeroConf PUBLIC
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
    $<INSTALL_INTERFACE:include>
)

so from this the required include paths should be different, as the BUILD_INTERFACE points to the root folder (where the the .h files are in the project) but the INSTALL_INTERFACE points to the installed 'include' folder, and the header files are then in an additional 'QtZeroConf' folder. I'm not sure why, but for some reason my test project when using FetchContent (so the BUILD_INTERFACE) works when using either #include "qzeroconf.h" or #include <QtZeroConf/qzeroconf.h>" .

For a first pass change, I'll update the INSTALL_INTERFACE to be include/QtZeroConf. This way the 'QtZeroConf' won't be required for any method of inclusion. That said, having a folder or module prefix for header includes is something that I thought was very typical. For example boost, nlohmann json, poco. I think Qt even you can use "QtSerialPort/qserialport.h".