So I use a static library as a "toolbox" of reusable code for most of my projects. I recently added something that extended the QSerialPort class. Now whenever I link to this static library, despite not using this new class, it's required that I add:
QT += serialport
QT += serialport
To copy to clipboard, switch view to plain text mode
or something similar if using cmake (I think this is correct):
target_link_libraries(${APP_NAME} Qt5::SerialPort)
target_link_libraries(${APP_NAME} Qt5::SerialPort)
To copy to clipboard, switch view to plain text mode
So to clarify, here's pseudo Lib.a:
MyReceipt.h:
class MyReceipt {
... junk ...
}
class MyReceipt {
... junk ...
}
To copy to clipboard, switch view to plain text mode
MyPort.h:
#import <QSerialPort>
class MyPort: public QSerialPort {
... junk ...
}
#import <QSerialPort>
class MyPort: public QSerialPort {
... junk ...
}
To copy to clipboard, switch view to plain text mode
My pseudo App:
#import <MyReceipt>
..junk...
#import <MyReceipt>
..junk...
To copy to clipboard, switch view to plain text mode
This would result in me having to add one of the initial statements to either .pro or CMakeLists.txt even though I'm not referencing QSerialPort at all. So is there a way to avoid this? I was thinking maybe not extending QSerialPort and simply having a private object of that type, and possibly just using a forward declaration so the include could be in the implementation file instead of the interface, but would like to avoid the rewrite if possible.
Any help or insight is welcome! Thanks.
Bookmarks