Important: Please read the Qt Code of Conduct -

.pro syntax. How to exclude some files from production builds

  • Hi All

    My app is 100% qml and most of the time I use just a qml viewer, sometimes from Qt Creator, sometimes started from the test scripts. There are plenty of files in my project that are useful during development only: test scripts, data for test scripts, some images and code that may be useful for the next release/platform, but not right now.

    When making a final build for Symbian or Maemo I want to create a small package and throw away these extra files without physically removing the from the directory (during the development, they are useful).

    Is there a way for using .pro file syntax so that based on some CONFIG setting it excludes a whole bunch of file by the naming convention?

    For example, if I define "FINALDEPLOYMENT" it would exclude all the files with the names starting with "tst_"

    Thank you for your time!

    I think I know how to use CONFIG so that I could include single files (via SOURCE), but that's not very convenient. I've got plenty of qmls, add, remove and rename them quite often, so adding a bunch of them via folder_01.source is way easier. Now if I would only be able to exclude some of the files based on some file name mask.

  • i'm not familar with qml...yet.

    but since you are using pro files for your projects, maybe I can give you some hints.

    have a look at the "following link ":

    There they explain the use of scopes and if structures in your pro file.
    if you combine this technique with including pri files or not, then you might get what you want.

    I hope this helps

  • Exactly! I need help with pro syntax or confirmation that what I want is impossible. QML details were just to add some context.

    Thank you for the link, unfortunately I can't find a solution for what I want. It is easy to include files one by one, I can't see the way to exclude (or include) a bunch of them using some kind of a rule.

  • the only thing i can think of is to use your files separated by using different directories in which you put a pri file which points to the files in the same directory. then you can tell to include the pri file or not using scopes.

    maybe you have to wait for the pro's , they get more active after the weekend ;)

  • Something like this (I haven't used QML and don't know in which variable they are defined, but I'm sure you get the idea)? :

    OTHER_FILES -= $$find(OTHER_FILES,tst_.*)

  • Unfortunately this syntax doesn't seem to work with qml.
    QML files are added to project not via SOURCES and not via OTHER_FILES, but via poorly documented folder_ox.source/target and DEPLOYMENTFOLDERS

    Here is for example a typical piece of a .pro file with qmls:
    @folder_01.source = ../MultiPlatformUi = qml
    DEPLOYMENTFOLDERS = folder_01@

Log in to reply