Search code examples
qtqt5qt4qt-creator

QMake variables not changing when modified in a .pri function


I have created a qmake function that includes a .pri file:

defineTest(add_my_lib) {
    lib_name = $$1
    message("adding lib$$lib_name ")
    include(mypath/$${lib_name}.pri)
}

in this .pri file I have added lines to include a library:

INCLUDEPATH += /pathToLib/src
LIBS += -L/pathToLib/lib -lmylibname

The problem is that for some reason in the .pro that calls add_my_lib the INCLUDEPATH gets reset. It looks like INCLUDEPATH is a variable that cannot be modified by functions. Or better, it can inside the function but the values do not get propagated in the caller .pro file.

Is this the correct behavior or am I doing something wrong?


Solution

  • I think i found the solution : You have to put

    export(INCLUDEPATH)
    export(LIBS)
    export(DEPENDPATH)
    

    After the include() directive