qmake: automatic addition of source files



  • Is there any possibility to tell qmake and Qt Creator to automatically load all .cpp and .h from a directory including all its subdirectories? Is there a magic rule for .pro file which solves it?

    I am working on GUI which is connected to another (non-Qt) C++ application. People working on that app add new files or change existing ones. When I download these changes via git to my local repository, I have to check it and add all new files manually to .pro file. That is really annoying. Thus, I am looking for a better way. The best option would be to tell the .pro file about one directory where all sources and headers are located and it will load them dynamically including all subdirectories.

    Thanks,

    thompsonx


  • Qt Champions 2017



  • @thompsonx
    well you could write a small programm to do that for you.

    Read your *.pro file and save the content in a String/Bytearray ignore everything SOURCES +=, HEADERS += and FORMS +=.
    Recursively go through all sub dirs add *h, *p *.ui files to seperate lists.

    Add those lists to your Pro file

    Save the new file.

    :-)



  • @mrjj said in qmake: automatic addition of source files:

    Hi
    well there are way to do something like that
    https://stackoverflow.com/questions/3806833/qmake-automatically-compiling-all-files-in-a-directory

    thx for reply, @mrjj . The proposed solution has a disadvantage. In my .pro file apart from SOURCES and HEADERS I also specify some qmake flags, include some libs and add includepaths which are necessary for the application that I am connecting the GUI to. With your solution I have to store the flags and all that stuff somewhere and copy it to a new .pro everytime. Am I right?

    @J-Hilk
    thx. Of course, this is a solution :-D But I would prefer a solution via .pro file if exists.


  • Qt Champions 2017

    @thompsonx said in qmake: automatic addition of source files:

    With your solution I have to store the flags and all that stuff somewhere and copy it to a new .pro everytime. Am I right?

    yes it just discovers files. it cant possible know any compile options from the files alone.
    But it makes a .pri file so in theory some options can survive a rescan if you can maybe include
    another pri file in the pri file etc.
    Normally you do not want it to find random .cpp and include in the project so its
    not something i tried a lot of times :)



  • Ok, I understand. So, possibly I can keep somewhere a .pri file with compiler flags etc. and include it to the final .pro file created by qmake. True?


  • Qt Champions 2017

    @thompsonx
    Yes i imagine its possible to have a pri file to setup options and the
    actual files comes from other autogenerated .pri file.


Log in to reply
 

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