CONFIG -= debug release debug_and_release CONFIG += debug fileName = "qtvars_Win32_Debug.props" modules = core varNames = DEFINES INCLUDEPATH LIBS ## Escape string for use by MSBuild # defineReplace(formatMsBuildString) { exprValue = $$1 exprText = "" sep = "" for (value, exprValue) { value = $$replace(value, "%", "%25") value = $$replace(value, ";", "%3B") value = $$replace(value, "\x24", "%24") value = $$replace(value, "@", "%40") exprText = "$$exprText$$sep$$value" sep = ";" } return($$exprText) } ## Fetch information from required modules through dependency relation # defined(modules, var) { INCLUDEPATH += $$[INCLUDEPATH] QT = $$resolve_depends(modules, "QT.") for (module, $$list($${QT})) { INCLUDEPATH *= $$eval($$"QT.$${module}.includes") DEFINES *= $$eval($$"QT.$${module}.DEFINES") } } ## Add "qtvars" make target: append "late-bound" variables (e.g. LIBS) to .props (XML) file. # contains(varNames, LIBS) { varNames -= LIBS NL = $$escape_expand("\n") TAB = $$escape_expand("\t") QMAKE_EXTRA_TARGETS += qtvars qtvars.target = qtvars qtvars.depends = $(LIBS) qtvars.commands = \ $$NL$(LIBS): FORCE\ $$NL$$TAB@CMD /V:ON /C \"\ @ECHO OFF &\ SET x=$@&\ IF NOT \"!x:~0,9!\"==\"/LIBPATH:\" (\ ECHO ^\$\$^(Qt_LIBS_^);!x!^>>$$fileName\ )\ ELSE (\ ECHO ^\$\$^(Qt_LIBPATH_^);!x:~9!^>>$$fileName\ )\" } ## Append Qt variables to .props (XML) file # for (varName, varNames) { propName = "Qt_$${varName}_" text = "<$${propName}>"$$formatMsBuildString($$eval($$varName))"" write_file($$fileName, text, append) }