I'm working on some general purpose math libraries that I will want to use in multiple projects. Obviously, it makes sense for all the project to reference the same code files so if I fix something it affects all projects.
One way to do this would be to simply have them all use an INCLUDEPATH and DEPENDPATH that points to the same directory of code files.
But I was reading this: http://qt-project.org/wiki/IncludingProFiles And I'm wondering if it is better to create a .pri Qt project for purposes of inclusion only. Would this be better? Do you have to then manually change the extension from .pro to .pri?
What's the best setup for sharing code between projects?
Obviously you know the way of including them with INCLUDEPATH and DEPENDPATH, which is fairly easy to setup but a bit annoying. Using a pri file does alleviate some of the headaches, and it makes it easier to add them into a new project as you go along with any additional customisation you like to have on projects. Or if you're working on a large multi-application project and need to keep similar build settings.
The third option is building them as a library file and just including them, the same as you would any library. Trickier to setup initially than just using a pri or the include directives, but it does mean the code is kept as it's own separate unit.
If it's a small amount of code, but you plan on using it often I'd use a pri, if it's a reasonably large amount of code I'd go for library, and if you only plan on using it rarely I'd use the include directives.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With