Best way to share source files between projects



  • 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?


  • Lifetime Qt Champion

    Hi,

    I would go for the pri file, you can then easily add dependencies to your library if needed without having to modify all your other projects.

    You should have both, a pro file that allows to build/run tests for your library
    when developing it and a pri file that is used to include your code in other projects (that is if you want to build your library with each project rather that only link to it)



  • It dependes mostly on your needs.

    I have 2 project sharing some code, in the pro file I have the build settings, in the pri file I have the files inclusion.

    In my case the build settings are project specific, but the include file list is the same for both of them.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.