Search code examples
qtqmake

Add all subdirs in a QMake project file


I'm porting an old project to Qt, and I have a lot of unit tests project. Each unit test is a single executable.

Now my main .pro file looks like this :

SUBDIRS += UnitTests/Test01/Test01.pro
SUBDIRS += UnitTests/Test02/Test02.pro
SUBDIRS += UnitTests/Test03/Test03.pro
...
SUBDIRS += UnitTests/Test54/Test54.pro

Is there any way to include all subdirs at once ? I would like something like this :

SUBDIRS += UnitTests/*

Thanks


Solution

  • Thanks to Martin Höher, this is working very well :

    // Get a list of all .pro files
    UNIT_TESTS_PRO_FILES = $$files($${PROJECT_ROOT_DIR}/Sources/UnitTests/*.pro, true)
    
    // Add them as subdirs
    for(unitTestProFile, UNIT_TESTS_PRO_FILES) SUBDIRS *= $${unitTestProFile}