defineTest(qtAddLibrary) {
    INCLUDEPATH = $$QMAKE_INCDIR_QT/$$1 $$INCLUDEPATH
    
    LIB_NAME = $$1
    LINKAGE =
    mac {
       CONFIG(qt_framework, qt_framework|qt_no_framework) { #forced
          QMAKE_CFLAGS *= -F$${QMAKE_LIBDIR_QT}
          QMAKE_CXXFLAGS *= -F$${QMAKE_LIBDIR_QT}
          QMAKE_LIBDIR_FLAGS *= -F$${QMAKE_LIBDIR_QT}
          FRAMEWORK_INCLUDE = $$QMAKE_LIBDIR_QT/$${LIB_NAME}.framework/Headers
          !qt_no_framework_direct_includes:exists($$FRAMEWORK_INCLUDE) {
             INCLUDEPATH -= $$FRAMEWORK_INCLUDE
             INCLUDEPATH = $$FRAMEWORK_INCLUDE $$INCLUDEPATH
           }
           LINKAGE = -framework $${LIB_NAME}
        } else:!qt_no_framework { #detection
           for(frmwrk_dir, $$list($$QMAKE_LIBDIR_QT $$QMAKE_LIBDIR $$(DYLD_FRAMEWORK_PATH) /Library/Frameworks)) {
    	  exists($${frmwrk_dir}/$${LIB_NAME}.framework) {
    	     QMAKE_CFLAGS *= -F$${frmwrk_dir}
    	     QMAKE_CXXFLAGS *= -F$${frmwrk_dir}
    	     QMAKE_LIBDIR_FLAGS *= -F$${frmwrk_dir}
    	     FRAMEWORK_INCLUDE = $$frmwrk_dir/$${LIB_NAME}.framework/Headers
    	     !qt_no_framework_direct_includes:exists($$FRAMEWORK_INCLUDE) {
    	        INCLUDEPATH -= $$FRAMEWORK_INCLUDE
    	        INCLUDEPATH = $$FRAMEWORK_INCLUDE $$INCLUDEPATH
                 }
    	     LINKAGE = -framework $${LIB_NAME}
       	     break()
              }
           }
       }
    }
    isEmpty(LINKAGE) {
       LINKAGE = -l$${LIB_NAME}
       CONFIG(debug, debug|release) {
           win32:LINKAGE = -l$${LIB_NAME}d
           mac:LINKAGE = -l$${LIB_NAME}_debug
       }
    }
    LIBS += $$LINKAGE
    export(LIBS)
    export(INCLUDEPATH)
    export(QMAKE_CFLAGS)
    export(QMAKE_CXXFLAGS)
    export(QMAKE_LIBDIR_FLAGS)
    return(true)
}
