Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Multiple binaries from same source files



  • Hi there,

    We have a complex build that's set up with qmake at the moment. We need to build libraries and executables with 4 different options, which correspond to:

    1. Single precision, serial
    2. Double precision, serial
    3. Single precision, parallel
    4. Double precision, parallel

    The pattern that we've followed up to now is to have a lib_common.pri file which lists the sources, and then four *.pro files like:

    lib_s_s.pro
    lib_d_s.pro
    lib_s_p.pro
    lib_d_p.pro
    

    which set the compiler options specific to each version of the library, and then include the lib_common.pri file. We then have an overarching 'lib.pro' file which is like:

    TEMPLATE = subdirs
    SUBDIRS = \
         lib_s_s.pro \
         lib_d_s.pro \
         lib_s_p.pro \
         lib_d_p.pro 
    

    While this works, we're finding that it's not a very elegant solution, and it means that for e.g. for a test binary, we can have a single source file and 6 build files.

    Is there any way to do this more elegantly? Ideally, we'd like to be able to do something akin to:

    for precision in [single, double]
        for concurrency in [serial, parallel]
            CONFIG = $precision $concurrency
            TARGET = lib_${precision}_${concurrency}
            SOURCES = somesources.cpp
        end for
    end for
    

    which would allow us to keep each library/executable's build script to at most one or two files.


Log in to reply