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 Code:
  1. QT += serialport
To copy to clipboard, switch view to plain text mode 

or something similar if using cmake (I think this is correct):
Qt Code:
  1. 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:
Qt Code:
  1. class MyReceipt {
  2. ... junk ...
  3. }
To copy to clipboard, switch view to plain text mode 

MyPort.h:
Qt Code:
  1. #import <QSerialPort>
  2.  
  3. class MyPort: public QSerialPort {
  4. ... junk ...
  5. }
To copy to clipboard, switch view to plain text mode 

My pseudo App:

Qt Code:
  1. #import <MyReceipt>
  2.  
  3. ..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.