I am trying to create a custom qmake "replace function" that basically appends some stuff to the INCLUDEPATH
variables like so:
defineReplace(myFunc) {
lo=$$lower($$1)
INCLUDEPATH += /someDir/libs/lib$${lo}
message("| INCLUDEPATH A: " $${INCLUDEPATH})
return (true)
}
However when I run this function with a parameter and then print out INCLUDEPATH
variables like this:
$$myFunc(whatever)
message("| INCLUDEPATH B: " $${INCLUDEPATH})
I get the following in the log:
Project MESSAGE: | INCLUDEPATH A: /someDir/libs/libwhatever
Project MESSAGE: | INCLUDEPATH B:
This indicates that the function works, but somehow the changes made to the INCLUDEPATH
variable are not preserved.
I want to know how I can get the behavior I expected (INCLUDEPATH
maintains the changes made to it after I run my function). How can I do that?
You need to add a call to export
. From the qmake manual:
export(variablename)
Exports the current value of variablename from the local context of a function > to the global context
So your code should be
defineReplace(myFunc) {
lo=$$lower($$1)
INCLUDEPATH += /someDir/libs/lib$${lo}
message("| INCLUDEPATH A: " $${INCLUDEPATH})
export(INCLUDEPATH) # <-- This is new
return (true)
}