Workaround for DMG problem

Workaround for DMG problem

Running into this bug on newer mac travis builds:
https://github.com/create-dmg/create-dmg/issues/72

isEmpty(TARGET_EXT) {
    win32 {
        TARGET_CUSTOM_EXT = .exe
    }
    macx {
        TARGET_CUSTOM_EXT = .app
    }
} else {
    TARGET_CUSTOM_EXT = $${TARGET_EXT}
}

win32 {
    equals($${TARGET_WINXP}, "1") {
        PRODUCT_VERSION = "$$GIT_VERSION-WindowsXP"
    } else {
        PRODUCT_VERSION = "$$GIT_VERSION"
    }

    DEPLOY_DIR = $$shell_quote($$system_path($${_PRO_FILE_PWD_}/install/deploy))
    DEPLOY_TARGET = $$shell_quote($$system_path($${OUT_PWD}/release/$${TARGET}$${TARGET_CUSTOM_EXT}))

    PRE_DEPLOY_COMMAND += $${QMAKE_DEL_FILE} $${DEPLOY_DIR}\*.* /S /Q $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $${DEPLOY_TARGET} $${DEPLOY_DIR} $$escape_expand(\\n\\t)
    # OpenSSL
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $$shell_quote($$system_path($$OPENSSL_PATH/*.dll)) $${DEPLOY_DIR} $$escape_expand(\\n\\t)
    # PCap
    equals(TARGET_WINXP, 0) {
        contains(QT_ARCH, i386) {
            PRE_DEPLOY_COMMAND += $$QMAKE_COPY $$shell_quote($$system_path($${PCAP_PATH}/Bin/*)) $${DEPLOY_DIR} $$escape_expand(\\n\\t)
        } else {
            PRE_DEPLOY_COMMAND += $$QMAKE_COPY $$shell_quote($$system_path($${PCAP_PATH}/Bin/x64/*)) $${DEPLOY_DIR} $$escape_expand(\\n\\t)
        }
    }

    DEPLOY_COMMAND = windeployqt
    DEPLOY_OPT = --dir $${DEPLOY_DIR}

    DEPLOY_INSTALLER = makensis /DPRODUCT_VERSION="$${PRODUCT_VERSION}" /DTARGET_WINXP="$${TARGET_WINXP}" $$shell_quote($$system_path($${_PRO_FILE_PWD_}/install/win/install.nsi))
}
macx {
    VERSION = $$system(echo $$GIT_VERSION | sed 's/[a-zA-Z]//')

    DEPLOY_DIR = $${_PRO_FILE_PWD_}/install/mac
    DEPLOY_TARGET = $${OUT_PWD}/$${TARGET}$${TARGET_CUSTOM_EXT}

    DEPLOY_COMMAND = macdeployqt

    DEPLOY_CLEANUP = codesign --force --deep --verify --verbose --sign \"Thomas Steer\" $${DEPLOY_TARGET} $$escape_expand(\\n\\t)
    DEPLOY_CLEANUP += $${QMAKE_DEL_FILE} $${DEPLOY_DIR}/sACNView*.dmg

    DEPLOY_INSTALLER = create-dmg --volname "sACNView_Installer" --volicon "$${_PRO_FILE_PWD_}/res/icon.icns"
    DEPLOY_INSTALLER += --background "$${_PRO_FILE_PWD_}/res/mac_install_bg.png" --window-pos 200 120 --window-size 800 400 --icon-size 100
    DEPLOY_INSTALLER += --icon $${TARGET}$${TARGET_CUSTOM_EXT} 200 190 --hide-extension $${TARGET}$${TARGET_CUSTOM_EXT} --app-drop-link 600 185 --skip-jenkins
    DEPLOY_INSTALLER += $${DEPLOY_DIR}/sACNView_$${VERSION}.dmg $${OUT_PWD}/$${TARGET}$${TARGET_CUSTOM_EXT}
}
linux {
    VERSION = $$system(echo $$GIT_VERSION | sed 's/[a-zA-Z]//')

    DEPLOY_DIR = $${_PRO_FILE_PWD_}/install/linux
    DEPLOY_TARGET = $${DEPLOY_DIR}/AppDir/$${TARGET}

    DEPLOY_COMMAND = $${OUT_PWD}/linuxdeployqt
    DEPLOY_OPT = -appimage -verbose=2

    PRE_DEPLOY_COMMAND += $${QMAKE_DEL_FILE} $${DEPLOY_DIR}/*.AppImage $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $${QMAKE_DEL_FILE} $${DEPLOY_TARGET} $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" -O $${DEPLOY_COMMAND} $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += chmod a+x $${DEPLOY_COMMAND} $$escape_expand(\\n\\t)
##    PRE_DEPLOY_COMMAND += unset LD_LIBRARY_PATH $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $${OUT_PWD}/$${TARGET} $${DEPLOY_TARGET} $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $${DEPLOY_DIR}/usr/share/applications/sacnview.desktop $${DEPLOY_DIR}/AppDir/sacnview.desktop $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/Logo.png $${DEPLOY_DIR}/AppDir/sacnview.png $$escape_expand(\\n\\t)

    DEPLOY_CLEANUP = $$QMAKE_COPY $${OUT_PWD}/$${TARGET}*.AppImage $${DEPLOY_DIR}/

    DEPLOY_INSTALLER = $${QMAKE_DEL_FILE} $${DEPLOY_DIR}/*.deb
    DEPLOY_INSTALLER += && $${QMAKE_DEL_FILE} $${DEPLOY_DIR}/opt/sacnview/*.AppImage
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/LICENSE $${DEPLOY_DIR}/COPYRIGHT
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${DEPLOY_DIR}/$${TARGET}*.AppImage $${DEPLOY_DIR}/opt/sacnview/
    DEPLOY_INSTALLER += && ln -s $${TARGET}*.AppImage $${DEPLOY_DIR}/opt/sacnview/sACNView2.AppImage
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_16.png $${DEPLOY_DIR}/usr/share/icons/hicolor/16x16/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_24.png $${DEPLOY_DIR}/usr/share/icons/hicolor/24x24/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_32.png $${DEPLOY_DIR}/usr/share/icons/hicolor/32x32/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_48.png $${DEPLOY_DIR}/usr/share/icons/hicolor/48x48/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_256.png $${DEPLOY_DIR}/usr/share/icons/hicolor/256x256/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/Logo.png $${DEPLOY_DIR}/usr/share/icons/hicolor/scalable/apps/sacnview.png
    DEPLOY_INSTALLER += && cd $${DEPLOY_DIR}
    DEPLOY_INSTALLER += && fpm -s dir -t deb --deb-meta-file $${DEPLOY_DIR}/COPYRIGHT --license $${LICENSE} --name $${TARGET} --version $${VERSION}  --description $${DESCRIPTION} --url $${URL} opt/ usr/
}

CONFIG( release , debug | release) {
    QMAKE_POST_LINK += $${PRE_DEPLOY_COMMAND} $$escape_expand(\\n\\t)
    QMAKE_POST_LINK += $${DEPLOY_COMMAND} $${DEPLOY_TARGET} $${DEPLOY_OPT} $$escape_expand(\\n\\t)
    QMAKE_POST_LINK += $${DEPLOY_CLEANUP} $$escape_expand(\\n\\t)
    QMAKE_POST_LINK += $${DEPLOY_INSTALLER} $$escape_expand(\\n\\t)
}

isEmpty(TARGET_EXT) {
    win32 {
        TARGET_CUSTOM_EXT = .exe
    }
    macx {
        TARGET_CUSTOM_EXT = .app
    }
} else {
    TARGET_CUSTOM_EXT = $${TARGET_EXT}
}

win32 {
    equals($${TARGET_WINXP}, "1") {
        PRODUCT_VERSION = "$$GIT_VERSION-WindowsXP"
    } else {
        PRODUCT_VERSION = "$$GIT_VERSION"
    }

    DEPLOY_DIR = $$shell_quote($$system_path($${_PRO_FILE_PWD_}/install/deploy))
    DEPLOY_TARGET = $$shell_quote($$system_path($${OUT_PWD}/release/$${TARGET}$${TARGET_CUSTOM_EXT}))

    PRE_DEPLOY_COMMAND += $${QMAKE_DEL_FILE} $${DEPLOY_DIR}\*.* /S /Q $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $${DEPLOY_TARGET} $${DEPLOY_DIR} $$escape_expand(\\n\\t)
    # OpenSSL
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $$shell_quote($$system_path($$OPENSSL_PATH/*.dll)) $${DEPLOY_DIR} $$escape_expand(\\n\\t)
    # PCap
    equals(TARGET_WINXP, 0) {
        contains(QT_ARCH, i386) {
            PRE_DEPLOY_COMMAND += $$QMAKE_COPY $$shell_quote($$system_path($${PCAP_PATH}/Bin/*)) $${DEPLOY_DIR} $$escape_expand(\\n\\t)
        } else {
            PRE_DEPLOY_COMMAND += $$QMAKE_COPY $$shell_quote($$system_path($${PCAP_PATH}/Bin/x64/*)) $${DEPLOY_DIR} $$escape_expand(\\n\\t)
        }
    }

    DEPLOY_COMMAND = windeployqt
    DEPLOY_OPT = --dir $${DEPLOY_DIR}

    DEPLOY_INSTALLER = makensis /DPRODUCT_VERSION="$${PRODUCT_VERSION}" /DTARGET_WINXP="$${TARGET_WINXP}" $$shell_quote($$system_path($${_PRO_FILE_PWD_}/install/win/install.nsi))
}
macx {
    VERSION = $$system(echo $$GIT_VERSION | sed 's/[a-zA-Z]//')

    DEPLOY_DIR = $${_PRO_FILE_PWD_}/install/mac
    DEPLOY_TARGET = $${OUT_PWD}/$${TARGET}$${TARGET_CUSTOM_EXT}

    DEPLOY_COMMAND = macdeployqt

    DEPLOY_CLEANUP = codesign --force --deep --verify --verbose --sign \"Thomas Steer\" $${DEPLOY_TARGET} $$escape_expand(\\n\\t)
    DEPLOY_CLEANUP += $${QMAKE_DEL_FILE} $${DEPLOY_DIR}/sACNView*.dmg

    DEPLOY_INSTALLER = create-dmg --volname "sACNView_Installer" --volicon "$${_PRO_FILE_PWD_}/res/icon.icns"
    DEPLOY_INSTALLER += --background "$${_PRO_FILE_PWD_}/res/mac_install_bg.png" --window-pos 200 120 --window-size 800 400 --icon-size 100 --icon $${TARGET}$${TARGET_CUSTOM_EXT} 200 190 --hide-extension $${TARGET}$${TARGET_CUSTOM_EXT} --app-drop-link 600 185
    DEPLOY_INSTALLER += $${DEPLOY_DIR}/sACNView_$${VERSION}.dmg $${OUT_PWD}/$${TARGET}$${TARGET_CUSTOM_EXT}
}
linux {
    VERSION = $$system(echo $$GIT_VERSION | sed 's/[a-zA-Z]//')

    DEPLOY_DIR = $${_PRO_FILE_PWD_}/install/linux
    DEPLOY_TARGET = $${DEPLOY_DIR}/AppDir/$${TARGET}

    DEPLOY_COMMAND = $${OUT_PWD}/linuxdeployqt
    DEPLOY_OPT = -appimage -verbose=2

    PRE_DEPLOY_COMMAND += $${QMAKE_DEL_FILE} $${DEPLOY_DIR}/*.AppImage $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $${QMAKE_DEL_FILE} $${DEPLOY_TARGET} $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage" -O $${DEPLOY_COMMAND} $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += chmod a+x $${DEPLOY_COMMAND} $$escape_expand(\\n\\t)
##    PRE_DEPLOY_COMMAND += unset LD_LIBRARY_PATH $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $${OUT_PWD}/$${TARGET} $${DEPLOY_TARGET} $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $${DEPLOY_DIR}/usr/share/applications/sacnview.desktop $${DEPLOY_DIR}/AppDir/sacnview.desktop $$escape_expand(\\n\\t)
    PRE_DEPLOY_COMMAND += $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/Logo.png $${DEPLOY_DIR}/AppDir/sacnview.png $$escape_expand(\\n\\t)

    DEPLOY_CLEANUP = $$QMAKE_COPY $${OUT_PWD}/$${TARGET}*.AppImage $${DEPLOY_DIR}/

    DEPLOY_INSTALLER = $${QMAKE_DEL_FILE} $${DEPLOY_DIR}/*.deb
    DEPLOY_INSTALLER += && $${QMAKE_DEL_FILE} $${DEPLOY_DIR}/opt/sacnview/*.AppImage
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/LICENSE $${DEPLOY_DIR}/COPYRIGHT
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${DEPLOY_DIR}/$${TARGET}*.AppImage $${DEPLOY_DIR}/opt/sacnview/
    DEPLOY_INSTALLER += && ln -s $${TARGET}*.AppImage $${DEPLOY_DIR}/opt/sacnview/sACNView2.AppImage
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_16.png $${DEPLOY_DIR}/usr/share/icons/hicolor/16x16/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_24.png $${DEPLOY_DIR}/usr/share/icons/hicolor/24x24/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_32.png $${DEPLOY_DIR}/usr/share/icons/hicolor/32x32/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_48.png $${DEPLOY_DIR}/usr/share/icons/hicolor/48x48/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/icon_256.png $${DEPLOY_DIR}/usr/share/icons/hicolor/256x256/apps/sacnview.png
    DEPLOY_INSTALLER += && $$QMAKE_COPY $${_PRO_FILE_PWD_}/res/Logo.png $${DEPLOY_DIR}/usr/share/icons/hicolor/scalable/apps/sacnview.png
    DEPLOY_INSTALLER += && cd $${DEPLOY_DIR}
    DEPLOY_INSTALLER += && fpm -s dir -t deb --deb-meta-file $${DEPLOY_DIR}/COPYRIGHT --license $${LICENSE} --name $${TARGET} --version $${VERSION}  --description $${DESCRIPTION} --url $${URL} opt/ usr/
}

CONFIG( release , debug | release) {
    QMAKE_POST_LINK += $${PRE_DEPLOY_COMMAND} $$escape_expand(\\n\\t)
    QMAKE_POST_LINK += $${DEPLOY_COMMAND} $${DEPLOY_TARGET} $${DEPLOY_OPT} $$escape_expand(\\n\\t)
    QMAKE_POST_LINK += $${DEPLOY_CLEANUP} $$escape_expand(\\n\\t)
    QMAKE_POST_LINK += $${DEPLOY_INSTALLER} $$escape_expand(\\n\\t)
}


Deactivate tests install

Deactivate tests install

include(../common.pri)

QT += testlib sql
QT -= gui

CONFIG += qt console warn_on depend_includepath testcase no_testcase_installs
CONFIG -= app_bundle

TEMPLATE = app

RESOURCES += $$PWD/../src/sql.qrc

INCLUDEPATH += $$PWD/../src $$PWD/include
LIBS += -L../../src -llpd8editor

include(../common.pri)

QT += testlib sql
QT -= gui

CONFIG += qt console warn_on depend_includepath testcase
CONFIG -= app_bundle

TEMPLATE = app

RESOURCES += $$PWD/../src/sql.qrc

INCLUDEPATH += $$PWD/../src $$PWD/include
LIBS += -L../../src -llpd8editor


Bug fixes for old Qt [ci skip]

Bug fixes for old Qt [ci skip]

INCLUDEPATH += $$PWD $$PWD/../src
DEPENDPATH  += $$PWD $$PWD/../src

HEADERS += $$PWD/eventdispatcher.h

CONFIG  *= link_prl
LIBS    += -L$$OUT_PWD/$$DESTDIR/../lib -leventdispatcher_libevent

unix|*-g++* {
	equals(QMAKE_PREFIX_STATICLIB, ""): QMAKE_PREFIX_STATICLIB = lib
	equals(QMAKE_EXTENSION_STATICLIB, ""): QMAKE_EXTENSION_STATICLIB = a

	PRE_TARGETDEPS *= $$OUT_PWD/$$DESTDIR/../lib/$${QMAKE_PREFIX_STATICLIB}eventdispatcher_libevent$${LIB_SUFFIX}.$${QMAKE_EXTENSION_STATICLIB}
}
else:win32 {
	PRE_TARGETDEPS *= $$OUT_PWD/$$DESTDIR/../lib/eventdispatcher_libevent$${LIB_SUFFIX}.lib
}

equals(TARGET, tst_qsocketnotifier):win32 {
	LIBS += $$QMAKE_LIBS_NETWORK
}

INCLUDEPATH += $$PWD $$PWD/../src
DEPENDPATH  += $$PWD $$PWD/../src

HEADERS += $$PWD/eventdispatcher.h

CONFIG  *= link_prl
LIBS    += -L$$OUT_PWD/$$DESTDIR/../lib -leventdispatcher_libevent

unix|*-g++* {
	PRE_TARGETDEPS *= $$OUT_PWD/$$DESTDIR/../lib/$${QMAKE_PREFIX_STATICLIB}eventdispatcher_libevent$${LIB_SUFFIX}.$${QMAKE_EXTENSION_STATICLIB}
}
else:win32 {
	PRE_TARGETDEPS *= $$OUT_PWD/$$DESTDIR/../lib/eventdispatcher_libevent$${LIB_SUFFIX}.lib
}

equals(TARGET, tst_qsocketnotifier):win32 {
	LIBS += $$QMAKE_LIBS_NETWORK
}


Version bump

Version bump

Change-Id: Ie922c0ccada7b20f452812ca0cf53f9085774c54

!isEmpty(QTCREATOR_PRI_INCLUDED):error("qtcreator.pri already included")
QTCREATOR_PRI_INCLUDED = 1

QTCREATOR_VERSION = 2.2.84

defineReplace(cleanPath) {
    win32:1 ~= s|\\\\|/|g
    contains(1, ^/.*):pfx = /
    else:pfx =
    segs = $$split(1, /)
    out =
    for(seg, segs) {
        equals(seg, ..):out = $$member(out, 0, -2)
        else:!equals(seg, .):out += $$seg
    }
    return($$join(out, /, $$pfx))
}

defineReplace(targetPath) {
    return($$replace(1, /, $$QMAKE_DIR_SEP))
}

defineReplace(qtLibraryName) {
   unset(LIBRARY_NAME)
   LIBRARY_NAME = $$1
   CONFIG(debug, debug|release) {
      !debug_and_release|build_pass {
          mac:RET = $$member(LIBRARY_NAME, 0)_debug
              else:win32:RET = $$member(LIBRARY_NAME, 0)d
      }
   }
   isEmpty(RET):RET = $$LIBRARY_NAME
   return($$RET)
}

defineTest(minQtVersion) {
    maj = $$1
    min = $$2
    patch = $$3
    isEqual(QT_MAJOR_VERSION, $$maj) {
        isEqual(QT_MINOR_VERSION, $$min) {
            isEqual(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
            greaterThan(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
        }
        greaterThan(QT_MINOR_VERSION, $$min) {
            return(true)
        }
    }
    return(false)
}

# For use in custom compilers which just copy files
win32:i_flag = i
defineReplace(stripSrcDir) {
    win32 {
        !contains(1, ^.:.*):1 = $$OUT_PWD/$$1
    } else {
        !contains(1, ^/.*):1 = $$OUT_PWD/$$1
    }
    out = $$cleanPath($$1)
    out ~= s|^$$re_escape($$PWD/)||$$i_flag
    return($$out)
}

isEmpty(TEST):CONFIG(debug, debug|release) {
    !debug_and_release|build_pass {
        TEST = 1
    }
}

isEmpty(IDE_LIBRARY_BASENAME) {
    IDE_LIBRARY_BASENAME = lib
}

DEFINES += IDE_LIBRARY_BASENAME=\\\"$$IDE_LIBRARY_BASENAME\\\"

equals(TEST, 1) {
    QT +=testlib
    DEFINES += WITH_TESTS
}

IDE_SOURCE_TREE = $$PWD
isEmpty(IDE_BUILD_TREE) {
    sub_dir = $$_PRO_FILE_PWD_
    sub_dir ~= s,^$$re_escape($$PWD),,
    IDE_BUILD_TREE = $$cleanPath($$OUT_PWD)
    IDE_BUILD_TREE ~= s,$$re_escape($$sub_dir)$,,
}
IDE_APP_PATH = $$IDE_BUILD_TREE/bin
macx {
    IDE_APP_TARGET   = "Qt Creator"
    IDE_LIBRARY_PATH = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/PlugIns
    IDE_PLUGIN_PATH  = $$IDE_LIBRARY_PATH
    IDE_LIBEXEC_PATH = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/Resources
    IDE_DATA_PATH    = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/Resources
    IDE_DOC_PATH     = $$IDE_DATA_PATH/doc
    IDE_BIN_PATH     = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/MacOS
    contains(QT_CONFIG, ppc):CONFIG += ppc x86
    copydata = 1
    isEmpty(TIGER_COMPAT_MODE):TIGER_COMPAT_MODE=$$(QTC_TIGER_COMPAT)
    isEmpty(TIGER_COMPAT_MODE) {
        QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5
        QMAKE_LFLAGS *= -mmacosx-version-min=10.5
    }
} else {
    win32 {
        contains(TEMPLATE, vc.*)|contains(TEMPLATE_PREFIX, vc):vcproj = 1
        IDE_APP_TARGET   = qtcreator
    } else {
        IDE_APP_TARGET   = qtcreator
    }
    IDE_LIBRARY_PATH = $$IDE_BUILD_TREE/$$IDE_LIBRARY_BASENAME/qtcreator
    IDE_PLUGIN_PATH  = $$IDE_LIBRARY_PATH/plugins
    IDE_LIBEXEC_PATH = $$IDE_APP_PATH # FIXME
    IDE_DATA_PATH    = $$IDE_BUILD_TREE/share/qtcreator
    IDE_DOC_PATH     = $$IDE_BUILD_TREE/share/doc/qtcreator
    IDE_BIN_PATH     = $$IDE_APP_PATH
    !isEqual(IDE_SOURCE_TREE, $$IDE_BUILD_TREE):copydata = 1
}

INCLUDEPATH += \
    $$IDE_SOURCE_TREE/src/libs \
    $$IDE_SOURCE_TREE/tools \
    $$IDE_SOURCE_TREE/src/plugins

CONFIG += depend_includepath

LIBS += -L$$IDE_LIBRARY_PATH

#DEFINES += QT_NO_CAST_FROM_ASCII
DEFINES += QT_NO_CAST_TO_ASCII
!macx:DEFINES += QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION

unix {
    CONFIG(debug, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared
    CONFIG(release, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared

    CONFIG(debug, debug|release):MOC_DIR = $${OUT_PWD}/.moc/debug-shared
    CONFIG(release, debug|release):MOC_DIR = $${OUT_PWD}/.moc/release-shared

    RCC_DIR = $${OUT_PWD}/.rcc
    UI_DIR = $${OUT_PWD}/.uic
}

win32-msvc* {
    #Don't warn about sprintf, fopen etc being 'unsafe'
    DEFINES += _CRT_SECURE_NO_WARNINGS
}

!isEmpty(QTCREATOR_PRI_INCLUDED):error("qtcreator.pri already included")
QTCREATOR_PRI_INCLUDED = 1

QTCREATOR_VERSION = 2.2.83

defineReplace(cleanPath) {
    win32:1 ~= s|\\\\|/|g
    contains(1, ^/.*):pfx = /
    else:pfx =
    segs = $$split(1, /)
    out =
    for(seg, segs) {
        equals(seg, ..):out = $$member(out, 0, -2)
        else:!equals(seg, .):out += $$seg
    }
    return($$join(out, /, $$pfx))
}

defineReplace(targetPath) {
    return($$replace(1, /, $$QMAKE_DIR_SEP))
}

defineReplace(qtLibraryName) {
   unset(LIBRARY_NAME)
   LIBRARY_NAME = $$1
   CONFIG(debug, debug|release) {
      !debug_and_release|build_pass {
          mac:RET = $$member(LIBRARY_NAME, 0)_debug
              else:win32:RET = $$member(LIBRARY_NAME, 0)d
      }
   }
   isEmpty(RET):RET = $$LIBRARY_NAME
   return($$RET)
}

defineTest(minQtVersion) {
    maj = $$1
    min = $$2
    patch = $$3
    isEqual(QT_MAJOR_VERSION, $$maj) {
        isEqual(QT_MINOR_VERSION, $$min) {
            isEqual(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
            greaterThan(QT_PATCH_VERSION, $$patch) {
                return(true)
            }
        }
        greaterThan(QT_MINOR_VERSION, $$min) {
            return(true)
        }
    }
    return(false)
}

# For use in custom compilers which just copy files
win32:i_flag = i
defineReplace(stripSrcDir) {
    win32 {
        !contains(1, ^.:.*):1 = $$OUT_PWD/$$1
    } else {
        !contains(1, ^/.*):1 = $$OUT_PWD/$$1
    }
    out = $$cleanPath($$1)
    out ~= s|^$$re_escape($$PWD/)||$$i_flag
    return($$out)
}

isEmpty(TEST):CONFIG(debug, debug|release) {
    !debug_and_release|build_pass {
        TEST = 1
    }
}

isEmpty(IDE_LIBRARY_BASENAME) {
    IDE_LIBRARY_BASENAME = lib
}

DEFINES += IDE_LIBRARY_BASENAME=\\\"$$IDE_LIBRARY_BASENAME\\\"

equals(TEST, 1) {
    QT +=testlib
    DEFINES += WITH_TESTS
}

IDE_SOURCE_TREE = $$PWD
isEmpty(IDE_BUILD_TREE) {
    sub_dir = $$_PRO_FILE_PWD_
    sub_dir ~= s,^$$re_escape($$PWD),,
    IDE_BUILD_TREE = $$cleanPath($$OUT_PWD)
    IDE_BUILD_TREE ~= s,$$re_escape($$sub_dir)$,,
}
IDE_APP_PATH = $$IDE_BUILD_TREE/bin
macx {
    IDE_APP_TARGET   = "Qt Creator"
    IDE_LIBRARY_PATH = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/PlugIns
    IDE_PLUGIN_PATH  = $$IDE_LIBRARY_PATH
    IDE_LIBEXEC_PATH = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/Resources
    IDE_DATA_PATH    = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/Resources
    IDE_DOC_PATH     = $$IDE_DATA_PATH/doc
    IDE_BIN_PATH     = $$IDE_APP_PATH/$${IDE_APP_TARGET}.app/Contents/MacOS
    contains(QT_CONFIG, ppc):CONFIG += ppc x86
    copydata = 1
    isEmpty(TIGER_COMPAT_MODE):TIGER_COMPAT_MODE=$$(QTC_TIGER_COMPAT)
    isEmpty(TIGER_COMPAT_MODE) {
        QMAKE_CXXFLAGS *= -mmacosx-version-min=10.5
        QMAKE_LFLAGS *= -mmacosx-version-min=10.5
    }
} else {
    win32 {
        contains(TEMPLATE, vc.*)|contains(TEMPLATE_PREFIX, vc):vcproj = 1
        IDE_APP_TARGET   = qtcreator
    } else {
        IDE_APP_TARGET   = qtcreator
    }
    IDE_LIBRARY_PATH = $$IDE_BUILD_TREE/$$IDE_LIBRARY_BASENAME/qtcreator
    IDE_PLUGIN_PATH  = $$IDE_LIBRARY_PATH/plugins
    IDE_LIBEXEC_PATH = $$IDE_APP_PATH # FIXME
    IDE_DATA_PATH    = $$IDE_BUILD_TREE/share/qtcreator
    IDE_DOC_PATH     = $$IDE_BUILD_TREE/share/doc/qtcreator
    IDE_BIN_PATH     = $$IDE_APP_PATH
    !isEqual(IDE_SOURCE_TREE, $$IDE_BUILD_TREE):copydata = 1
}

INCLUDEPATH += \
    $$IDE_SOURCE_TREE/src/libs \
    $$IDE_SOURCE_TREE/tools \
    $$IDE_SOURCE_TREE/src/plugins

CONFIG += depend_includepath

LIBS += -L$$IDE_LIBRARY_PATH

#DEFINES += QT_NO_CAST_FROM_ASCII
DEFINES += QT_NO_CAST_TO_ASCII
!macx:DEFINES += QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_CONCATENATION

unix {
    CONFIG(debug, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/debug-shared
    CONFIG(release, debug|release):OBJECTS_DIR = $${OUT_PWD}/.obj/release-shared

    CONFIG(debug, debug|release):MOC_DIR = $${OUT_PWD}/.moc/debug-shared
    CONFIG(release, debug|release):MOC_DIR = $${OUT_PWD}/.moc/release-shared

    RCC_DIR = $${OUT_PWD}/.rcc
    UI_DIR = $${OUT_PWD}/.uic
}

win32-msvc* {
    #Don't warn about sprintf, fopen etc being 'unsafe'
    DEFINES += _CRT_SECURE_NO_WARNINGS
}


Tune UBSAN options

Tune UBSAN options

# Copyright 2018 Iakov Kirilenko, 2007-2017 QReal Research Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

!isEmpty(_PRO_FILE_):!isEmpty(CONFIG):isEmpty(GLOBAL_PRI_INCLUDED){
#GLOBAL_PRI_INCLUDED = $$PWD

win32 {
	PLATFORM = windows
}

unix:!macx {
	PLATFORM = linux
}

macx {
	PLATFORM = mac
}

CONFIG *= qt

!win32:CONFIG *= ltcg use_gold_linker
#CONFIG *= fat-lto

#deal with mixed configurations
CONFIG -= debug_and_release debug_and_release_target
CONFIG(debug, debug | release): CONFIG -= release
else:!debug:CONFIG *= release
release:CONFIG -= debug
no-sanitizers: CONFIG *= nosanitizers
CONFIG = $$unique(CONFIG)

CONFIG(debug) {
	CONFIGURATION = debug
	CONFIGURATION_SUFFIX = -d
	unix {
		QMAKE_CXXFLAGS += -coverage
		QMAKE_LFLAGS += -coverage
	}
} else {
	CONFIGURATION = release
	CONFIGURATION_SUFFIX =
}

#	CHECK_GCC_VERSION_5="test \"x$$CHECK_GCC_VERSION\" != x && echo \"$$CHECK_GCC_VERSION\" | grep -qe \'\\<5\\.[0-9]\\+\\.\'"
#	!clang:gcc:*-g++*:system($$CHECK_GCC_VERSION_5){

#CHECK_GCC_VERSION=$$system("$$QMAKE_CXX --version")
#!CONFIG(nosanitizers):!clang:gcc:*-g++*:system(test \"x$${CHECK_GCC_VERSION}\" = x  || echo \"$$CHECK_GCC_VERSION\" | grep -qe \'\\<4\\.[0-9]\\+\\.\')
!gcc4:!gcc5:!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\\<5\\.[0-9]+\\."' ){ CONFIG += gcc5 }
!gcc4:!gcc5:!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\\<4\\.[0-9]+\\."' ){ CONFIG += gcc4 }

GLOBAL_PWD = $$absolute_path($$PWD)

isEmpty(GLOBAL_DESTDIR) {
	GLOBAL_DESTDIR = $$GLOBAL_PWD/bin/$$CONFIGURATION
}

isEmpty(DESTDIR) {
	DESTDIR = $$GLOBAL_DESTDIR
}

PROJECT_BASENAME = $$basename(_PRO_FILE_)
PROJECT_NAME = $$section(PROJECT_BASENAME, ".", 0, 0)

isEmpty(TARGET) {
	TARGET = $$PROJECT_NAME$$CONFIGURATION_SUFFIX
} else {
	TARGET = $$TARGET$$CONFIGURATION_SUFFIX
}

equals(TEMPLATE, app) {
	!no_rpath {
		unix:!macx {
			QMAKE_LFLAGS += -Wl,-rpath-link,$$GLOBAL_DESTDIR
			QMAKE_LFLAGS += -Wl,-O1,-rpath,\'\$$ORIGIN\'
		} macx {
			QMAKE_LFLAGS += -rpath @executable_path
			QMAKE_LFLAGS += -rpath @executable_path/../Lib
			QMAKE_LFLAGS += -rpath @executable_path/../Frameworks
			QMAKE_LFLAGS += -rpath @executable_path/../../../
		}
	}
}

#Workaround for a known gcc/ld (before 7.3/bionic) issue
use_gold_linker:!clang: QMAKE_LFLAGS += -Wl,--disable-new-dtags

macx-clang {
	QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9
	QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
}

!nosanitizers:!clang:gcc:*-g++*:gcc4{
	warning("Disabled sanitizers, failed to detect compiler version or too old compiler: $$QMAKE_CXX")
	CONFIG += nosanitizers
}

!nosanitizers {
	CONFIG += sanitizer
}

unix:!nosanitizers {

	# seems like we want USan always, but are afraid of ....
	!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
		# Ubsan is turned on by default
		CONFIG += sanitizer sanitize_undefined
	}

	#LSan can be used without performance degrade even in release build
	#But at the moment we can not, because of Qt  problems
	CONFIG(debug):!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!macx-clang { CONFIG += sanitize_leak }

	sanitize_leak {
		QMAKE_CFLAGS += -fsanitize=leak
		QMAKE_CXXFLAGS += -fsanitize=leak
		QMAKE_LFLAGS += -fsanitize=leak
	}

	sanitize_undefined:macx-clang {
		# sometimes runtime is missing in clang. this hack allows to avoid runtime dependency.
		QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fsanitize-trap=undefined
		QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined
		QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fsanitize-trap=undefined
	}

	gcc5 {
		CONFIG(sanitize_undefined){
		# Ubsan has (had at least) known issues with false errors about calls of methods of the base class.
		# That must be disabled. Variables for confguring ubsan are taken from here:
		# https://codereview.qt-project.org/#/c/43420/17/mkspecs/common/sanitize.conf
		# They can change in some version of Qt, keep track of it.
		# By the way, simply setting QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS instead of those used below
		# will not work due to arguments order ("-fsanitize=undefined" must be declared before "-fno-sanitize=vptr").
#			QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fno-sanitize=vptr
#			QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fno-sanitize=vptr
#			QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fno-sanitize=vptr
		}
	}

	CONFIG(release){
		QMAKE_CFLAGS += -fsanitize-recover=all
		QMAKE_CXXFLAGS += -fsanitize-recover=all
	} else {
		QMAKE_CFLAGS += -fsanitize-recover=undefined
		QMAKE_CXXFLAGS += -fsanitize-recover=undefined
	}

}

OBJECTS_DIR = .build/$$CONFIGURATION/obj
MOC_DIR = .build/$$CONFIGURATION/moc
RCC_DIR = .build/$$CONFIGURATION/rcc
UI_DIR = .build/$$CONFIGURATION/ui

PRECOMPILED_HEADER = $$PWD/pch.h
CONFIG += precompile_header
#PRECOMPILED_SOURCE = $$_PRO_FILE_PWD_/precompile_header_dummy.cpp
QMAKE_CXX_FLAGS *= -Winvalid-pch

INCLUDEPATH += $$absolute_path($$_PRO_FILE_PWD_) \
	$$absolute_path($$_PRO_FILE_PWD_/include) \
	$$absolute_path($$PWD) \

CONFIG += c++11

QMAKE_CXXFLAGS += -pedantic-errors -Wextra #-Werror -Wno-error=reorder

!clang: QMAKE_CXXFLAGS += -ansi

gcc5 | clang {
	QMAKE_CXXFLAGS +=-Werror=pedantic -Werror=delete-incomplete
}

#treat git submodules as system path
SYSTEM_INCLUDE_PREFIX_OPTION += $$system(git submodule status 2>/dev/null | sed $$shell_quote('s/^.[0-9a-fA-F]* \\([^ ]*\\).*$/--system-header-prefix=\\1/g'))

#treat Qt includes as system headers
SYSTEM_INCLUDE_PREFIX_OPTION += --system-header-prefix=$$[QT_INSTALL_HEADERS]

clang:QMAKE_CXXFLAGS += $$SYSTEM_INCLUDE_PREFIX_OPTION

false:clang {
# Problem from Qt system headers
	QMAKE_CXXFLAGS += -Wno-error=expansion-to-defined
}

QMAKE_CXXFLAGS += -Werror=cast-qual -Werror=write-strings -Werror=redundant-decls -Werror=unreachable-code \
			-Werror=non-virtual-dtor -Wno-error=overloaded-virtual \
			-Werror=uninitialized -Werror=init-self

# Simple function that checks if given argument is a file or directory.
# Returns false if argument 1 is a file or does not exist.
defineTest(isDir) {
	exists($$system_path($$1/*)):return(true)
	return(false)
}

# Useful function to copy additional files to destination,
# from http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output
defineTest(copyToDestdir) {
	FILES = $$1
	NOW = $$2

	for(FILE, FILES) {
		DESTDIR_SUFFIX =
		AFTER_SLASH = $$section(FILE, "/", -1, -1)
		isDir($$FILE) {
			ABSOLUTE_PATH = $$absolute_path($$FILE, $$GLOBAL_PWD)
			BASE_NAME = $$section(ABSOLUTE_PATH, "/", -1, -1)
			DESTDIR_SUFFIX = $$BASE_NAME/
			FILE = $$FILE/*
		}

		DDIR = $$system_path($$DESTDIR/$$3$$DESTDIR_SUFFIX)
		FILE = $$system_path($$FILE)

		mkpath($$DDIR)

		win32 {
			# probably, xcopy needs /s and /e for directories
			COPY_DIR = "cmd.exe /C xcopy /f /y /i /s /e "
		} else {
			COPY_DIR = rsync -a
			!silent: COPY_DIR += -v
		}
		COPY_COMMAND = $$COPY_DIR $$quote($$FILE) $$quote($$DDIR)
		isEmpty(NOW) {
			QMAKE_POST_LINK += $$COPY_COMMAND $$escape_expand(\\n\\t)
		} else {
			system($$COPY_COMMAND)
		}
	}

	export(QMAKE_POST_LINK)
}

defineTest(includes) {
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		INCLUDEPATH += $$GLOBAL_PWD/$$PROJECT $$GLOBAL_PWD/$$PROJECT/include
	}

	export(INCLUDEPATH)
}

defineTest(links) {
	LIBS *= -L$$GLOBAL_DESTDIR
	LIBS *= -L$$DESTDIR
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		LIBS += -l$$PROJECT$$CONFIGURATION_SUFFIX
	}

	export(LIBS)
}

defineTest(noPch) {
	CONFIG -= precompile_header
	PRECOMPILED_HEADER =
	export(CONFIG)
	export(PRECOMPILED_HEADER)
}

defineTest(enableFlagIfCan) {
  system(echo $$shell_quote(int main(){return 0;}) | $$QMAKE_CXX $$QMAKE_CXXFLAGS $$1 -x c++ -c - -o $$system(mktemp) ) {
    QMAKE_CXXFLAGS += $$1
  export(QMAKE_CXXFLAGS)
  } else {
    message(Cannot enable $$1)
  }
}

CONFIG(noPch) {
	noPch()
}

} # GLOBAL_PRI_INCLUDED

# Copyright 2018 Iakov Kirilenko, 2007-2017 QReal Research Group
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

!isEmpty(_PRO_FILE_):!isEmpty(CONFIG):isEmpty(GLOBAL_PRI_INCLUDED){
#GLOBAL_PRI_INCLUDED = $$PWD

win32 {
	PLATFORM = windows
}

unix:!macx {
	PLATFORM = linux
}

macx {
	PLATFORM = mac
}

CONFIG *= qt

!win32:CONFIG *= ltcg use_gold_linker
#CONFIG *= fat-lto

#deal with mixed configurations
CONFIG -= debug_and_release debug_and_release_target
CONFIG(debug, debug | release): CONFIG -= release
else:!debug:CONFIG *= release
release:CONFIG -= debug
no-sanitizers: CONFIG *= nosanitizers
CONFIG = $$unique(CONFIG)

CONFIG(debug) {
	CONFIGURATION = debug
	CONFIGURATION_SUFFIX = -d
	unix {
		QMAKE_CXXFLAGS += -coverage
		QMAKE_LFLAGS += -coverage
	}
} else {
	CONFIGURATION = release
	CONFIGURATION_SUFFIX =
}

#	CHECK_GCC_VERSION_5="test \"x$$CHECK_GCC_VERSION\" != x && echo \"$$CHECK_GCC_VERSION\" | grep -qe \'\\<5\\.[0-9]\\+\\.\'"
#	!clang:gcc:*-g++*:system($$CHECK_GCC_VERSION_5){

#CHECK_GCC_VERSION=$$system("$$QMAKE_CXX --version")
#!CONFIG(nosanitizers):!clang:gcc:*-g++*:system(test \"x$${CHECK_GCC_VERSION}\" = x  || echo \"$$CHECK_GCC_VERSION\" | grep -qe \'\\<4\\.[0-9]\\+\\.\')
!gcc4:!gcc5:!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\\<5\\.[0-9]+\\."' ){ CONFIG += gcc5 }
!gcc4:!gcc5:!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\\<4\\.[0-9]+\\."' ){ CONFIG += gcc4 }

GLOBAL_PWD = $$absolute_path($$PWD)

isEmpty(GLOBAL_DESTDIR) {
	GLOBAL_DESTDIR = $$GLOBAL_PWD/bin/$$CONFIGURATION
}

isEmpty(DESTDIR) {
	DESTDIR = $$GLOBAL_DESTDIR
}

PROJECT_BASENAME = $$basename(_PRO_FILE_)
PROJECT_NAME = $$section(PROJECT_BASENAME, ".", 0, 0)

isEmpty(TARGET) {
	TARGET = $$PROJECT_NAME$$CONFIGURATION_SUFFIX
} else {
	TARGET = $$TARGET$$CONFIGURATION_SUFFIX
}

equals(TEMPLATE, app) {
	!no_rpath {
		unix:!macx {
			QMAKE_LFLAGS += -Wl,-rpath-link,$$GLOBAL_DESTDIR
			QMAKE_LFLAGS += -Wl,-O1,-rpath,\'\$$ORIGIN\'
		} macx {
			QMAKE_LFLAGS += -rpath @executable_path
			QMAKE_LFLAGS += -rpath @executable_path/../Lib
			QMAKE_LFLAGS += -rpath @executable_path/../Frameworks
			QMAKE_LFLAGS += -rpath @executable_path/../../../
		}
	}
}

#Workaround for a known gcc/ld (before 7.3/bionic) issue
use_gold_linker:!clang: QMAKE_LFLAGS += -Wl,--disable-new-dtags

macx-clang {
	QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9
	QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
}

!nosanitizers:!clang:gcc:*-g++*:gcc4{
	warning("Disabled sanitizers, failed to detect compiler version or too old compiler: $$QMAKE_CXX")
	CONFIG += nosanitizers
}

!nosanitizers {
	CONFIG += sanitizer
}

unix:!nosanitizers {

	# seems like we want USan always, but are afraid of ....
	!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
		# Ubsan is turned on by default
		CONFIG += sanitizer sanitize_undefined
	}

	#LSan can be used without performance degrade even in release build
	#But at the moment we can not, because of Qt  problems
	CONFIG(debug):!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!macx-clang { CONFIG += sanitize_leak }

	sanitize_leak {
		QMAKE_CFLAGS += -fsanitize=leak
		QMAKE_CXXFLAGS += -fsanitize=leak
		QMAKE_LFLAGS += -fsanitize=leak
	}

	sanitize_undefined:macx-clang {
		# sometimes runtime is missing in clang. this hack allows to avoid runtime dependency.
		QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fsanitize-trap=undefined
		QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined
		QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fsanitize-trap=undefined
	}

	gcc5 {
		CONFIG(sanitize_undefined){
		# Ubsan has (had at least) known issues with false errors about calls of methods of the base class.
		# That must be disabled. Variables for confguring ubsan are taken from here:
		# https://codereview.qt-project.org/#/c/43420/17/mkspecs/common/sanitize.conf
		# They can change in some version of Qt, keep track of it.
		# By the way, simply setting QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS instead of those used below
		# will not work due to arguments order ("-fsanitize=undefined" must be declared before "-fno-sanitize=vptr").
			QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fno-sanitize=vptr
			QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fno-sanitize=vptr
			QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fno-sanitize=vptr
		}
	}

	CONFIG(release){
		QMAKE_CFLAGS += -fsanitize-recover=all
		QMAKE_CXXFLAGS += -fsanitize-recover=all
	} else {
		QMAKE_CFLAGS += -fno-sanitize-recover=all
		QMAKE_CXXFLAGS += -fno-sanitize-recover=all
	}

}

OBJECTS_DIR = .build/$$CONFIGURATION/obj
MOC_DIR = .build/$$CONFIGURATION/moc
RCC_DIR = .build/$$CONFIGURATION/rcc
UI_DIR = .build/$$CONFIGURATION/ui

PRECOMPILED_HEADER = $$PWD/pch.h
CONFIG += precompile_header
#PRECOMPILED_SOURCE = $$_PRO_FILE_PWD_/precompile_header_dummy.cpp
QMAKE_CXX_FLAGS *= -Winvalid-pch

INCLUDEPATH += $$absolute_path($$_PRO_FILE_PWD_) \
	$$absolute_path($$_PRO_FILE_PWD_/include) \
	$$absolute_path($$PWD) \

CONFIG += c++11

QMAKE_CXXFLAGS += -pedantic-errors -Wextra #-Werror -Wno-error=reorder

!clang: QMAKE_CXXFLAGS += -ansi

gcc5 | clang {
	QMAKE_CXXFLAGS +=-Werror=pedantic -Werror=delete-incomplete
}

#treat git submodules as system path
SYSTEM_INCLUDE_PREFIX_OPTION += $$system(git submodule status 2>/dev/null | sed $$shell_quote('s/^.[0-9a-fA-F]* \\([^ ]*\\).*$/--system-header-prefix=\\1/g'))

#treat Qt includes as system headers
SYSTEM_INCLUDE_PREFIX_OPTION += --system-header-prefix=$$[QT_INSTALL_HEADERS]

clang:QMAKE_CXXFLAGS += $$SYSTEM_INCLUDE_PREFIX_OPTION

false:clang {
# Problem from Qt system headers
	QMAKE_CXXFLAGS += -Wno-error=expansion-to-defined
}

QMAKE_CXXFLAGS += -Werror=cast-qual -Werror=write-strings -Werror=redundant-decls -Werror=unreachable-code \
			-Werror=non-virtual-dtor -Wno-error=overloaded-virtual \
			-Werror=uninitialized -Werror=init-self

# Simple function that checks if given argument is a file or directory.
# Returns false if argument 1 is a file or does not exist.
defineTest(isDir) {
	exists($$system_path($$1/*)):return(true)
	return(false)
}

# Useful function to copy additional files to destination,
# from http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output
defineTest(copyToDestdir) {
	FILES = $$1
	NOW = $$2

	for(FILE, FILES) {
		DESTDIR_SUFFIX =
		AFTER_SLASH = $$section(FILE, "/", -1, -1)
		isDir($$FILE) {
			ABSOLUTE_PATH = $$absolute_path($$FILE, $$GLOBAL_PWD)
			BASE_NAME = $$section(ABSOLUTE_PATH, "/", -1, -1)
			DESTDIR_SUFFIX = $$BASE_NAME/
			FILE = $$FILE/*
		}

		DDIR = $$system_path($$DESTDIR/$$3$$DESTDIR_SUFFIX)
		FILE = $$system_path($$FILE)

		mkpath($$DDIR)

		win32 {
			# probably, xcopy needs /s and /e for directories
			COPY_DIR = "cmd.exe /C xcopy /f /y /i /s /e "
		} else {
			COPY_DIR = rsync -a
			!silent: COPY_DIR += -v
		}
		COPY_COMMAND = $$COPY_DIR $$quote($$FILE) $$quote($$DDIR)
		isEmpty(NOW) {
			QMAKE_POST_LINK += $$COPY_COMMAND $$escape_expand(\\n\\t)
		} else {
			system($$COPY_COMMAND)
		}
	}

	export(QMAKE_POST_LINK)
}

defineTest(includes) {
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		INCLUDEPATH += $$GLOBAL_PWD/$$PROJECT $$GLOBAL_PWD/$$PROJECT/include
	}

	export(INCLUDEPATH)
}

defineTest(links) {
	LIBS *= -L$$GLOBAL_DESTDIR
	LIBS *= -L$$DESTDIR
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		LIBS += -l$$PROJECT$$CONFIGURATION_SUFFIX
	}

	export(LIBS)
}

defineTest(noPch) {
	CONFIG -= precompile_header
	PRECOMPILED_HEADER =
	export(CONFIG)
	export(PRECOMPILED_HEADER)
}

defineTest(enableFlagIfCan) {
  system(echo $$shell_quote(int main(){return 0;}) | $$QMAKE_CXX $$QMAKE_CXXFLAGS $$1 -x c++ -c - -o $$system(mktemp) ) {
    QMAKE_CXXFLAGS += $$1
  export(QMAKE_CXXFLAGS)
  } else {
    message(Cannot enable $$1)
  }
}

CONFIG(noPch) {
	noPch()
}

} # GLOBAL_PRI_INCLUDED


Tream Qt includes as system include path

beacuse there is obsolete code there that induces warnings

# Copyright 2014 - 2018 CyberTech Co. Ltd., Yurii Litvinov, Iakov Kirilenko
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build settings common to all projects in TrikRuntime.
# Provides:
# CONFIGURATION_SUFFIX variable that shall be consistently used in TARGET and LIBS variables in all projects.
# copyToDestdir function to copy arbitrary files and directories to DESTDIR
# uses function to automatically add a library to INCLUDEPATH and LIBS.
#
# Uses environment variable INSTALL_ROOT as a root of a file structure for install rules.
#
# Uses CONFIG variable to control support for Google Sanitizers:
# - CONFIG+=sanitize-address will enable address sanitizer
# - CONFIG+=sanitize-undefined will enable undefined behavior sanitizer
# - CONFIG+=sanitize-thread will enable thread sanitizer

!isEmpty(_PRO_FILE_):!isEmpty(CONFIG):isEmpty(GLOBAL_PRI_INCLUDED){
# commented out, seems like there is no need for this var, but let's wait
false:GLOBAL_PRI_INCLUDED=1

COMPILER = $$(CXX)
!isEmpty(QMAKE_GCC_MAJOR_VERSION) {
	COMPILER_VERSION=$${QMAKE_GCC_MAJOR_VERSION}.$${QMAKE_GCC_MINOR_VERSION}
}

COMPILER_IS_ARM = $$find(COMPILER, arm-.*)

PYTHONQTALL_CONFIG=PythonQtCore

count(COMPILER_IS_ARM, 1) {
	ARCHITECTURE = arm
} else {
	ARCHITECTURE = x86
}

win32 {
	PLATFORM = windows
}

unix:!macx {
	PLATFORM = linux
}

macx {
	PLATFORM = mac
}

CONFIG *= qt

CONFIG -= app_bundle

!win32:CONFIG *= use_gold_linker
#CONFIG *= fat-lto

#deal with mixed configurations
CONFIG -= debug_and_release debug_and_release_target
CONFIG(debug, debug | release): CONFIG -= release
else:!debug:CONFIG *= release
release:CONFIG -= debug
no-sanitizers: CONFIG *= nosanitizers
CONFIG = $$unique(CONFIG)

QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += -Og

CONFIG(debug) {
	isEmpty(CONFIGURATION): CONFIGURATION = $$ARCHITECTURE-debug
	unix {
		QMAKE_CXXFLAGS += -coverage
		QMAKE_LFLAGS += -coverage
	}
	CONFIGURATION_SUFFIX=
} else {
	isEmpty(CONFIGURATION): CONFIGURATION = $$ARCHITECTURE-release
	CONFIGURATION_SUFFIX=
}

!gcc4:!gcc5:!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\\<5\\.[0-9]+\\."' ){ CONFIG += gcc5 }
!gcc4:!gcc5:!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\\<4\\.[0-9]+\\."' ){ CONFIG += gcc4 }

GLOBAL_PWD = $$absolute_path($$PWD)
GLOBAL_OUTPWD = $$absolute_path($$OUT_PWD)

isEmpty(GLOBAL_DESTDIR) {
	GLOBAL_DESTDIR = $$GLOBAL_OUTPWD/bin/$$CONFIGURATION
}
isEmpty(DESTDIR) {
	DESTDIR = $$GLOBAL_DESTDIR
}

PROJECT_BASENAME = $$basename(_PRO_FILE_)
PROJECT_NAME = $$section(PROJECT_BASENAME, ".", 0, 0)

isEmpty(TARGET) {
	TARGET = $$PROJECT_NAME$$CONFIGURATION_SUFFIX
} else {
	R=$$find( TARGET, "$$CONFIGURATION_SUFFIX$" )
	isEmpty(R):TARGET = $$TARGET$$CONFIGURATION_SUFFIX
}

equals(TEMPLATE, app) {
	!no_rpath {
		unix:!macx {
			QMAKE_LFLAGS += -Wl,-rpath-link,$$GLOBAL_DESTDIR
			QMAKE_LFLAGS += -Wl,-O1,-rpath,\'\$$ORIGIN\'
		} macx {
			QMAKE_LFLAGS += -rpath @executable_path
			QMAKE_LFLAGS += -rpath @executable_path/../Lib
			QMAKE_LFLAGS += -rpath @executable_path/../Frameworks
			QMAKE_LFLAGS += -rpath @executable_path/../../../
		}
	}
} else:equals(TEMPLATE, lib){

	CONFIG += create_pc create_libtool
	QMAKE_PKGCONFIG_NAME=$$TARGET
	QMAKE_PKGCONFIG_PREFIX = $$INSTALLBASE
	QMAKE_PKGCONFIG_LIBDIR = $$target.path
	QMAKE_PKGCONFIG_INCDIR = $$headers.path
	QMAKE_PKGCONFIG_VERSION = $$VERSION
#	QMAKE_PKGCONFIG_DESCRIPTION =
}

#Workaround for a known gcc/ld (before 7.3/bionic) issue
use_gold_linker:!clang: QMAKE_LFLAGS += -Wl,--disable-new-dtags

macx-clang {
	QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9
	QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
}

!nosanitizers:!clang:gcc:*-g++*:gcc4{
	warning("Disabled sanitizers, failed to detect compiler version or too old compiler: $$QMAKE_CXX")
	CONFIG += nosanitizers
}

!nosanitizers {
	CONFIG += sanitizer
}

unix:!nosanitizers {

	# seems like we want USan always, but are afraid of ....
	!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
		# Ubsan is turned on by default
		#CONFIG += sanitizer sanitize_undefined
		#QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined -fsanitize-undefined-trap-on-error
	}

	CONFIG(sanitize_address) {
	# GCC 5.5 does not know this
	#	QMAKE_SANITIZE_ADDRESS_CXXFLAGS += -fsanitize-address-use-after-scope
		!clang:QMAKE_LFLAGS_RELEASE *= -static-libasan
	}
	#LSan can be used without performance degrade even in release build
	#But at the moment we can not, because of Qt  problems
	CONFIG(debug):!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!macx-clang { CONFIG += sanitize_leak }

	sanitize_leak {
		QMAKE_CFLAGS *= -fsanitize=leak
		QMAKE_CXXFLAGS *= -fsanitize=leak
		QMAKE_LFLAGS *= -fsanitize=leak
		!clang:QMAKE_LFLAGS_RELEASE *= -static-liblsan
	}

	sanitize_undefined {
		macx-clang {
		# sometimes runtime is missing in clang. this hack allows to avoid runtime dependency.
		#QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fsanitize-trap=undefined
		#QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined
		#QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fsanitize-trap=undefined
		}
		!clang:QMAKE_LFLAGS_RELEASE *= -static-libubsan
	}

	sanitize_thread {
		!clang:QMAKE_LFLAGS_RELEASE *= -static-libtsan
	}

	gcc5 {
		CONFIG(sanitize_undefined){
		# Ubsan has (had at least) known issues with false errors about calls of methods of the base class.
		# That must be disabled. Variables for confguring ubsan are taken from here:
		# https://codereview.qt-project.org/#/c/43420/17/mkspecs/common/sanitize.conf
		# They can change in some version of Qt, keep track of it.
		# By the way, simply setting QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS instead of those used below
		# will not work due to arguments order ("-fsanitize=undefined" must be declared before "-fno-sanitize=vptr").

# Useless since 2019? Commented out.
#			QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fno-sanitize=vptr
#			QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fno-sanitize=vptr
#			QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fno-sanitize=vptr
		}
	}

	QMAKE_CFLAGS += -fno-sanitize-recover=all
	QMAKE_CXXFLAGS += -fno-sanitize-recover=all
}

OBJECTS_DIR = .build/$$CONFIGURATION/obj
MOC_DIR = .build/$$CONFIGURATION/moc
RCC_DIR = .build/$$CONFIGURATION/rcc
UI_DIR = .build/$$CONFIGURATION/ui

CONFIG += precompile_header
precompile_header {
	PRECOMPILED_HEADER = $$PWD/pch.h
	QMAKE_CXXFLAGS *= -Wno-error=invalid-pch
}

INCLUDEPATH += $$_PRO_FILE_PWD_ \
	$$_PRO_FILE_PWD_/include/$$PROJECT_NAME \

THIS_IS_QS_LOG=$$find(PROJECT_NAME, [qQ]s[lL]og)
isEmpty(THIS_IS_QS_LOG) {
	INCLUDEPATH += $$GLOBAL_PWD/qslog
}

CONFIG += c++11

DEFINES += QT_FORCE_ASSERTS

QMAKE_CXXFLAGS += -pedantic-errors -Wextra -Werror

!clang: QMAKE_CXXFLAGS += -ansi

gcc5 | clang {
	QMAKE_CXXFLAGS +=-Werror=pedantic -Werror=delete-incomplete
}

clang {
	#treat git submodules as system path
	SYSTEM_INCLUDE_PREFIX_OPTION += $$system(git submodule status 2>/dev/null | sed $$shell_quote('s/^.[0-9a-fA-F]* \\([^ ]*\\).*$/--system-header-prefix=\\1/g'))

	#treat Qt includes as system headers
	SYSTEM_INCLUDE_PREFIX_OPTION += --system-header-prefix=$$[QT_INSTALL_HEADERS]
}

gcc {
	#treat Qt includes as system headers
	SYSTEM_INCLUDE_PREFIX_OPTION *= -isystem $$[QT_INSTALL_HEADERS]
}

QMAKE_CXXFLAGS += $$SYSTEM_INCLUDE_PREFIX_OPTION

false:clang {
# Problem from Qt system headers
	QMAKE_CXXFLAGS += -Wno-error=expansion-to-defined -Wno-error=c++98-compat -Wno-error=sign-conversion \
			-Wno-error=covered-switch-default -Wno-error=c++98-compat-pedantic \
			-Wno-error=documentation-unknown-command -Wno-error=inconsistent-missing-destructor-override \
			-Wno-error=used-but-marked-unused -Wno-error=extra-semi-stmt -Wno-error=padded \
			-Wno-error=float-equal -Wno-error=float-conversion -Wno-error=implicit-float-conversion \
			-Wno-error=redundant-parens -Wno-error=deprecated -Wno-error=shift-sign-overflow \
			-Wno-error=zero-as-null-pointer-constant -Wno-error=exit-time-destructors \
			-Wno-error=double-promotion -Wno-error=shadow-field -Wno-error=documentation \
			-Wno-error=reserved-id-macro -Wno-error=extra-semi -Wno-error=comma
}

QMAKE_CXXFLAGS += -Werror=cast-qual -Werror=write-strings -Werror=redundant-decls -Werror=unreachable-code \
			-Werror=non-virtual-dtor -Wno-error=overloaded-virtual \
			-Werror=uninitialized -Werror=init-self

gcc4:QMAKE_CXXFLAGS += -Wno-error=missing-field-initializers

# Simple function that checks if given argument is a file or directory.
# Returns false if argument 1 is a file or does not exist.
defineTest(isDir) {
	exists($$system_path($$1/*)):return(true)
	return(false)
}

# Useful function to copy additional files to destination,
# from http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output
defineTest(copyToDestdir) {
	FILES = $$1
	NOW = $$2

	for(FILE, FILES) {
		DESTDIR_SUFFIX =
		AFTER_SLASH = $$section(FILE, "/", -1, -1)
		isDir($$FILE) {
			ABSOLUTE_PATH = $$absolute_path($$FILE, $$GLOBAL_PWD)
			BASE_NAME = $$section(ABSOLUTE_PATH, "/", -1, -1)
			DESTDIR_SUFFIX = $$BASE_NAME/
			FILE = $$FILE/*
		}

		DDIR = $$quote($$system_path($$DESTDIR/$$3$$DESTDIR_SUFFIX))
		FILE = $$quote($$system_path($$FILE))

		mkpath($$DDIR)

		win32 {
			# probably, xcopy needs /s and /e for directories
			COPY_DIR = "cmd.exe /C xcopy /y /i /s /e "
			!silent: COPY_DIR += /f
		} else {
			COPY_DIR = rsync -a
			!silent: COPY_DIR += -v
		}

		COPY_COMMAND = $$COPY_DIR $$FILE $$DDIR
		isEmpty(NOW) {
			QMAKE_POST_LINK += $$COPY_COMMAND $$escape_expand(\\n\\t)
		} else {
			system($$COPY_COMMAND)
		}
	}

	export(QMAKE_POST_LINK)
}

defineTest(interfaceIncludes) {
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		INCLUDEPATH *= $$GLOBAL_PWD/$$PROJECT/include
	}

	export(INCLUDEPATH)
}

defineTest(implementationIncludes) {
	interfaceIncludes($$1)
}

defineTest(transitiveIncludes) {
	interfaceIncludes($$1)
}

defineTest(PythonQtIncludes) {
	INCLUDEPATH += $$GLOBAL_PWD/PythonQt/PythonQt/src
	export(INCLUDEPATH)
}

defineTest(links) {
	LIBS *= -L$$GLOBAL_DESTDIR
	LIBS *= -L$$DESTDIR
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		LIBS += -l$$PROJECT$$CONFIGURATION_SUFFIX
	}

	export(LIBS)
}

defineTest(installs) {
	unix {
		equals(TEMPLATE, lib) {
			target.path = $$INSTALL_ROOT/usr/lib/
			isEmpty(PUBLIC_HEADERS) {
				headers.files = $$HEADERS
				headers.path = $$INSTALL_ROOT/usr/include/$$PROJECT_NAME/
			} else {
				headers.files = $$PUBLIC_HEADERS
				headers.path = $$INSTALL_ROOT/usr/include/$$PROJECT_NAME/
			}
		}

		equals(TEMPLATE, app) {
			target.path = $$INSTALL_ROOT/usr/bin/
		}

		INSTALLS += target
		export(target.path)

		equals(TEMPLATE, lib) {
			INSTALLS += headers
			export(headers.files)
			export(headers.path)
		}

		export(INSTALLS)
	}

	HEADERS += $$PUBLIC_HEADERS
	export(HEADERS)
}

defineTest(installAdditionalConfigs) {
	FILES = $$1

	unix {
		additionalConfigs.files += $$FILES
		additionalConfigs.path = $$INSTALL_ROOT/etc/trik/trikRuntime/

		INSTALLS += additionalConfigs

		export(additionalConfigs.path)
		export(additionalConfigs.files)
		export(INSTALLS)
	}
}

defineTest(installAdditionalSharedFiles) {
	FILES = $$1

	unix {
		additionalSharedFiles.files += $$FILES
		additionalSharedFiles.path = $$INSTALL_ROOT/usr/share/trikRuntime/

		INSTALLS *= additionalSharedFiles

		export(additionalSharedFiles.path)
		export(additionalSharedFiles.files)
		export(INSTALLS)
	}
}

defineTest(noPch) {
	CONFIG -= precompile_header
	PRECOMPILED_HEADER =
	export(CONFIG)
	export(PRECOMPILED_HEADER)
}

defineTest(enableFlagIfCan) {
  system(echo $$shell_quote(int main(){return 0;}) | $$QMAKE_CXX $$QMAKE_CXXFLAGS $$1 -x c++ -c - -o $$system(mktemp) 2>/dev/null ) {
	QMAKE_CXXFLAGS += $$1
	export(QMAKE_CXXFLAGS)
  } else {
	message(Cannot enable $$1)
  }
}

CONFIG(noPch) {
	noPch()
}
} # GLOBAL_PRI_INCLUDED

# Copyright 2014 - 2018 CyberTech Co. Ltd., Yurii Litvinov, Iakov Kirilenko
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#	  http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Build settings common to all projects in TrikRuntime.
# Provides:
# CONFIGURATION_SUFFIX variable that shall be consistently used in TARGET and LIBS variables in all projects.
# copyToDestdir function to copy arbitrary files and directories to DESTDIR
# uses function to automatically add a library to INCLUDEPATH and LIBS.
#
# Uses environment variable INSTALL_ROOT as a root of a file structure for install rules.
#
# Uses CONFIG variable to control support for Google Sanitizers:
# - CONFIG+=sanitize-address will enable address sanitizer
# - CONFIG+=sanitize-undefined will enable undefined behavior sanitizer
# - CONFIG+=sanitize-thread will enable thread sanitizer

!isEmpty(_PRO_FILE_):!isEmpty(CONFIG):isEmpty(GLOBAL_PRI_INCLUDED){
# commented out, seems like there is no need for this var, but let's wait
false:GLOBAL_PRI_INCLUDED=1

COMPILER = $$(CXX)
!isEmpty(QMAKE_GCC_MAJOR_VERSION) {
	COMPILER_VERSION=$${QMAKE_GCC_MAJOR_VERSION}.$${QMAKE_GCC_MINOR_VERSION}
}

COMPILER_IS_ARM = $$find(COMPILER, arm-.*)

PYTHONQTALL_CONFIG=PythonQtCore

count(COMPILER_IS_ARM, 1) {
	ARCHITECTURE = arm
} else {
	ARCHITECTURE = x86
}

win32 {
	PLATFORM = windows
}

unix:!macx {
	PLATFORM = linux
}

macx {
	PLATFORM = mac
}

CONFIG *= qt

CONFIG -= app_bundle

!win32:CONFIG *= use_gold_linker
#CONFIG *= fat-lto

#deal with mixed configurations
CONFIG -= debug_and_release debug_and_release_target
CONFIG(debug, debug | release): CONFIG -= release
else:!debug:CONFIG *= release
release:CONFIG -= debug
no-sanitizers: CONFIG *= nosanitizers
CONFIG = $$unique(CONFIG)

QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += -Og

CONFIG(debug) {
	isEmpty(CONFIGURATION): CONFIGURATION = $$ARCHITECTURE-debug
	unix {
		QMAKE_CXXFLAGS += -coverage
		QMAKE_LFLAGS += -coverage
	}
	CONFIGURATION_SUFFIX=
} else {
	isEmpty(CONFIGURATION): CONFIGURATION = $$ARCHITECTURE-release
	CONFIGURATION_SUFFIX=
}

!gcc4:!gcc5:!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\\<5\\.[0-9]+\\."' ){ CONFIG += gcc5 }
!gcc4:!gcc5:!clang:!win32:gcc:*-g++*:system($$QMAKE_CXX --version | grep -qEe '"\\<4\\.[0-9]+\\."' ){ CONFIG += gcc4 }

GLOBAL_PWD = $$absolute_path($$PWD)
GLOBAL_OUTPWD = $$absolute_path($$OUT_PWD)

isEmpty(GLOBAL_DESTDIR) {
	GLOBAL_DESTDIR = $$GLOBAL_OUTPWD/bin/$$CONFIGURATION
}
isEmpty(DESTDIR) {
	DESTDIR = $$GLOBAL_DESTDIR
}

PROJECT_BASENAME = $$basename(_PRO_FILE_)
PROJECT_NAME = $$section(PROJECT_BASENAME, ".", 0, 0)

isEmpty(TARGET) {
	TARGET = $$PROJECT_NAME$$CONFIGURATION_SUFFIX
} else {
	R=$$find( TARGET, "$$CONFIGURATION_SUFFIX$" )
	isEmpty(R):TARGET = $$TARGET$$CONFIGURATION_SUFFIX
}

equals(TEMPLATE, app) {
	!no_rpath {
		unix:!macx {
			QMAKE_LFLAGS += -Wl,-rpath-link,$$GLOBAL_DESTDIR
			QMAKE_LFLAGS += -Wl,-O1,-rpath,\'\$$ORIGIN\'
		} macx {
			QMAKE_LFLAGS += -rpath @executable_path
			QMAKE_LFLAGS += -rpath @executable_path/../Lib
			QMAKE_LFLAGS += -rpath @executable_path/../Frameworks
			QMAKE_LFLAGS += -rpath @executable_path/../../../
		}
	}
} else:equals(TEMPLATE, lib){

	CONFIG += create_pc create_libtool
	QMAKE_PKGCONFIG_NAME=$$TARGET
	QMAKE_PKGCONFIG_PREFIX = $$INSTALLBASE
	QMAKE_PKGCONFIG_LIBDIR = $$target.path
	QMAKE_PKGCONFIG_INCDIR = $$headers.path
	QMAKE_PKGCONFIG_VERSION = $$VERSION
#	QMAKE_PKGCONFIG_DESCRIPTION =
}

#Workaround for a known gcc/ld (before 7.3/bionic) issue
use_gold_linker:!clang: QMAKE_LFLAGS += -Wl,--disable-new-dtags

macx-clang {
	QMAKE_MACOSX_DEPLOYMENT_TARGET=10.9
	QMAKE_LFLAGS_SONAME = -Wl,-install_name,@rpath/
}

!nosanitizers:!clang:gcc:*-g++*:gcc4{
	warning("Disabled sanitizers, failed to detect compiler version or too old compiler: $$QMAKE_CXX")
	CONFIG += nosanitizers
}

!nosanitizers {
	CONFIG += sanitizer
}

unix:!nosanitizers {

	# seems like we want USan always, but are afraid of ....
	!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!CONFIG(sanitize_memory):!CONFIG(sanitize_kernel_address) {
		# Ubsan is turned on by default
		#CONFIG += sanitizer sanitize_undefined
		#QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined -fsanitize-undefined-trap-on-error
	}

	CONFIG(sanitize_address) {
	# GCC 5.5 does not know this
	#	QMAKE_SANITIZE_ADDRESS_CXXFLAGS += -fsanitize-address-use-after-scope
		!clang:QMAKE_LFLAGS_RELEASE *= -static-libasan
	}
	#LSan can be used without performance degrade even in release build
	#But at the moment we can not, because of Qt  problems
	CONFIG(debug):!CONFIG(sanitize_address):!CONFIG(sanitize_thread):!macx-clang { CONFIG += sanitize_leak }

	sanitize_leak {
		QMAKE_CFLAGS *= -fsanitize=leak
		QMAKE_CXXFLAGS *= -fsanitize=leak
		QMAKE_LFLAGS *= -fsanitize=leak
		!clang:QMAKE_LFLAGS_RELEASE *= -static-liblsan
	}

	sanitize_undefined {
		macx-clang {
		# sometimes runtime is missing in clang. this hack allows to avoid runtime dependency.
		#QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fsanitize-trap=undefined
		#QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fsanitize-trap=undefined
		#QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fsanitize-trap=undefined
		}
		!clang:QMAKE_LFLAGS_RELEASE *= -static-libubsan
	}

	sanitize_thread {
		!clang:QMAKE_LFLAGS_RELEASE *= -static-libtsan
	}

	gcc5 {
		CONFIG(sanitize_undefined){
		# Ubsan has (had at least) known issues with false errors about calls of methods of the base class.
		# That must be disabled. Variables for confguring ubsan are taken from here:
		# https://codereview.qt-project.org/#/c/43420/17/mkspecs/common/sanitize.conf
		# They can change in some version of Qt, keep track of it.
		# By the way, simply setting QMAKE_CFLAGS, QMAKE_CXXFLAGS and QMAKE_LFLAGS instead of those used below
		# will not work due to arguments order ("-fsanitize=undefined" must be declared before "-fno-sanitize=vptr").

# Useless since 2019? Commented out.
#			QMAKE_SANITIZE_UNDEFINED_CFLAGS += -fno-sanitize=vptr
#			QMAKE_SANITIZE_UNDEFINED_CXXFLAGS += -fno-sanitize=vptr
#			QMAKE_SANITIZE_UNDEFINED_LFLAGS += -fno-sanitize=vptr
		}
	}

	QMAKE_CFLAGS += -fno-sanitize-recover=all
	QMAKE_CXXFLAGS += -fno-sanitize-recover=all
}

OBJECTS_DIR = .build/$$CONFIGURATION/obj
MOC_DIR = .build/$$CONFIGURATION/moc
RCC_DIR = .build/$$CONFIGURATION/rcc
UI_DIR = .build/$$CONFIGURATION/ui

CONFIG += precompile_header
precompile_header {
	PRECOMPILED_HEADER = $$PWD/pch.h
	QMAKE_CXXFLAGS *= -Wno-error=invalid-pch
}

INCLUDEPATH += $$_PRO_FILE_PWD_ \
	$$_PRO_FILE_PWD_/include/$$PROJECT_NAME \

THIS_IS_QS_LOG=$$find(PROJECT_NAME, [qQ]s[lL]og)
isEmpty(THIS_IS_QS_LOG) {
	INCLUDEPATH += $$GLOBAL_PWD/qslog
}

CONFIG += c++11

DEFINES += QT_FORCE_ASSERTS

QMAKE_CXXFLAGS += -pedantic-errors -Wextra -Werror

!clang: QMAKE_CXXFLAGS += -ansi

gcc5 | clang {
	QMAKE_CXXFLAGS +=-Werror=pedantic -Werror=delete-incomplete
}

clang {
	#treat git submodules as system path
	SYSTEM_INCLUDE_PREFIX_OPTION += $$system(git submodule status 2>/dev/null | sed $$shell_quote('s/^.[0-9a-fA-F]* \\([^ ]*\\).*$/--system-header-prefix=\\1/g'))

	#treat Qt includes as system headers
	SYSTEM_INCLUDE_PREFIX_OPTION += --system-header-prefix=$$[QT_INSTALL_HEADERS]

	QMAKE_CXXFLAGS += $$SYSTEM_INCLUDE_PREFIX_OPTION
}

false:clang {
# Problem from Qt system headers
	QMAKE_CXXFLAGS += -Wno-error=expansion-to-defined -Wno-error=c++98-compat -Wno-error=sign-conversion \
			-Wno-error=covered-switch-default -Wno-error=c++98-compat-pedantic \
			-Wno-error=documentation-unknown-command -Wno-error=inconsistent-missing-destructor-override \
			-Wno-error=used-but-marked-unused -Wno-error=extra-semi-stmt -Wno-error=padded \
			-Wno-error=float-equal -Wno-error=float-conversion -Wno-error=implicit-float-conversion \
			-Wno-error=redundant-parens -Wno-error=deprecated -Wno-error=shift-sign-overflow \
			-Wno-error=zero-as-null-pointer-constant -Wno-error=exit-time-destructors \
			-Wno-error=double-promotion -Wno-error=shadow-field -Wno-error=documentation \
			-Wno-error=reserved-id-macro -Wno-error=extra-semi -Wno-error=comma
}

QMAKE_CXXFLAGS += -Werror=cast-qual -Werror=write-strings -Werror=redundant-decls -Werror=unreachable-code \
			-Werror=non-virtual-dtor -Wno-error=overloaded-virtual \
			-Werror=uninitialized -Werror=init-self

gcc4:QMAKE_CXXFLAGS += -Wno-error=missing-field-initializers

# Simple function that checks if given argument is a file or directory.
# Returns false if argument 1 is a file or does not exist.
defineTest(isDir) {
	exists($$system_path($$1/*)):return(true)
	return(false)
}

# Useful function to copy additional files to destination,
# from http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output
defineTest(copyToDestdir) {
	FILES = $$1
	NOW = $$2

	for(FILE, FILES) {
		DESTDIR_SUFFIX =
		AFTER_SLASH = $$section(FILE, "/", -1, -1)
		isDir($$FILE) {
			ABSOLUTE_PATH = $$absolute_path($$FILE, $$GLOBAL_PWD)
			BASE_NAME = $$section(ABSOLUTE_PATH, "/", -1, -1)
			DESTDIR_SUFFIX = $$BASE_NAME/
			FILE = $$FILE/*
		}

		DDIR = $$quote($$system_path($$DESTDIR/$$3$$DESTDIR_SUFFIX))
		FILE = $$quote($$system_path($$FILE))

		mkpath($$DDIR)

		win32 {
			# probably, xcopy needs /s and /e for directories
			COPY_DIR = "cmd.exe /C xcopy /y /i /s /e "
			!silent: COPY_DIR += /f
		} else {
			COPY_DIR = rsync -a
			!silent: COPY_DIR += -v
		}

		COPY_COMMAND = $$COPY_DIR $$FILE $$DDIR
		isEmpty(NOW) {
			QMAKE_POST_LINK += $$COPY_COMMAND $$escape_expand(\\n\\t)
		} else {
			system($$COPY_COMMAND)
		}
	}

	export(QMAKE_POST_LINK)
}

defineTest(interfaceIncludes) {
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		INCLUDEPATH *= $$GLOBAL_PWD/$$PROJECT/include
	}

	export(INCLUDEPATH)
}

defineTest(implementationIncludes) {
	interfaceIncludes($$1)
}

defineTest(transitiveIncludes) {
	interfaceIncludes($$1)
}

defineTest(PythonQtIncludes) {
	INCLUDEPATH += $$GLOBAL_PWD/PythonQt/PythonQt/src
	export(INCLUDEPATH)
}

defineTest(links) {
	LIBS *= -L$$GLOBAL_DESTDIR
	LIBS *= -L$$DESTDIR
	PROJECTS = $$1

	for(PROJECT, PROJECTS) {
		LIBS += -l$$PROJECT$$CONFIGURATION_SUFFIX
	}

	export(LIBS)
}

defineTest(installs) {
	unix {
		equals(TEMPLATE, lib) {
			target.path = $$INSTALL_ROOT/usr/lib/
			isEmpty(PUBLIC_HEADERS) {
				headers.files = $$HEADERS
				headers.path = $$INSTALL_ROOT/usr/include/$$PROJECT_NAME/
			} else {
				headers.files = $$PUBLIC_HEADERS
				headers.path = $$INSTALL_ROOT/usr/include/$$PROJECT_NAME/
			}
		}

		equals(TEMPLATE, app) {
			target.path = $$INSTALL_ROOT/usr/bin/
		}

		INSTALLS += target
		export(target.path)

		equals(TEMPLATE, lib) {
			INSTALLS += headers
			export(headers.files)
			export(headers.path)
		}

		export(INSTALLS)
	}

	HEADERS += $$PUBLIC_HEADERS
	export(HEADERS)
}

defineTest(installAdditionalConfigs) {
	FILES = $$1

	unix {
		additionalConfigs.files += $$FILES
		additionalConfigs.path = $$INSTALL_ROOT/etc/trik/trikRuntime/

		INSTALLS += additionalConfigs

		export(additionalConfigs.path)
		export(additionalConfigs.files)
		export(INSTALLS)
	}
}

defineTest(installAdditionalSharedFiles) {
	FILES = $$1

	unix {
		additionalSharedFiles.files += $$FILES
		additionalSharedFiles.path = $$INSTALL_ROOT/usr/share/trikRuntime/

		INSTALLS *= additionalSharedFiles

		export(additionalSharedFiles.path)
		export(additionalSharedFiles.files)
		export(INSTALLS)
	}
}

defineTest(noPch) {
	CONFIG -= precompile_header
	PRECOMPILED_HEADER =
	export(CONFIG)
	export(PRECOMPILED_HEADER)
}

defineTest(enableFlagIfCan) {
  system(echo $$shell_quote(int main(){return 0;}) | $$QMAKE_CXX $$QMAKE_CXXFLAGS $$1 -x c++ -c - -o $$system(mktemp) 2>/dev/null ) {
	QMAKE_CXXFLAGS += $$1
	export(QMAKE_CXXFLAGS)
  } else {
	message(Cannot enable $$1)
  }
}

CONFIG(noPch) {
	noPch()
}
} # GLOBAL_PRI_INCLUDED


не создавать хлама внутри студии

не создавать хлама внутри студии

win32 | win32-msvc* {
        CONFIG(debug, debug|release) {
                QMAKE_QRXC = $$PWD/debug/qrxc.exe
        } else:CONFIG(release, debug|release){
                QMAKE_QRXC = $$PWD/release/qrxc.exe
        } else {
                error(Windows build definitely needs to be fixed)
        }
} else {
        QMAKE_QRXC = $$PWD/qrxc
}

INPUT = $$QREAL_XML$$quote(.xml)

qrxc_source.commands = $$QMAKE_QRXC $$INPUT generated/${QMAKE_FILE_IN_BASE}.pro
qrxc_source.input = INPUT
qrxc_source.output = generated/pluginInterface.cpp
qrxc_source.variable_out = SOURCES
qrxc_source.name = QReal_XML_Compiler

QMAKE_EXTRA_COMPILERS += qrxc_source

qrxc_header.commands = $$FAKE
qrxc_header.input = INPUT
qrxc_header.output = generated/pluginInterface.h
qrxc_header.variable_out = HEADERS

QMAKE_EXTRA_COMPILERS += qrxc_header

qrxc_resource.commands = $$FAKE
qrxc_resource.input = INPUT
qrxc_resource.output = $$quote(generated/shapes/)$$QREAL_XML$$quote(.qrc)
qrxc_resource.variable_out = RESOURCES

QMAKE_EXTRA_COMPILERS += qrxc_resource

SDF_FILES = $$files($$quote(..\qrxml\)$$QREAL_XML$$quote(\generated\shapes\*.sdf))
#message($$SDF_FILES)

defineTest(addExtraCompiler) {
    eval($${1}.commands = $$FAKE)
    eval($${1}.input = INPUT)
	eval($${1}.output = $${2})
    eval($${1}.variable_out = GENERATED_RESOURCES)

    export($${1}.output)
    export($${1}.input)
    export($${1}.commands)
    export($${1}.variable_out)

    QMAKE_EXTRA_COMPILERS += $${1}

    export(QMAKE_EXTRA_COMPILERS)

    return(true)
}

for(sdfFile,SDF_FILES) {
	FILE_NAME_LONG = $${sdfFile}
	COMPILER_NAME_LONG = $$section(FILE_NAME_LONG,"/",1,1)
	COMPILER_NAME = $$section(COMPILER_NAME_LONG,".",0,0)
	FILE_NAME = $$quote(generated/shapes/)$$COMPILER_NAME$$quote(.sdf)

	addExtraCompiler($$COMPILER_NAME, $$FILE_NAME)
}

COMMAND = cd $$quote(..\qrxml\)$$QREAL_XML\ && $$QMAKE_QRXC $$QREAL_XML$$quote(.xml) $$quote(generated/)$$QREAL_XML$$quote(.pro)

!exists($$quote(..\qrxml\)$$QREAL_XML$$quote(\generated\pluginInterface.h)) {
	message($$COMMAND)
	SYS = $$system($$COMMAND)
}

QRXML_ROOT = ..

!include (../editorsSdk.pri) {
	message("editorsSdk.pri not found at ../")
}

QT += xml

TEMPLATE =  lib
CONFIG += plugin
DESTDIR = ../../qrgui/plugins/
INCLUDEPATH += ../

OBJECTS_DIR = .obj
MOC_DIR = .moc
RCC_DIR = .moc

win32 | win32-msvc* {
        CONFIG(debug, debug|release) {
                QMAKE_QRXC = $$PWD/debug/qrxc.exe
        } else:CONFIG(release, debug|release){
                QMAKE_QRXC = $$PWD/release/qrxc.exe
        } else {
                error(Windows build definitely needs to be fixed)
        }
} else {
        QMAKE_QRXC = $$PWD/qrxc
}

INPUT = $$QREAL_XML$$quote(.xml)

qrxc_source.commands = $$QMAKE_QRXC $$INPUT generated/${QMAKE_FILE_IN_BASE}.pro
qrxc_source.input = INPUT
qrxc_source.output = generated/pluginInterface.cpp
qrxc_source.variable_out = SOURCES
qrxc_source.name = QReal_XML_Compiler

QMAKE_EXTRA_COMPILERS += qrxc_source

qrxc_header.commands = $$FAKE
qrxc_header.input = INPUT
qrxc_header.output = generated/pluginInterface.h
qrxc_header.variable_out = HEADERS

QMAKE_EXTRA_COMPILERS += qrxc_header

qrxc_resource.commands = $$FAKE
qrxc_resource.input = INPUT
qrxc_resource.output = $$quote(generated/shapes/)$$QREAL_XML$$quote(.qrc)
qrxc_resource.variable_out = RESOURCES

QMAKE_EXTRA_COMPILERS += qrxc_resource

SDF_FILES = $$files($$quote(..\qrxml\)$$QREAL_XML$$quote(\generated\shapes\*.sdf))
#message($$SDF_FILES)

defineTest(addExtraCompiler) {
    eval($${1}.commands = $$FAKE)
    eval($${1}.input = INPUT)
	eval($${1}.output = $${2})
    eval($${1}.variable_out = GENERATED_FILES)

    export($${1}.output)
    export($${1}.input)
    export($${1}.commands)
    export($${1}.variable_out)

    QMAKE_EXTRA_COMPILERS += $${1}

    export(QMAKE_EXTRA_COMPILERS)

    return(true)
}

for(sdfFile,SDF_FILES) {
	FILE_NAME_LONG = $${sdfFile}
	COMPILER_NAME_LONG = $$section(FILE_NAME_LONG,"/",1,1)
	COMPILER_NAME = $$section(COMPILER_NAME_LONG,".",0,0)
	FILE_NAME = $$quote(generated/shapes/)$$COMPILER_NAME$$quote(.sdf)

	addExtraCompiler($$COMPILER_NAME, $$FILE_NAME)
}

COMMAND = cd $$quote(..\qrxml\)$$QREAL_XML\ && $$QMAKE_QRXC $$QREAL_XML$$quote(.xml) $$quote(generated/)$$QREAL_XML$$quote(.pro)

!exists($$quote(..\qrxml\)$$QREAL_XML$$quote(\generated\pluginInterface.h)) {
	message($$COMMAND)
	SYS = $$system($$COMMAND)
}

QRXML_ROOT = ..

!include (../editorsSdk.pri) {
	message("editorsSdk.pri not found at ../")
}

QT += xml

TEMPLATE =  lib
CONFIG += plugin
DESTDIR = ../../qrgui/plugins/
INCLUDEPATH += ../

OBJECTS_DIR = .obj
MOC_DIR = .moc
RCC_DIR = .moc


Version 1.8

Version 1.8


Try 8419{LIBNAME}.8419{LIB_EXTENSION} for gcc build #13

# Load this from any subproject to link shared libs properly and easy.
#
# Takes a list of paths of shared libs (customLibs). The used list must
# contain 'path/to/lib/name's with path/to/lib relative to the caller.
#
# Example:
# - customLibs = ../path/to/lib/mylib ../other/path/to/otherlib
# - include(loadlibs.pri)
#
# Make sure to provide all libname.pri to set INCLUDEPATH & DEPENDPATH!
#
# Note: include(loadlibs.pri) will setup all given custom libs ->
# -> INCLUDEPATH, DEPENDPATH, LIBS, PRE_TARGETDEPS & QMAKE_LFLAGS.

include($$PWD/win32.pri)

QMAKE_PROJECT_DEPTH = 0 # Forces absolute paths

for(lib, customLibs) {
    !isEmpty(lib) {
        LIBDIR = $$dirname(lib)
        LIBNAME = $$basename(lib)
        #message("$${TARGET} is loading $$LIBNAME -> from: $$LIBDIR")

        # Load lib.pri to set INCLUDEPATH & DEPENDPATH
        exists($$_PRO_FILE_PWD_/$$LIBDIR/$$LIBNAME.pri) {
            include($$_PRO_FILE_PWD_/$$LIBDIR/$${LIBNAME}.pri)
        }
        #message($${INCLUDEPATH})

        #  Set library file extension
        LIB_EXTENSION = $$QMAKE_EXTENSION_SHLIB
        isEmpty(LIB_EXTENSION) {
            macx: LIB_EXTENSION = dylib
            unix:!macx: LIB_EXTENSION = so
        }
        win32 {
            LIB_EXTENSION = $$QMAKE_EXTENSION_STATICLIB
            isEmpty(LIB_EXTENSION) {
                LIB_EXTENSION = lib
            }
        }
        #message($${LIB_EXTENSION})

        # Get library's binary directory
        OUTDIR = $$clean_path($$OUT_PWD/$${LIBDIR})

        macx {
            frameworks += $$files($${OUTDIR}/$${LIBNAME}.framework)
            LIBS += -F$${OUTDIR}/ -framework $${LIBNAME}
            PRE_TARGETDEPS += $${OUTDIR}/$${LIBNAME}.framework
            INCLUDEPATH += -F$${LIBDIR}
        }
        win32 {
            msvc {
                LIBS += $${OUTDIR}/$${WINDIR}/$${LIBNAME}.$${LIB_EXTENSION}
                PRE_TARGETDEPS += $${OUTDIR}/$${WINDIR}/$${LIBNAME}.$${LIB_EXTENSION}
            }
            gcc {
                LIBS += $${OUTDIR}/$${WINDIR}/$${LIBNAME}.$${LIB_EXTENSION}
                PRE_TARGETDEPS += $${OUTDIR}/$${WINDIR}/$${LIBNAME}.$${LIB_EXTENSION}
            }
        }
        unix:!macx {
            LIBS += -L$${OUTDIR}/ -l$${LIBNAME}
            PRE_TARGETDEPS += $${OUTDIR}/lib$${LIBNAME}.$${LIB_EXTENSION}
            QMAKE_LFLAGS += "-Wl,-rpath,\'$$OUTDIR\'"
        }
    }
}

macx { # Deploy all linked frameworks to target bundle
    APP_LIB_FILES.files = $$frameworks
    APP_LIB_FILES.path = Contents/Frameworks/
    QMAKE_BUNDLE_DATA += APP_LIB_FILES
}

# Load this from any subproject to link shared libs properly and easy.
#
# Takes a list of paths of shared libs (customLibs). The used list must
# contain 'path/to/lib/name's with path/to/lib relative to the caller.
#
# Example:
# - customLibs = ../path/to/lib/mylib ../other/path/to/otherlib
# - include(loadlibs.pri)
#
# Make sure to provide all libname.pri to set INCLUDEPATH & DEPENDPATH!
#
# Note: include(loadlibs.pri) will setup all given custom libs ->
# -> INCLUDEPATH, DEPENDPATH, LIBS, PRE_TARGETDEPS & QMAKE_LFLAGS.

include($$PWD/win32.pri)

QMAKE_PROJECT_DEPTH = 0 # Forces absolute paths

for(lib, customLibs) {
    !isEmpty(lib) {
        LIBDIR = $$dirname(lib)
        LIBNAME = $$basename(lib)
        #message("$${TARGET} is loading $$LIBNAME -> from: $$LIBDIR")

        # Load lib.pri to set INCLUDEPATH & DEPENDPATH
        exists($$_PRO_FILE_PWD_/$$LIBDIR/$$LIBNAME.pri) {
            include($$_PRO_FILE_PWD_/$$LIBDIR/$${LIBNAME}.pri)
        }
        #message($${INCLUDEPATH})

        #  Set library file extension
        LIB_EXTENSION = $$QMAKE_EXTENSION_SHLIB
        isEmpty(LIB_EXTENSION) {
            macx: LIB_EXTENSION = dylib
            unix:!macx: LIB_EXTENSION = so
        }
        win32 {
            LIB_EXTENSION = $$QMAKE_EXTENSION_STATICLIB
            gcc : LIB_EXTENSION = lib
            isEmpty(LIB_EXTENSION) {
                LIB_EXTENSION = lib
            }
        }
        #message($${LIB_EXTENSION})

        # Get library's binary directory
        OUTDIR = $$clean_path($$OUT_PWD/$${LIBDIR})

        macx {
            frameworks += $$files($${OUTDIR}/$${LIBNAME}.framework)
            LIBS += -F$${OUTDIR}/ -framework $${LIBNAME}
            PRE_TARGETDEPS += $${OUTDIR}/$${LIBNAME}.framework
            INCLUDEPATH += -F$${LIBDIR}
        }
        win32 {
            msvc {
                LIBS += $${OUTDIR}/$${WINDIR}/$${LIBNAME}.$${LIB_EXTENSION}
                PRE_TARGETDEPS += $${OUTDIR}/$${WINDIR}/$${LIBNAME}.$${LIB_EXTENSION}
            }
            gcc {
                LIBS += $${OUTDIR}/$${WINDIR}/lib$${LIBNAME}.$${LIB_EXTENSION}
                PRE_TARGETDEPS += $${OUTDIR}/$${WINDIR}/lib$${LIBNAME}.$${LIB_EXTENSION}
            }
        }
        unix:!macx {
            LIBS += -L$${OUTDIR}/ -l$${LIBNAME}
            PRE_TARGETDEPS += $${OUTDIR}/lib$${LIBNAME}.$${LIB_EXTENSION}
            QMAKE_LFLAGS += "-Wl,-rpath,\'$$OUTDIR\'"
        }
    }
}

macx { # Deploy all linked frameworks to target bundle
    APP_LIB_FILES.files = $$frameworks
    APP_LIB_FILES.path = Contents/Frameworks/
    QMAKE_BUNDLE_DATA += APP_LIB_FILES
}


permit manual building of examples even if "-examples" option is missing
from configure

Task-number: MOBILITY-708

include(../staticconfig.pri)

win32:contains(CONFIG_WIN32,build_all):Win32DebugAndRelease=yes
mac | contains(Win32DebugAndRelease,yes) {
    #due to different debug/release library names we have to comply with
    #whatever Qt does
    !contains(QT_CONFIG,debug)|!contains(QT_CONFIG,release) {
        CONFIG -= debug_and_release debug release
        contains(QT_CONFIG,debug): CONFIG+=debug
        contains(QT_CONFIG,release): CONFIG+=release
    }
}

CONFIG(debug, debug|release) {
    SUBDIRPART=Debug
} else {
    SUBDIRPART=Release
}

OUTPUT_DIR = $$QT_MOBILITY_BUILD_TREE
DESTDIR = $$OUTPUT_DIR/bin/examples
MOC_DIR = $$OUTPUT_DIR/build/$$SUBDIRPART/$$TARGET/moc
RCC_DIR = $$OUTPUT_DIR/build/$$SUBDIRPART/$$TARGET/rcc
UI_DIR = $$OUTPUT_DIR/build/$$SUBDIRPART/$$TARGET/ui
OBJECTS_DIR = $$OUTPUT_DIR/build/$$SUBDIRPART/$$TARGET
mac:LIBS+= -F$$OUTPUT_DIR/lib
LIBS+= -L$$OUTPUT_DIR/lib
QMAKE_RPATHDIR+=$$OUTPUT_DIR/lib
INCLUDEPATH+= $$QT_MOBILITY_SOURCE_TREE/src/global

maemo6 {
    DEFINES+= Q_WS_MAEMO_6
    DEFINES+= QTM_EXAMPLES_SMALL_SCREEN
    DEFINES+= QTM_EXAMPLES_PREFER_LANDSCAPE
}
maemo5 {
    DEFINES+= Q_WS_MAEMO_5
    DEFINES+= QTM_EXAMPLES_SMALL_SCREEN
    DEFINES+= QTM_EXAMPLES_PREFER_LANDSCAPE
}
symbian {
    DEFINES+= QTM_EXAMPLES_SMALL_SCREEN
}

include(../staticconfig.pri)

!contains(build_examples, yes):error(Please use the -examples configure switch to enable building of examples)

win32:contains(CONFIG_WIN32,build_all):Win32DebugAndRelease=yes
mac | contains(Win32DebugAndRelease,yes) {
    #due to different debug/release library names we have to comply with
    #whatever Qt does
    !contains(QT_CONFIG,debug)|!contains(QT_CONFIG,release) {
        CONFIG -= debug_and_release debug release
        contains(QT_CONFIG,debug): CONFIG+=debug
        contains(QT_CONFIG,release): CONFIG+=release
    }
}

CONFIG(debug, debug|release) {
    SUBDIRPART=Debug
} else {
    SUBDIRPART=Release
}

OUTPUT_DIR = $$QT_MOBILITY_BUILD_TREE
DESTDIR = $$OUTPUT_DIR/bin/examples
MOC_DIR = $$OUTPUT_DIR/build/$$SUBDIRPART/$$TARGET/moc
RCC_DIR = $$OUTPUT_DIR/build/$$SUBDIRPART/$$TARGET/rcc
UI_DIR = $$OUTPUT_DIR/build/$$SUBDIRPART/$$TARGET/ui
OBJECTS_DIR = $$OUTPUT_DIR/build/$$SUBDIRPART/$$TARGET
mac:LIBS+= -F$$OUTPUT_DIR/lib
LIBS+= -L$$OUTPUT_DIR/lib
QMAKE_RPATHDIR+=$$OUTPUT_DIR/lib
INCLUDEPATH+= $$QT_MOBILITY_SOURCE_TREE/src/global

maemo6 {
    DEFINES+= Q_WS_MAEMO_6
    DEFINES+= QTM_EXAMPLES_SMALL_SCREEN
    DEFINES+= QTM_EXAMPLES_PREFER_LANDSCAPE
}
maemo5 {
    DEFINES+= Q_WS_MAEMO_5
    DEFINES+= QTM_EXAMPLES_SMALL_SCREEN
    DEFINES+= QTM_EXAMPLES_PREFER_LANDSCAPE
}
symbian {
    DEFINES+= QTM_EXAMPLES_SMALL_SCREEN
}


Changes: Add keyboard layouts to OTHER_FILES

RevBy: Ning Chi

LAYOUTS_DATA = layouts/*.xml layouts/*.dtd
layouts_data.path = /usr/share/meegotouch/virtual-keyboard/layouts
layouts_data.files = $$LAYOUTS_DATA

INSTALLS += \
    layouts_data \

OTHER_FILES += $$LAYOUTS_DATA


fix rpath

fix rpath

include($$PROJECTROOT/src/common.pri)

CORE_LIB_DIR = $$PROJECTROOT/hub/lib/

QMAKE_LIBDIR += $${CORE_LIB_DIR}

LIBS += -lqmhcore
QMAKE_LFLAGS += -Wl,-rpath,$${PREFIX}/lib/ -Wl,-rpath,$${CORE_LIB_DIR}

mac {
QMAKE_LFLAGS += -mmacosx-version-min=10.5
}

include($$PROJECTROOT/src/common.pri)

CORE_LIB_DIR = $$PROJECTROOT/hub/lib/

QMAKE_LIBDIR += $${CORE_LIB_DIR}

LIBS += -lqmhcore
QMAKE_LFLAGS += -Wl,-rpath,$${INSTALL_PREFIX}/lib/ -Wl,-rpath,$${CORE_LIB_DIR}

mac {
QMAKE_LFLAGS += -mmacosx-version-min=10.5
}


Fixes: LD_LIBRARY_PATH for tests does not contain input-method-quick

RevBy: TrustMe
This would make the test fail unless the input-method-quick
library was already installed, and otherwise unreliable because
the wrong library would be used (system instead of in-tree).

Full, original commit at 0d861f5610f22193b47182efaf29281e50d61e85 in maliit-framework

QMAKE_EXTRA_TARGETS += check
check.target = check
check.commands = \
    TESTING_IN_SANDBOX=1 \
    TESTPLUGIN_PATH=../plugins \
    TESTDATA_PATH=$$IN_PWD \
    LD_LIBRARY_PATH=../../input-method-quick:../../src:../../input-context/:../../passthroughserver/:../../maliit:../plugins:$(LD_LIBRARY_PATH) \
    ./$$TARGET

check.depends += $$TARGET

QMAKE_EXTRA_TARGETS += check-xml
check-xml.target = check-xml
check-xml.commands = ../rt.sh $$TARGET
check-xml.depends += $$TARGET

# coverage flags are off per default, but can be turned on via qmake COV_OPTION=on
for(OPTION,$$list($$lower($$COV_OPTION))){
    isEqual(OPTION, on){
        QMAKE_CXXFLAGS += -ftest-coverage -fprofile-arcs
        LIBS += -lgcov
    }
}
QMAKE_CLEAN += $$OBJECTS_DIR/*.gcno $$OBJECTS_DIR/*.gcda

QMAKE_EXTRA_TARGETS += check
check.target = check
check.commands = \
    TESTING_IN_SANDBOX=1 \
    TESTPLUGIN_PATH=../plugins \
    TESTDATA_PATH=$$IN_PWD \
    LD_LIBRARY_PATH=../../src:../../input-context/:../../passthroughserver/:../../maliit:../plugins:$(LD_LIBRARY_PATH) \
    ./$$TARGET

check.depends += $$TARGET

QMAKE_EXTRA_TARGETS += check-xml
check-xml.target = check-xml
check-xml.commands = ../rt.sh $$TARGET
check-xml.depends += $$TARGET

# coverage flags are off per default, but can be turned on via qmake COV_OPTION=on
for(OPTION,$$list($$lower($$COV_OPTION))){
    isEqual(OPTION, on){
        QMAKE_CXXFLAGS += -ftest-coverage -fprofile-arcs
        LIBS += -lgcov
    }
}
QMAKE_CLEAN += $$OBJECTS_DIR/*.gcno $$OBJECTS_DIR/*.gcda


Bumped version for release.

Bumped version for release.

Signed-off-by: Carl Wong <71f6120c3829ee10a91638f591f6c67d26f52dda@intel.com>


Bump version for release.

Bump version for release.


Doc installing fixes...

Doc installing fixes...

doxygen_doc.target = doc/html/index.html
doxygen_doc.commands = cd doc && VERSION=\"$$DOC_VERSION\" LIBRARYNAME=\"$$LIBRARYNAME\" doxygen doxygen.cfg
doc.depends = doxygen_doc

install_doc.files = doc/html/*.html doc/html/*.css doc/html/*.gif doc/html/*.png
install_doc.path = $$QTSPARQL_INSTALL_DOCS/$$PACKAGENAME-doc/html
install_doc.CONFIG = no_check_exist
INSTALLS += install_doc

clean_doc.commands = rm -rf doc/html doc/man
distclean.depends += clean_doc

QMAKE_EXTRA_TARGETS += doc doxygen_doc clean_doc

doxygen_doc.target = doc/html/index.html
doxygen_doc.commands = cd doc && VERSION=\"$$DOC_VERSION\" LIBRARYNAME=\"$$LIBRARYNAME\" doxygen doxygen.cfg
doc.depends = doxygen_doc

install_doc.files = doc/html/*
install_doc.path = $$QTSPARQL_INSTALL_DOCS/$$PACKAGENAME-doc/html
install_doc.CONFIG = no_check_exist
INSTALLS += install_doc

clean_doc.commands = rm -rf doc/html doc/man
distclean.depends += clean_doc

QMAKE_EXTRA_TARGETS += doc doxygen_doc clean_doc


Removed all but sources and headers from .pri file.

#-------------------------------------------------
#
# Project created by QtCreator 2015-09-16T16:15:51
#
#-------------------------------------------------

QT       -= core gui

TARGET = cpp_utils
TEMPLATE = lib
CONFIG += staticlib

SOURCES +=

HEADERS += \
    $$PWD/concurrent.hpp \
    $$PWD/concurrent_queue.hpp \
    $$PWD/cow_ptr.hpp \
    $$PWD/functors.hpp \
    $$PWD/meta_programming.hpp \
    $$PWD/monitor.hpp \
    $$PWD/scope_guard.hpp \
    $$PWD/task_queue.hpp \
    $$PWD/task_queue_thread.hpp \
    $$PWD/units.hpp \
    $$PWD/updater.hpp \


Bump to to try to get installer to work

Bump to to try to get installer to work

# -------------------------------------------------
# QGroundControl - Micro Air Vehicle Groundstation
# Please see our website at <http://qgroundcontrol.org>
# Maintainer:
# Lorenz Meier <lm@inf.ethz.ch>
# (c) 2009-2014 QGroundControl Developers
# License terms set in COPYING.md
# -------------------------------------------------

installer {
    DEFINES += QGC_INSTALL_RELEASE
    MacBuild {
        VideoEnabled {
            # Install the gstreamer framework
            # This will:
            # Copy from the original distibution into DESTDIR/gstwork (if not already there)
            # Prune the framework, removing stuff we don't need
            # Relocate all dylibs so they can work under @executable_path/...
            # Copy the result into the app bundle
            # Make sure qgroundcontrol can find them
            message("Preparing GStreamer Framework")
            QMAKE_POST_LINK += && $$BASEDIR/tools/prepare_gstreamer_framework.sh $${OUT_PWD}/gstwork/ $${DESTDIR}/$${TARGET}.app $${TARGET}
        } else {
            message("Skipping GStreamer Framework")
        }
        # We cd to release directory so we can run macdeployqt without a path to the
        # qgroundcontrol.app file. If you specify a path to the .app file the symbolic
        # links to plugins will not be created correctly.
        QMAKE_POST_LINK += && mkdir -p $${DESTDIR}/package
        QMAKE_POST_LINK += && cd $${DESTDIR} && $$dirname(QMAKE_QMAKE)/macdeployqt QGroundControl.app -appstore-compliant -verbose=2 -qmldir=$${BASEDIR}/src
        QMAKE_POST_LINK += && cd $${OUT_PWD}
        QMAKE_POST_LINK += && hdiutil create -verbose -stretch 4g -layout SPUD -srcfolder $${DESTDIR}/QGroundControl.app -volname QGroundControl $${DESTDIR}/package/QGroundControl.dmg
    }
    WindowsBuild {
        # The pdb moving command are commented out for now since we are including the .pdb in the installer. This makes it much
        # easier to debug user crashes.
        #QMAKE_POST_LINK += $$escape_expand(\\n) $$QMAKE_COPY $${DESTDIR_WIN}\\qgroundcontrol.pdb
        #QMAKE_POST_LINK += $$escape_expand(\\n) del $${DESTDIR_WIN}\\qgroundcontrol.pdb
        QMAKE_POST_LINK += $$escape_expand(\\n) cd $$BASEDIR_WIN && $$quote("\"C:\\Program Files \(x86\)\\NSIS\\makensis.exe\"" /NOCD "\"/XOutFile $${DESTDIR_WIN}\\QGroundControl-installer.exe\"" "$$BASEDIR_WIN\\deploy\\qgroundcontrol_installer.nsi")
        #QMAKE_POST_LINK += $$escape_expand(\\n) $$QMAKE_COPY qgroundcontrol.pdb $${DESTDIR_WIN}
        #QMAKE_POST_LINK += $$escape_expand(\\n) del qgroundcontrol.pdb
        OTHER_FILES += deploy/qgroundcontrol_installer.nsi
    }
    LinuxBuild {
        #-- TODO: This uses hardcoded paths. It should use $${DESTDIR}
        QMAKE_POST_LINK += && mkdir -p release/package
        QMAKE_POST_LINK += && tar -cjf release/package/QGroundControl.tar.bz2 release --exclude='package' --transform 's/release/qgroundcontrol/'
    }
    AndroidBuild {
        #-- TODO: This uses hardcoded paths. It should use $${DESTDIR}
        QMAKE_POST_LINK += && mkdir -p $${DESTDIR}/package
        QMAKE_POST_LINK += && make install INSTALL_ROOT=$${DESTDIR}/android-build/
        QMAKE_POST_LINK += && androiddeployqt --input android-libQGroundControl.so-deployment-settings.json --output $${DESTDIR}/android-build --deployment bundled --gradle --sign $${BASEDIR}/android/android_release.keystore dagar --storepass $$(ANDROID_STOREPASS)
        QMAKE_POST_LINK += && cp $${DESTDIR}/android-build/build/outputs/apk/android-build-release-signed.apk $${DESTDIR}/package/QGroundControl.apk
    }
}

# -------------------------------------------------
# QGroundControl - Micro Air Vehicle Groundstation
# Please see our website at <http://qgroundcontrol.org>
# Maintainer:
# Lorenz Meier <lm@inf.ethz.ch>
# (c) 2009-2014 QGroundControl Developers
# License terms set in COPYING.md
# -------------------------------------------------

installer {
    DEFINES += QGC_INSTALL_RELEASE
    MacBuild {
        VideoEnabled {
            # Install the gstreamer framework
            # This will:
            # Copy from the original distibution into DESTDIR/gstwork (if not already there)
            # Prune the framework, removing stuff we don't need
            # Relocate all dylibs so they can work under @executable_path/...
            # Copy the result into the app bundle
            # Make sure qgroundcontrol can find them
            message("Preparing GStreamer Framework")
            QMAKE_POST_LINK += && $$BASEDIR/tools/prepare_gstreamer_framework.sh $${OUT_PWD}/gstwork/ $${DESTDIR}/$${TARGET}.app $${TARGET}
        } else {
            message("Skipping GStreamer Framework")
        }
        # We cd to release directory so we can run macdeployqt without a path to the
        # qgroundcontrol.app file. If you specify a path to the .app file the symbolic
        # links to plugins will not be created correctly.
        QMAKE_POST_LINK += && mkdir -p $${DESTDIR}/package
        QMAKE_POST_LINK += && cd $${DESTDIR} && $$dirname(QMAKE_QMAKE)/macdeployqt QGroundControl.app -appstore-compliant -verbose=2 -qmldir=$${BASEDIR}/src
        QMAKE_POST_LINK += && cd $${OUT_PWD}
        QMAKE_POST_LINK += && hdiutil create -verbose -stretch 3g -layout SPUD -srcfolder $${DESTDIR}/QGroundControl.app -volname QGroundControl $${DESTDIR}/package/QGroundControl.dmg
    }
    WindowsBuild {
        # The pdb moving command are commented out for now since we are including the .pdb in the installer. This makes it much
        # easier to debug user crashes.
        #QMAKE_POST_LINK += $$escape_expand(\\n) $$QMAKE_COPY $${DESTDIR_WIN}\\qgroundcontrol.pdb
        #QMAKE_POST_LINK += $$escape_expand(\\n) del $${DESTDIR_WIN}\\qgroundcontrol.pdb
        QMAKE_POST_LINK += $$escape_expand(\\n) cd $$BASEDIR_WIN && $$quote("\"C:\\Program Files \(x86\)\\NSIS\\makensis.exe\"" /NOCD "\"/XOutFile $${DESTDIR_WIN}\\QGroundControl-installer.exe\"" "$$BASEDIR_WIN\\deploy\\qgroundcontrol_installer.nsi")
        #QMAKE_POST_LINK += $$escape_expand(\\n) $$QMAKE_COPY qgroundcontrol.pdb $${DESTDIR_WIN}
        #QMAKE_POST_LINK += $$escape_expand(\\n) del qgroundcontrol.pdb
        OTHER_FILES += deploy/qgroundcontrol_installer.nsi
    }
    LinuxBuild {
        #-- TODO: This uses hardcoded paths. It should use $${DESTDIR}
        QMAKE_POST_LINK += && mkdir -p release/package
        QMAKE_POST_LINK += && tar -cjf release/package/QGroundControl.tar.bz2 release --exclude='package' --transform 's/release/qgroundcontrol/'
    }
    AndroidBuild {
        #-- TODO: This uses hardcoded paths. It should use $${DESTDIR}
        QMAKE_POST_LINK += && mkdir -p $${DESTDIR}/package
        QMAKE_POST_LINK += && make install INSTALL_ROOT=$${DESTDIR}/android-build/
        QMAKE_POST_LINK += && androiddeployqt --input android-libQGroundControl.so-deployment-settings.json --output $${DESTDIR}/android-build --deployment bundled --gradle --sign $${BASEDIR}/android/android_release.keystore dagar --storepass $$(ANDROID_STOREPASS)
        QMAKE_POST_LINK += && cp $${DESTDIR}/android-build/build/outputs/apk/android-build-release-signed.apk $${DESTDIR}/package/QGroundControl.apk
    }
}


Set openssl version to 1.1.1 for Mac

Set openssl version to 1.1.1 for Mac

# 1. Before using autotools & make, make sure to set the macOS target platform in the shell:
# export MACOSX_DEPLOYMENT_TARGET=10.10

# 2. Install all libraries with homebrew:
# brew install autoconf automake libtool pkg-config openssl@1.1 libevent boost gcc wget

# (2a optional) Fix for xCode to stop complaining about not finding the string.h file
# https://stackoverflow.com/questions/48839127/qmake-derived-clang-in-osx-10-13-cannot-find-string-h
# INCLUDEPATH += /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include

ICON = $$PWD/../spectre.icns

    # to build tor with autotools, call in subfolder tor:
    # ./autogen.sh && ./configure --with-ssl-dir=/usr/local/Cellar/openssl@1.1/1.1.1 --disable-asciidoc --disable-lzma
#    LIBS += -L$$PWD/../tor/src/or -ltor \
#    -L$$PWD/../tor/src/common -lor \
#    -L$$PWD/../tor/src/common -lor-ctime \
#    -L$$PWD/../tor/src/common -lor-crypto \
#    -L$$PWD/../tor/src/common -lor-event \
#    -L$$PWD/../tor/src/trunnel -lor-trunnel \
#    -L$$PWD/../tor/src/common -lcurve25519_donna \
#    -L$$PWD/../tor/src/ext/ed25519/donna -led25519_donna \
#    -L$$PWD/../tor/src/ext/ed25519/ref10 -led25519_ref10 \
#    -L$$PWD/../tor/src/ext/keccak-tiny -lkeccak-tiny \

#    INCLUDEPATH += $$PWD/../tor/src/or $$PWD/../tor/src/common $$PWD/../tor/src/trunnel $$PWD/../tor/src/ext/ed25519/donna $$PWD/../tor/src/ext/ed25519/ref10 $$PWD/../tor/src/ext/keccak-tiny
#    DEPENDPATH += $$PWD/../tor/src/or $$PWD/../tor/src/common $$PWD/../tor/src/trunnel $$PWD/../tor/src/ext/ed25519/donna $$PWD/../tor/src/ext/ed25519/ref10 $$PWD/../tor/src/ext/keccak-tiny

#    PRE_TARGETDEPS += $$PWD/../tor/src/or/libtor.a \
#    $$PWD/../tor/src/common/libor.a \
#    $$PWD/../tor/src/common/libor-ctime.a \
#    $$PWD/../tor/src/common/libor-crypto.a \
#    $$PWD/../tor/src/common/libor-event.a \
#    $$PWD/../tor/src/trunnel/libor-trunnel.a \
#    $$PWD/../tor/src/common/libcurve25519_donna.a \
#    $$PWD/../tor/src/ext/ed25519/donna/libed25519_donna.a \
#    $$PWD/../tor/src/ext/ed25519/ref10/libed25519_ref10.a \
#    $$PWD/../tor/src/ext/keccak-tiny/libkeccak-tiny.a \

    # brew install zlib
    _ZLIB_PATH = /usr/local/opt/zlib
    INCLUDEPATH += "$${_ZLIB_PATH}/include/"
    LIBS += -L$${_ZLIB_PATH}/lib
    #Shblis-MacBook-Pro:src Shbli$ find /usr/local/Cellar/libevent/2.1.8/lib/ -name *a
    LIBS += -lz

    # to build BerkeleyDB with autotools, call in subfolder db4.8:
    # ./configure --enable-cxx --disable-shared --disable-replication --with-pic && make
    _BERKELEY_PATH = $$PWD/../db4.8/build_unix
    LIBS += $${_BERKELEY_PATH}/libdb_cxx.a \ # link static
    $${_BERKELEY_PATH}/libdb.a

    DEPENDPATH += $${_BERKELEY_PATH}
    INCLUDEPATH += $${_BERKELEY_PATH}

    # to build leveldb call in subfolder leveldb:
    # ./build_detect_platform build_config.mk ./ && make
    LIBS += -L$$PWD/../leveldb/out-static -lleveldb \
    -L$$PWD/../leveldb/out-static -lmemenv

    INCLUDEPATH += $$PWD/../leveldb/out-static
    DEPENDPATH += $$PWD/../leveldb/out-static
    INCLUDEPATH += $$PWD/../leveldb/include
    DEPENDPATH += $$PWD/../leveldb/include
    INCLUDEPATH += $$PWD/../leveldb/helpers
    DEPENDPATH += $$PWD/../leveldb/helpers

    PRE_TARGETDEPS += $$PWD/../leveldb/out-static/libleveldb.a \
    $$PWD/../leveldb/out-static/libmemenv.a

HEADERS +=              $$PWD/qt/macdockiconhandler.h \
                        $$PWD/qt/macnotificationhandler.h \

OBJECTIVE_SOURCES +=    $$PWD/qt/macdockiconhandler.mm \
                        $$PWD/qt/macnotificationhandler.mm \

DEFINES += FORTIFY_SOURCE=1

QMAKE_LFLAGS += -fstack-protector
QMAKE_CXXFLAGS += -pthread -fPIC -fstack-protector -O2 -D_FORTIFY_SOURCE=1 -Wall -Wextra -Wno-ignored-qualifiers -Woverloaded-virtual -Wformat -Wformat-security -Wno-unused-parameter

DEFINES += MAC_OSX
# Mac: compile for maximum compatibility (10.0 Yosemite, 32-bit)
QMAKE_CXXFLAGS += -std=c++14 -mmacosx-version-min=10.10 -isysroot

    # https://www.reddit.com/r/cpp/comments/334s4r/how_to_enable_c14_in_qt_creator_on_a_mac/
    # Turns out, there's a glitch in the Mac version where the standard library isn't correctly included when using the C++14 config flag. Adding this additional line to the .pro file fixes the problem:
    QMAKE_CXXFLAGS += -stdlib=libc++

    #add in core foundation framework
    QMAKE_LFLAGS += -F /System/Library/Frameworks/CoreFoundation.framework/
    LIBS += -framework CoreFoundation

    QMAKE_LFLAGS += -F /System/Library/Frameworks/AppKit.framework/
    LIBS += -framework AppKit

    QMAKE_LFLAGS += -F /System/Library/Frameworks/ApplicationServices.framework/
    LIBS += -framework ApplicationServices

    #brew install boost
    _BOOST_PATH = /usr/local/Cellar/boost/1.67.0_1
    INCLUDEPATH += "$${_BOOST_PATH}/include/"
    LIBS += -L$${_BOOST_PATH}/lib
    LIBS += -lboost_system-mt -lboost_chrono-mt -lboost_filesystem-mt -lboost_program_options-mt -lboost_thread-mt -lboost_unit_test_framework-mt -lboost_timer-mt # using dynamic lib (not sure if you need that "-mt" at the end or not)
    DEFINES += BOOST_ASIO_ENABLE_OLD_SERVICES BOOST_SPIRIT_THREADSAFE BOOST_THREAD_USE_LIB BOOST_THREAD_POSIX BOOST_HAS_THREADS
    #LIBS += $${_BOOST_PATH}/lib/libboost_chrono-mt.a # using static lib

    #brew install openssl@1.1
    _OPENSSL_PATH = /usr/local/Cellar/openssl@1.1/1.1.1
    INCLUDEPATH += "$${_OPENSSL_PATH}/include/"
    LIBS += -L$${_OPENSSL_PATH}/lib
    LIBS += -lssl -lcrypto # using dynamic lib (not sure if you need that "-mt" at the end or not)

    #libevent-2.1.6.dylib
    #brew install libevent
    _LIBEVENT_PATH = /usr/local/Cellar/libevent/2.1.8
    INCLUDEPATH += "$${_LIBEVENT_PATH}/include/"
    LIBS += -L$${_LIBEVENT_PATH}/lib
    #Shblis-MacBook-Pro:src Shbli$ find /usr/local/Cellar/libevent/2.1.8/lib/ -name *a
    LIBS += -levent_extra -levent -levent_core -levent_openssl -levent_pthreads

# 1. Before using autotools & make, make sure to set the macOS target platform in the shell:
# export MACOSX_DEPLOYMENT_TARGET=10.10

# 2. Install all libraries with homebrew:
# brew install autoconf automake libtool pkg-config openssl@1.1 libevent boost gcc wget

# (2a optional) Fix for xCode to stop complaining about not finding the string.h file
# https://stackoverflow.com/questions/48839127/qmake-derived-clang-in-osx-10-13-cannot-find-string-h
# INCLUDEPATH += /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include

ICON = $$PWD/../spectre.icns

    # to build tor with autotools, call in subfolder tor:
    # ./autogen.sh && ./configure --with-ssl-dir=/usr/local/Cellar/openssl@1.1/1.1.0i --disable-asciidoc --disable-lzma
#    LIBS += -L$$PWD/../tor/src/or -ltor \
#    -L$$PWD/../tor/src/common -lor \
#    -L$$PWD/../tor/src/common -lor-ctime \
#    -L$$PWD/../tor/src/common -lor-crypto \
#    -L$$PWD/../tor/src/common -lor-event \
#    -L$$PWD/../tor/src/trunnel -lor-trunnel \
#    -L$$PWD/../tor/src/common -lcurve25519_donna \
#    -L$$PWD/../tor/src/ext/ed25519/donna -led25519_donna \
#    -L$$PWD/../tor/src/ext/ed25519/ref10 -led25519_ref10 \
#    -L$$PWD/../tor/src/ext/keccak-tiny -lkeccak-tiny \

#    INCLUDEPATH += $$PWD/../tor/src/or $$PWD/../tor/src/common $$PWD/../tor/src/trunnel $$PWD/../tor/src/ext/ed25519/donna $$PWD/../tor/src/ext/ed25519/ref10 $$PWD/../tor/src/ext/keccak-tiny
#    DEPENDPATH += $$PWD/../tor/src/or $$PWD/../tor/src/common $$PWD/../tor/src/trunnel $$PWD/../tor/src/ext/ed25519/donna $$PWD/../tor/src/ext/ed25519/ref10 $$PWD/../tor/src/ext/keccak-tiny

#    PRE_TARGETDEPS += $$PWD/../tor/src/or/libtor.a \
#    $$PWD/../tor/src/common/libor.a \
#    $$PWD/../tor/src/common/libor-ctime.a \
#    $$PWD/../tor/src/common/libor-crypto.a \
#    $$PWD/../tor/src/common/libor-event.a \
#    $$PWD/../tor/src/trunnel/libor-trunnel.a \
#    $$PWD/../tor/src/common/libcurve25519_donna.a \
#    $$PWD/../tor/src/ext/ed25519/donna/libed25519_donna.a \
#    $$PWD/../tor/src/ext/ed25519/ref10/libed25519_ref10.a \
#    $$PWD/../tor/src/ext/keccak-tiny/libkeccak-tiny.a \

    # brew install zlib
    _ZLIB_PATH = /usr/local/opt/zlib
    INCLUDEPATH += "$${_ZLIB_PATH}/include/"
    LIBS += -L$${_ZLIB_PATH}/lib
    #Shblis-MacBook-Pro:src Shbli$ find /usr/local/Cellar/libevent/2.1.8/lib/ -name *a
    LIBS += -lz

    # to build BerkeleyDB with autotools, call in subfolder db4.8:
    # ./configure --enable-cxx --disable-shared --disable-replication --with-pic && make
    _BERKELEY_PATH = $$PWD/../db4.8/build_unix
    LIBS += $${_BERKELEY_PATH}/libdb_cxx.a \ # link static
    $${_BERKELEY_PATH}/libdb.a

    DEPENDPATH += $${_BERKELEY_PATH}
    INCLUDEPATH += $${_BERKELEY_PATH}

    # to build leveldb call in subfolder leveldb:
    # ./build_detect_platform build_config.mk ./ && make
    LIBS += -L$$PWD/../leveldb/out-static -lleveldb \
    -L$$PWD/../leveldb/out-static -lmemenv

    INCLUDEPATH += $$PWD/../leveldb/out-static
    DEPENDPATH += $$PWD/../leveldb/out-static
    INCLUDEPATH += $$PWD/../leveldb/include
    DEPENDPATH += $$PWD/../leveldb/include
    INCLUDEPATH += $$PWD/../leveldb/helpers
    DEPENDPATH += $$PWD/../leveldb/helpers

    PRE_TARGETDEPS += $$PWD/../leveldb/out-static/libleveldb.a \
    $$PWD/../leveldb/out-static/libmemenv.a

HEADERS +=              $$PWD/qt/macdockiconhandler.h \
                        $$PWD/qt/macnotificationhandler.h \

OBJECTIVE_SOURCES +=    $$PWD/qt/macdockiconhandler.mm \
                        $$PWD/qt/macnotificationhandler.mm \

DEFINES += FORTIFY_SOURCE=1

QMAKE_LFLAGS += -fstack-protector
QMAKE_CXXFLAGS += -pthread -fPIC -fstack-protector -O2 -D_FORTIFY_SOURCE=1 -Wall -Wextra -Wno-ignored-qualifiers -Woverloaded-virtual -Wformat -Wformat-security -Wno-unused-parameter

DEFINES += MAC_OSX
# Mac: compile for maximum compatibility (10.0 Yosemite, 32-bit)
QMAKE_CXXFLAGS += -std=c++14 -mmacosx-version-min=10.10 -isysroot

    # https://www.reddit.com/r/cpp/comments/334s4r/how_to_enable_c14_in_qt_creator_on_a_mac/
    # Turns out, there's a glitch in the Mac version where the standard library isn't correctly included when using the C++14 config flag. Adding this additional line to the .pro file fixes the problem:
    QMAKE_CXXFLAGS += -stdlib=libc++

    #add in core foundation framework
    QMAKE_LFLAGS += -F /System/Library/Frameworks/CoreFoundation.framework/
    LIBS += -framework CoreFoundation

    QMAKE_LFLAGS += -F /System/Library/Frameworks/AppKit.framework/
    LIBS += -framework AppKit

    QMAKE_LFLAGS += -F /System/Library/Frameworks/ApplicationServices.framework/
    LIBS += -framework ApplicationServices

    #brew install boost
    _BOOST_PATH = /usr/local/Cellar/boost/1.67.0_1
    INCLUDEPATH += "$${_BOOST_PATH}/include/"
    LIBS += -L$${_BOOST_PATH}/lib
    LIBS += -lboost_system-mt -lboost_chrono-mt -lboost_filesystem-mt -lboost_program_options-mt -lboost_thread-mt -lboost_unit_test_framework-mt -lboost_timer-mt # using dynamic lib (not sure if you need that "-mt" at the end or not)
    DEFINES += BOOST_ASIO_ENABLE_OLD_SERVICES BOOST_SPIRIT_THREADSAFE BOOST_THREAD_USE_LIB BOOST_THREAD_POSIX BOOST_HAS_THREADS
    #LIBS += $${_BOOST_PATH}/lib/libboost_chrono-mt.a # using static lib

    #brew install openssl@1.1
    _OPENSSL_PATH = /usr/local/Cellar/openssl@1.1/1.1.0i
    INCLUDEPATH += "$${_OPENSSL_PATH}/include/"
    LIBS += -L$${_OPENSSL_PATH}/lib
    LIBS += -lssl -lcrypto # using dynamic lib (not sure if you need that "-mt" at the end or not)

    #libevent-2.1.6.dylib
    #brew install libevent
    _LIBEVENT_PATH = /usr/local/Cellar/libevent/2.1.8
    INCLUDEPATH += "$${_LIBEVENT_PATH}/include/"
    LIBS += -L$${_LIBEVENT_PATH}/lib
    #Shblis-MacBook-Pro:src Shbli$ find /usr/local/Cellar/libevent/2.1.8/lib/ -name *a
    LIBS += -levent_extra -levent -levent_core -levent_openssl -levent_pthreads