qgroundcontrol.pri: comment-out building OSG entirely (was only used for pixhawk 3D indoor map); Silence unhelpful compiler warnings on on MSVC; Clean up distribution commands.

# -------------------------------------------------
# QGroundControl - Micro Air Vehicle Groundstation
# Please see our website at <http://qgroundcontrol.org>
# Maintainer:
# Lorenz Meier <lm@inf.ethz.ch>
# (c) 2009-2011 QGroundControl Developers
# This file is part of the open groundstation project
# QGroundControl is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# QGroundControl is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with QGroundControl. If not, see <http://www.gnu.org/licenses/>.
# -------------------------------------------------

message(Qt version $$[QT_VERSION])

# Turn off serial port warnings
DEFINES += _TTY_NOWARN_

# MAC OS X
macx|macx-g++42|macx-g++|macx-llvm: {

	CONFIG += cocoa
#	CONFIG += x86_64 cocoa phonon
#	CONFIG -= x86

	# For release builds remove support for various Qt debugging macros.
	CONFIG(release, debug|release) {
		DEFINES += QT_NO_DEBUG
	}

	MACBITS = "mac32"
	DEFINES += USE_GOOGLE_EARTH_PLUGIN
	*64 {
		message("Building Mac64 version")
		MACBITS = "mac64"
		DEFINES -= USE_GOOGLE_EARTH_PLUGIN
	}

	QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6

	INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers

	LIBS += -framework IOKit \
#		-F$$BASEDIR/libs/lib/Frameworks \
		-framework SDL \
		-framework CoreFoundation \
		-framework ApplicationServices \
		-lm

	ICON = $$BASEDIR/files/images/icons/macx.icns

	QMAKE_POST_LINK += $$quote(echo "Copying files")

	# Copy AQ files
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/bin
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/aq/bin/aq_osx_all/* $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/bin
	QMAKE_POST_LINK += && chmod +x $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/bin/*
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/mixes
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/aq/mixes/* $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/mixes

	# Copy google earth starter file
	QMAKE_POST_LINK += && cp -f $$BASEDIR/files/*.* $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/files
	# Copy audio files
	QMAKE_POST_LINK += && cp -r $$BASEDIR/files/audio $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/files
	 # Copy language files
	QMAKE_POST_LINK += && cp -f $$BASEDIR/files/lang/*.qm $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/files/lang
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/files/lang/flags $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/files/lang
	# Copy libraries
#	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/libs
#	QMAKE_POST_LINK += && cp -rf $$BASEDIR/libs/lib/$${MACBITS}/lib/* $$TARGETDIR/qgroundcontrol.app/Contents/libs
	# Copy frameworks
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/Frameworks
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/libs/lib/Frameworks/* $$TARGETDIR/qgroundcontrol.app/Contents/Frameworks

	# Fix library paths inside executable
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
#	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
#	QMAKE_POST_LINK += && install_name_tool -change libosgViewer.dylib "@executable_path/../libs/libosgViewer.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
#	QMAKE_POST_LINK += && install_name_tool -change libosgGA.dylib "@executable_path/../libs/libosgGA.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
#	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
#	QMAKE_POST_LINK += && install_name_tool -change libosgText.dylib "@executable_path/../libs/libosgText.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
#	QMAKE_POST_LINK += && install_name_tool -change libosgWidget.dylib "@executable_path/../libs/libosgWidget.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol

	# Fix library paths within libraries (inter-library dependencies)

	# OSG GA LIBRARY
#	QMAKE_POST_LINK += && install_name_tool -change libosgGA.dylib "@executable_path/../libs/libosgGA.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib

	# OSG DB LIBRARY
#	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgDB.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgDB.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgDB.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgDB.dylib

	# OSG TEXT LIBRARY
#	QMAKE_POST_LINK += && install_name_tool -change libosgText.dylib "@executable_path/../libs/libosgText.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib

	# OSG UTIL LIBRARY
#	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgUtil.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgUtil.dylib

	# OSG VIEWER LIBRARY
#	QMAKE_POST_LINK += && install_name_tool -change libosgGA.dylib "@executable_path/../libs/libosgGA.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgText.dylib "@executable_path/../libs/libosgText.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib

	# OSG WIDGET LIBRARY
#	QMAKE_POST_LINK += && install_name_tool -change libosgGA.dylib "@executable_path/../libs/libosgGA.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgText.dylib "@executable_path/../libs/libosgText.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
#	QMAKE_POST_LINK += && install_name_tool -change libosgViewer.dylib "@executable_path/../libs/libosgViewer.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib

	# CORE OSG LIBRARY
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosg.dylib

	# SDL Framework
	QMAKE_POST_LINK += && install_name_tool -change "@rpath/SDL.framework/Versions/A/SDL" "@executable_path/../Frameworks/SDL.framework/Versions/A/SDL" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol

	# No check for GLUT.framework since it's a MAC default
#	message("Building support for OpenSceneGraph")
#	DEPENDENCIES_PRESENT += osg
#	DEFINES += QGC_OSG_ENABLED
#	# Include OpenSceneGraph libraries
#	INCLUDEPATH += -framework GLUT \
#        -framework Cocoa \
#		  $$BASEDIR/libs/lib/$${MACBITS}/include

#	LIBS += -framework GLUT \
#		  -framework Cocoa \
#		  -L$$BASEDIR/libs/lib/$${MACBITS}/lib \
#        -lOpenThreads \
#        -losg \
#        -losgViewer \
#        -losgGA \
#        -losgDB \
#        -losgText \
#        -losgWidget

	exists(/opt/local/include/libfreenect)|exists(/usr/local/include/libfreenect) {
		message("Building support for libfreenect")
		DEPENDENCIES_PRESENT += libfreenect
		# Include libfreenect libraries
		LIBS += -lfreenect
		DEFINES += QGC_LIBFREENECT_ENABLED
	}
}

# GNU/Linux
linux-g++|linux-g++-64{

	CONFIG -= console
	DEFINES += __STDC_LIMIT_MACROS
	DESTDIR = $$TARGETDIR

	release {
		DEFINES += QT_NO_DEBUG
	}

	INCLUDEPATH += /usr/include \
		  /usr/local/include \

	LIBS += \
		-L/usr/lib \
		-L/usr/local/lib64 \
		-lm \
#		-lflite_cmu_us_kal \
#		-lflite_usenglish \
#		-lflite_cmulex \
#		-lflite \
		-lSDL \
		-lSDLmain

#	exists(/usr/include/osg) | exists(/usr/local/include/osg) {
#		message("Building support for OpenSceneGraph")
#		DEPENDENCIES_PRESENT += osg
#		# Include OpenSceneGraph libraries
#		LIBS += -losg \
#            -losgViewer \
#            -losgGA \
#            -losgDB \
#            -losgText \
#            -lOpenThreads

#		DEFINES += QGC_OSG_ENABLED
#	}

	exists(/usr/include/osg/osgQt) | exists(/usr/include/osgQt) |
	exists(/usr/local/include/osg/osgQt) | exists(/usr/local/include/osgQt) {
		message("Building support for OpenSceneGraph Qt")
		# Include OpenSceneGraph Qt libraries
		LIBS += -losgQt
		DEFINES += QGC_OSG_QT_ENABLED
	}

	exists(/usr/local/include/google/protobuf) {
		message("Building support for Protocol Buffers")
		DEPENDENCIES_PRESENT += protobuf
		# Include Protocol Buffers libraries
		LIBS += -lprotobuf \
            -lprotobuf-lite \
            -lprotoc

		DEFINES += QGC_PROTOBUF_ENABLED
	}

	exists(/usr/local/include/libfreenect/libfreenect.h) {
		message("Building support for libfreenect")
		DEPENDENCIES_PRESENT += libfreenect
		INCLUDEPATH += /usr/include/libusb-1.0
		# Include libfreenect libraries
		LIBS += -lfreenect
		DEFINES += QGC_LIBFREENECT_ENABLED
	}

	QMAKE_POST_LINK += $$quote(echo "Copying files")

	# Validated copy commands
	!exists($$TARGETDIR){
		QMAKE_POST_LINK += && mkdir -p $$TARGETDIR
	}

	# Copy AQ files
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/aq/bin
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/aq/bin/aq_unix_all/* $$TARGETDIR/aq/bin
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/aq/mixes
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/aq/mixes/* $$TARGETDIR/aq/mixes
	QMAKE_POST_LINK += && chmod +x $$TARGETDIR/aq/bin/*
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/files/*.* $$TARGETDIR/files
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/files/audio $$TARGETDIR/files/audio
	QMAKE_POST_LINK += && cp -f $$BASEDIR/files/lang/*.qm $$TARGETDIR/files/lang
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/files/lang/flags $$TARGETDIR/files/lang/flags
	#QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR

	# osg/osgEarth dynamic casts might fail without this compiler option.
	# see http://osgearth.org/wiki/FAQ for details.
	QMAKE_CXXFLAGS += -Wl,-E
}

linux-g++ {
	message("Building for GNU/Linux 32bit/i386")
        QMAKE_POST_LINK += && mv -f $$TARGETDIR/aq/bin/cal_32 $$TARGETDIR/aq/bin/cal
        QMAKE_POST_LINK += && mv -f $$TARGETDIR/aq/bin/sim3_32 $$TARGETDIR/aq/bin/sim3
}
linux-g++-64 {
	message("Building for GNU/Linux 64bit/x64 (g++-64)")
	exists(/usr/local/lib64) {
		LIBS += -L/usr/local/lib64
	}
        QMAKE_POST_LINK += && mv -f $$TARGETDIR/aq/bin/cal_64 $$TARGETDIR/aq/bin/cal
        QMAKE_POST_LINK += && mv -f $$TARGETDIR/aq/bin/sim3_64 $$TARGETDIR/aq/bin/sim3
}

# Windows (32bit), Visual Studio
win32-msvc2010|win32-msvc2012|win32-g++ {

	win32-msvc2010 {
		message(Building for Windows Visual Studio 2010 (32bit))
	}
	win32-msvc2012 {
		message(Building for Windows Visual Studio 2012 (32bit))
	}
	win32-g++ {
		message(Building for Windows GCC (32bit))
	}

	# Specify multi-process compilation within Visual Studio.
	# (drastically improves compilation times for multi-core computers)
	QMAKE_CFLAGS_DEBUG += /MP
	QMAKE_CXXFLAGS_DEBUG += /MP
	QMAKE_CFLAGS_RELEASE += /MP
	QMAKE_CXXFLAGS_RELEASE += /MP

	QMAKE_CXXFLAGS_WARN_ON += /W3 \
		  /wd4996 \   # silence warnings about deprecated strcpy and whatnot
		  /wd4005 \   # silence warnings about macro redefinition
		  /wd4290     # ignore exception specifications

	# QAxContainer support is needed for the Internet Control
	# element showing the Google Earth window
	greaterThan(QT_MAJOR_VERSION, 4) {
		QT += axcontainer
	} else {
		CONFIG += qaxcontainer
	}

	DEFINES += USE_GOOGLE_EARTH_PLUGIN

	# The EIGEN library needs this define
	# to make the internal min/max functions work
	DEFINES += NOMINMAX

	# QWebkit is not needed on MS-Windows compilation environment
	CONFIG -= webkit webkitwidgets

	# Specify the inclusion of (U)INT*_(MAX/MIN) macros within Visual Studio
	DEFINES += __STDC_LIMIT_MACROS

	# For release builds remove support for various Qt debugging macros.
	CONFIG(release, debug|release) {
		DEFINES += QT_NO_DEBUG
	}

	# For debug releases we just want the debugging console.
	CONFIG(debug, debug|release) {
		CONFIG += console
	}

	INCLUDEPATH += $$BASEDIR/libs/lib/sdl/msvc/include \
        $$BASEDIR/libs/lib/opal/include \
#		  $$BASEDIR/libs/lib/msinttypes

	LIBS += -L$$BASEDIR/libs/lib/sdl/msvc/lib \
        -lSDLmain -lSDL \
        -lsetupapi

#	exists($$BASEDIR/libs/lib/osg123) {
#		message("Building support for OSG")
#		DEPENDENCIES_PRESENT += osg

#		# Include OpenSceneGraph
#		INCLUDEPATH += $$BASEDIR/libs/lib/osgEarth/win32/include \
#			$$BASEDIR/libs/lib/osgEarth_3rdparty/win32/OpenSceneGraph-2.8.2/include
#		LIBS += -L$$BASEDIR/libs/lib/osgEarth_3rdparty/win32/OpenSceneGraph-2.8.2/lib \
#			-losg \
#			-losgViewer \
#			-losgGA \
#			-losgDB \
#			-losgText \
#			-lOpenThreads
#		DEFINES += QGC_OSG_ENABLED
#	}

	RC_FILE = $$BASEDIR/qgroundcontrol.rc

	# Copy dependencies
	BASEDIR_WIN = $$replace(BASEDIR,"/","\\")
	CONFIG(debug, debug|release) {
		TARGETDIR_WIN = $$replace(TARGETDIR,"/","\\")\\debug
	} else {
		TARGETDIR_WIN = $$replace(TARGETDIR,"/","\\")\\release
	}
	greaterThan(QT_MAJOR_VERSION, 4) {
		QTLIBDLLPFX = "Qt5"
		QTLIBDBGDLLSFX = "d.dll"
	} else {
		QTLIBDLLPFX = "Qt"
		QTLIBDBGDLLSFX = "d4.dll"
	}

	QMAKE_POST_LINK += $$quote(echo "Copying files"$$escape_expand(\\n))

	# Copy AQ files
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /E /I "$$BASEDIR_WIN\\aq\\bin\\aq_win_all\\*" "$$TARGETDIR_WIN\\aq\\bin" $$escape_expand(\\n))
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /E /I "$$BASEDIR_WIN\\aq\\mixes\\*" "$$TARGETDIR_WIN\\aq\\mixes" $$escape_expand(\\n))

	# Copy VLC files  --  just install VNC instaed!
#	contains(DEFINES, QGC_USE_VLC) {
#		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\vlc\\plugins\\*"  "$$TARGETDIR_WIN\\plugins" /E /I $$escape_expand(\\n))
#		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\vlc\\libvlccore.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
#		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\vlc\\libvlc.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
#	}

	# Copy application resources
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /I "$$BASEDIR_WIN\\files\\*.*" "$$TARGETDIR_WIN\\files\\" $$escape_expand(\\n))
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /E /I "$$BASEDIR_WIN\\files\\audio" "$$TARGETDIR_WIN\\files\\audio" $$escape_expand(\\n))
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /I "$$BASEDIR_WIN\\files\\lang\\*.qm" "$$TARGETDIR_WIN\\files\\lang" $$escape_expand(\\n))
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /E /I "$$BASEDIR_WIN\\files\\lang" "$$TARGETDIR_WIN\\files\\lang" $$escape_expand(\\n))

	CONFIG(release, debug|release) {
		# Copy supporting library DLLs
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\lib\\sdl\\win32\\SDL.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		#QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\thirdParty\\libxbee\\lib\\libxbee.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))

		# Copy Qt DLLs
		QMAKE_POST_LINK += $$quote(xcopy /D /Y /E /I "$$(QTDIR)\\plugins\\imageformats" "$$TARGETDIR_WIN\\imageformats" $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y /E /I "$$(QTDIR)\\plugins\\iconengines" "$$TARGETDIR_WIN\\iconengines" $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y /E /I "$$(QTDIR)\\plugins\\sqldrivers" "$$TARGETDIR_WIN\\sqldrivers" $$escape_expand(\\n))
		CONFIG(release, debug|release) {
		}
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Core.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Concurrent.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Gui.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Multimedia.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Network.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}OpenGL.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Sql.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Svg.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Test.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}WebKit.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Xml.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}XmlPatterns.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))

		# clean up stuff not needed by release versions
		QMAKE_POST_LINK += $$quote(del /Q "$$TARGETDIR_WIN\\imageformats\\*$${QTLIBDBGDLLSFX}" $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(del /Q "$$TARGETDIR_WIN\\iconengines\\*$${QTLIBDBGDLLSFX}" $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(del /Q "$$TARGETDIR_WIN\\sqldrivers\\*$${QTLIBDBGDLLSFX}" $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(del /F "$$TARGETDIR_WIN\\qgroundcontrol.exp"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(del /F "$$TARGETDIR_WIN\\qgroundcontrol.lib"$$escape_expand(\\n))

		# Copy Visual Studio DLLs
		win32-msvc2010 {
			QMAKE_POST_LINK += $$quote(xcopy /D /Y "\"C:\\Program Files \(x86\)\\Microsoft Visual Studio 10.0\\VC\\redist\\x86\\Microsoft.VC100.CRT\\*.dll\""  "$$TARGETDIR_WIN\\"$$escape_expand(\\n))
		}
		win32-msvc2012 {
			 QMAKE_POST_LINK += $$quote(xcopy /D /Y "\"C:\\Program Files \(x86\)\\Microsoft Visual Studio 11.0\\VC\\redist\\x86\\Microsoft.VC110.CRT\\*.dll\""  "$${TARGETDIR}\\"$$escape_expand(\\n))
		}
		win32-g++ {
			# we need to know where MinGW lives so we can copy some DLLs from there.
			MINGW_PATH = $$(MINGW_PATH)
			isEmpty(MINGW_PATH): error("MINGW_PATH not found")
			QMAKE_POST_LINK  += $$quote(xcopy /D /Y "$${MINGW_PATH}\\bin\\libwinpthread-1.dll"  "$${TARGETDIR}"$$escape_expand(\\n\\t))
			QMAKE_POST_LINK  += $$quote(xcopy /D /Y "$${MINGW_PATH}\\bin\\libstdc++-6.dll"  "$${TARGETDIR}"$$escape_expand(\\n))
		}
	}
}

# -------------------------------------------------
# QGroundControl - Micro Air Vehicle Groundstation
# Please see our website at <http://qgroundcontrol.org>
# Maintainer:
# Lorenz Meier <lm@inf.ethz.ch>
# (c) 2009-2011 QGroundControl Developers
# This file is part of the open groundstation project
# QGroundControl is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# QGroundControl is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with QGroundControl. If not, see <http://www.gnu.org/licenses/>.
# -------------------------------------------------

message(Qt version $$[QT_VERSION])

# Turn off serial port warnings
DEFINES += _TTY_NOWARN_

# MAC OS X
macx|macx-g++42|macx-g++|macx-llvm: {

	CONFIG += cocoa
#	CONFIG += x86_64 cocoa phonon
#	CONFIG -= x86

	# For release builds remove support for various Qt debugging macros.
	CONFIG(release, debug|release) {
		DEFINES += QT_NO_DEBUG
	}

	MACBITS = "mac32"
	DEFINES += USE_GOOGLE_EARTH_PLUGIN
	*64 {
		message("Building Mac64 version")
		MACBITS = "mac64"
		DEFINES -= USE_GOOGLE_EARTH_PLUGIN
	}

	QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6

	INCLUDEPATH += /Library/Frameworks/SDL.framework/Headers

	LIBS += -framework IOKit \
#		-F$$BASEDIR/libs/lib/Frameworks \
		-framework SDL \
		-framework CoreFoundation \
		-framework ApplicationServices \
		-lm

	ICON = $$BASEDIR/files/images/icons/macx.icns

	QMAKE_POST_LINK += $$quote(echo "Copying files")

	# Copy AQ files
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/bin
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/aq/bin/aq_osx_all/* $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/bin
	QMAKE_POST_LINK += && chmod +x $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/bin/*
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/mixes
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/aq/mixes/* $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/aq/mixes

	# Copy google earth starter file
	QMAKE_POST_LINK += && cp -f $$BASEDIR/files/*.* $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/files
	# Copy audio files
	QMAKE_POST_LINK += && cp -r $$BASEDIR/files/audio $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/files
	 # Copy language files
	QMAKE_POST_LINK += && cp -f $$BASEDIR/files/lang/*.qm $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/files/lang
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/files/lang/flags $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/files/lang
	# Copy libraries
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/libs
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/libs/lib/$${MACBITS}/lib/* $$TARGETDIR/qgroundcontrol.app/Contents/libs
	# Copy frameworks
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/qgroundcontrol.app/Contents/Frameworks
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/libs/lib/Frameworks/* $$TARGETDIR/qgroundcontrol.app/Contents/Frameworks

	# Fix library paths inside executable
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
	QMAKE_POST_LINK += && install_name_tool -change libosgViewer.dylib "@executable_path/../libs/libosgViewer.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
	QMAKE_POST_LINK += && install_name_tool -change libosgGA.dylib "@executable_path/../libs/libosgGA.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
	QMAKE_POST_LINK += && install_name_tool -change libosgText.dylib "@executable_path/../libs/libosgText.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol
	QMAKE_POST_LINK += && install_name_tool -change libosgWidget.dylib "@executable_path/../libs/libosgWidget.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol

	# Fix library paths within libraries (inter-library dependencies)

	# OSG GA LIBRARY
	QMAKE_POST_LINK += && install_name_tool -change libosgGA.dylib "@executable_path/../libs/libosgGA.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgGA.dylib

	# OSG DB LIBRARY
	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgDB.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgDB.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgDB.dylib
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgDB.dylib

	# OSG TEXT LIBRARY
	QMAKE_POST_LINK += && install_name_tool -change libosgText.dylib "@executable_path/../libs/libosgText.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgText.dylib

	# OSG UTIL LIBRARY
	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgUtil.dylib
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgUtil.dylib

	# OSG VIEWER LIBRARY
	QMAKE_POST_LINK += && install_name_tool -change libosgGA.dylib "@executable_path/../libs/libosgGA.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgText.dylib "@executable_path/../libs/libosgText.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgViewer.dylib

	# OSG WIDGET LIBRARY
	QMAKE_POST_LINK += && install_name_tool -change libosgGA.dylib "@executable_path/../libs/libosgGA.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgText.dylib "@executable_path/../libs/libosgText.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgDB.dylib "@executable_path/../libs/libosgDB.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgUtil.dylib "@executable_path/../libs/libosgUtil.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosg.dylib "@executable_path/../libs/libosg.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib
	QMAKE_POST_LINK += && install_name_tool -change libosgViewer.dylib "@executable_path/../libs/libosgViewer.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosgWidget.dylib

	# CORE OSG LIBRARY
	QMAKE_POST_LINK += && install_name_tool -change libOpenThreads.dylib "@executable_path/../libs/libOpenThreads.dylib" $$TARGETDIR/qgroundcontrol.app/Contents/libs/libosg.dylib

	# SDL Framework
	QMAKE_POST_LINK += && install_name_tool -change "@rpath/SDL.framework/Versions/A/SDL" "@executable_path/../Frameworks/SDL.framework/Versions/A/SDL" $$TARGETDIR/qgroundcontrol.app/Contents/MacOS/qgroundcontrol

	# No check for GLUT.framework since it's a MAC default
	message("Building support for OpenSceneGraph")
	DEPENDENCIES_PRESENT += osg
	DEFINES += QGC_OSG_ENABLED
	# Include OpenSceneGraph libraries
	INCLUDEPATH += -framework GLUT \
        -framework Cocoa \
		  $$BASEDIR/libs/lib/$${MACBITS}/include

	LIBS += -framework GLUT \
		  -framework Cocoa \
		  -L$$BASEDIR/libs/lib/$${MACBITS}/lib \
        -lOpenThreads \
        -losg \
        -losgViewer \
        -losgGA \
        -losgDB \
        -losgText \
        -losgWidget

        #exists(/usr/local/include/google/protobuf) {
        #	message("Building support for Protocol Buffers")
        #	DEPENDENCIES_PRESENT += protobuf
        #	# Include Protocol Buffers libraries
        #	LIBS += -L/usr/local/lib \
        #    -lprotobuf \
        #    -lprotobuf-lite \
        #    -lprotoc
        #
        #	DEFINES += QGC_PROTOBUF_ENABLED
        #}

	exists(/opt/local/include/libfreenect)|exists(/usr/local/include/libfreenect) {
		message("Building support for libfreenect")
		DEPENDENCIES_PRESENT += libfreenect
		# Include libfreenect libraries
		LIBS += -lfreenect
		DEFINES += QGC_LIBFREENECT_ENABLED
	}
}

# GNU/Linux
linux-g++|linux-g++-64{

	CONFIG -= console
	DEFINES += __STDC_LIMIT_MACROS
	DESTDIR = $$TARGETDIR

	release {
		DEFINES += QT_NO_DEBUG
	}

	INCLUDEPATH += /usr/include \
		  /usr/local/include \

	LIBS += \
		-L/usr/lib \
		-L/usr/local/lib64 \
		-lm \
#		-lflite_cmu_us_kal \
#		-lflite_usenglish \
#		-lflite_cmulex \
#		-lflite \
		-lSDL \
		-lSDLmain

	exists(/usr/include/osg) | exists(/usr/local/include/osg) {
		message("Building support for OpenSceneGraph")
		DEPENDENCIES_PRESENT += osg
		# Include OpenSceneGraph libraries
		LIBS += -losg \
            -losgViewer \
            -losgGA \
            -losgDB \
            -losgText \
            -lOpenThreads

		DEFINES += QGC_OSG_ENABLED
	}

	exists(/usr/include/osg/osgQt) | exists(/usr/include/osgQt) |
	exists(/usr/local/include/osg/osgQt) | exists(/usr/local/include/osgQt) {
		message("Building support for OpenSceneGraph Qt")
		# Include OpenSceneGraph Qt libraries
		LIBS += -losgQt
		DEFINES += QGC_OSG_QT_ENABLED
	}

	exists(/usr/local/include/google/protobuf) {
		message("Building support for Protocol Buffers")
		DEPENDENCIES_PRESENT += protobuf
		# Include Protocol Buffers libraries
		LIBS += -lprotobuf \
            -lprotobuf-lite \
            -lprotoc

		DEFINES += QGC_PROTOBUF_ENABLED
	}

	exists(/usr/local/include/libfreenect/libfreenect.h) {
		message("Building support for libfreenect")
		DEPENDENCIES_PRESENT += libfreenect
		INCLUDEPATH += /usr/include/libusb-1.0
		# Include libfreenect libraries
		LIBS += -lfreenect
		DEFINES += QGC_LIBFREENECT_ENABLED
	}

	QMAKE_POST_LINK += $$quote(echo "Copying files")

	# Validated copy commands
	!exists($$TARGETDIR){
		QMAKE_POST_LINK += && mkdir -p $$TARGETDIR
	}

	# Copy AQ files
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/aq/bin
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/aq/bin/aq_unix_all/* $$TARGETDIR/aq/bin
	QMAKE_POST_LINK += && mkdir -p $$TARGETDIR/aq/mixes
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/aq/mixes/* $$TARGETDIR/aq/mixes
	QMAKE_POST_LINK += && chmod +x $$TARGETDIR/aq/bin/*
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/files/*.* $$TARGETDIR/files
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/files/audio $$TARGETDIR/files/audio
	QMAKE_POST_LINK += && cp -f $$BASEDIR/files/lang/*.qm $$TARGETDIR/files/lang
	QMAKE_POST_LINK += && cp -rf $$BASEDIR/files/lang/flags $$TARGETDIR/files/lang/flags
	#QMAKE_POST_LINK += && cp -rf $$BASEDIR/data $$TARGETDIR

	# osg/osgEarth dynamic casts might fail without this compiler option.
	# see http://osgearth.org/wiki/FAQ for details.
	QMAKE_CXXFLAGS += -Wl,-E
}

linux-g++ {
	message("Building for GNU/Linux 32bit/i386")
        QMAKE_POST_LINK += && mv -f $$TARGETDIR/aq/bin/cal_32 $$TARGETDIR/aq/bin/cal
        QMAKE_POST_LINK += && mv -f $$TARGETDIR/aq/bin/sim3_32 $$TARGETDIR/aq/bin/sim3
}
linux-g++-64 {
	message("Building for GNU/Linux 64bit/x64 (g++-64)")
	exists(/usr/local/lib64) {
		LIBS += -L/usr/local/lib64
	}
        QMAKE_POST_LINK += && mv -f $$TARGETDIR/aq/bin/cal_64 $$TARGETDIR/aq/bin/cal
        QMAKE_POST_LINK += && mv -f $$TARGETDIR/aq/bin/sim3_64 $$TARGETDIR/aq/bin/sim3
}

# Windows (32bit), Visual Studio
win32-msvc2010|win32-msvc2012|win32-g++ {

	win32-msvc2010 {
		message(Building for Windows Visual Studio 2010 (32bit))
	}
	win32-msvc2012 {
		message(Building for Windows Visual Studio 2012 (32bit))
	}
	win32-g++ {
		message(Building for Windows GCC (32bit))
	}

	# Specify multi-process compilation within Visual Studio.
	# (drastically improves compilation times for multi-core computers)
	QMAKE_CFLAGS_DEBUG += /MP
	QMAKE_CXXFLAGS_DEBUG += /MP
	QMAKE_CFLAGS_RELEASE += /MP
	QMAKE_CXXFLAGS_RELEASE += /MP

	# QAxContainer support is needed for the Internet Control
	# element showing the Google Earth window
	greaterThan(QT_MAJOR_VERSION, 4) {
		QT += axcontainer
	} else {
		CONFIG += qaxcontainer
	}

	DEFINES += USE_GOOGLE_EARTH_PLUGIN

	# The EIGEN library needs this define
	# to make the internal min/max functions work
	DEFINES += NOMINMAX

	# QWebkit is not needed on MS-Windows compilation environment
	CONFIG -= webkit webkitwidgets

	# Specify the inclusion of (U)INT*_(MAX/MIN) macros within Visual Studio
	DEFINES += __STDC_LIMIT_MACROS

	# For release builds remove support for various Qt debugging macros.
	CONFIG(release, debug|release) {
		DEFINES += QT_NO_DEBUG
	}

	# For debug releases we just want the debugging console.
	CONFIG(debug, debug|release) {
		CONFIG += console
	}

	INCLUDEPATH += $$BASEDIR/libs/lib/sdl/msvc/include \
        $$BASEDIR/libs/lib/opal/include \
        $$BASEDIR/libs/lib/msinttypes

	LIBS += -L$$BASEDIR/libs/lib/sdl/msvc/lib \
        -lSDLmain -lSDL \
        -lsetupapi

	exists($$BASEDIR/libs/lib/osg123) {
		message("Building support for OSG")
		DEPENDENCIES_PRESENT += osg

		# Include OpenSceneGraph
		INCLUDEPATH += $$BASEDIR/libs/lib/osgEarth/win32/include \
			$$BASEDIR/libs/lib/osgEarth_3rdparty/win32/OpenSceneGraph-2.8.2/include
		LIBS += -L$$BASEDIR/libs/lib/osgEarth_3rdparty/win32/OpenSceneGraph-2.8.2/lib \
			-losg \
			-losgViewer \
			-losgGA \
			-losgDB \
			-losgText \
			-lOpenThreads
		DEFINES += QGC_OSG_ENABLED
	}

	RC_FILE = $$BASEDIR/qgroundcontrol.rc

	# Copy dependencies
	BASEDIR_WIN = $$replace(BASEDIR,"/","\\")
	TARGETDIR_WIN = $$replace(TARGETDIR,"/","\\")\\release
	greaterThan(QT_MAJOR_VERSION, 4) {
		QTLIBDLLPFX = "Qt5"
		QTLIBDLLSFX = ".dll"
	} else {
		QTLIBDLLPFX = "Qt"
		QTLIBDLLSFX = "4.dll"
	}
	CONFIG(debug, debug|release) {
		TARGETDIR_WIN = $$replace(TARGETDIR,"/","\\")\\debug
		greaterThan(QT_MAJOR_VERSION, 4) {
			QTLIBDLLSFX = "d.dll"
		} else {
			QTLIBDLLSFX = "d4.dll"
		}
	}

	QMAKE_POST_LINK += $$quote(echo "Copying files"$$escape_expand(\\n))

	# Copy AQ files
	QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\aq\\bin\\aq_win_all\\*" "$$TARGETDIR_WIN\\aq\\bin" /E /I $$escape_expand(\\n))
	QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\aq\\mixes\\*" "$$TARGETDIR_WIN\\aq\\mixes" /E /I $$escape_expand(\\n))

	# Copy VLC files  --  just install VNC instaed!
#	contains(DEFINES, QGC_USE_VLC) {
#		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\vlc\\plugins\\*"  "$$TARGETDIR_WIN\\plugins" /E /I $$escape_expand(\\n))
#		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\vlc\\libvlccore.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
#		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\vlc\\libvlc.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
#	}

	# Copy application resources
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /I "$$BASEDIR_WIN\\files\\*.*" "$$TARGETDIR_WIN\\files\\" $$escape_expand(\\n))
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /E /I "$$BASEDIR_WIN\\files\\audio" "$$TARGETDIR_WIN\\files\\audio" $$escape_expand(\\n))
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /I "$$BASEDIR_WIN\\files\\lang\\*.qm" "$$TARGETDIR_WIN\\files\\lang" $$escape_expand(\\n))
	QMAKE_POST_LINK += $$quote(xcopy /D /Y /E /I "$$BASEDIR_WIN\\files\\lang" "$$TARGETDIR_WIN\\files\\lang" $$escape_expand(\\n))

	CONFIG(release, debug|release) {
		# Copy supporting library DLLs
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\lib\\sdl\\win32\\SDL.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		#QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$BASEDIR_WIN\\libs\\thirdParty\\libxbee\\lib\\libxbee.dll" "$$TARGETDIR_WIN"$$escape_expand(\\n))

		# Copy Qt DLLs
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\plugins\\imageformats\\*$${QTLIBDLLSFX}" "$$TARGETDIR_WIN\\imageformats" /E /I $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\plugins\\iconengines\\*$${QTLIBDLLSFX}" "$$TARGETDIR_WIN\\iconengines" /E /I $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\plugins\\sqldrivers\\*$${QTLIBDLLSFX}" "$$TARGETDIR_WIN\\sqldrivers" /E /I $$escape_expand(\\n))
		CONFIG(release, debug|release) {
		}
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Core$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Gui$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Multimedia$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Network$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}OpenGL$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Sql$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Svg$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Test$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}WebKit$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}Xml$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(xcopy /D /Y "$$(QTDIR)\\bin\\$${QTLIBDLLPFX}XmlPatterns$$QTLIBDLLSFX" "$$TARGETDIR_WIN"$$escape_expand(\\n))

		# clean up stuff not needed by release versions
		QMAKE_POST_LINK += $$quote(del /Q "$$TARGETDIR_WIN\\imageformats\\*d4.dll" $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(del /Q "$$TARGETDIR_WIN\\iconengines\\*d4.dll" $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(del /Q "$$TARGETDIR_WIN\\sqldrivers\\*d4.dll" $$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(del /F "$$TARGETDIR_WIN\\qgroundcontrol.exp"$$escape_expand(\\n))
		QMAKE_POST_LINK += $$quote(del /F "$$TARGETDIR_WIN\\qgroundcontrol.lib"$$escape_expand(\\n))

		# Copy Visual Studio DLLs
		win32-msvc2010 {
			QMAKE_POST_LINK += $$quote(xcopy /D /Y "\"C:\\Program Files \(x86\)\\Microsoft Visual Studio 10.0\\VC\\redist\\x86\\Microsoft.VC100.CRT\\*.dll\""  "$$TARGETDIR_WIN\\"$$escape_expand(\\n))
		}
		win32-msvc2012 {
			 QMAKE_POST_LINK += $$quote(xcopy /D /Y "\"C:\\Program Files \(x86\)\\Microsoft Visual Studio 11.0\\VC\\redist\\x86\\Microsoft.VC110.CRT\\*.dll\""  "$${TARGETDIR}\\"$$escape_expand(\\n))
		}
		win32-g++ {
			# we need to know where MinGW lives so we can copy some DLLs from there.
			MINGW_PATH = $$(MINGW_PATH)
			isEmpty(MINGW_PATH): error("MINGW_PATH not found")
			QMAKE_POST_LINK  += $$quote(xcopy /D /Y "$${MINGW_PATH}\\bin\\libwinpthread-1.dll"  "$${TARGETDIR}"$$escape_expand(\\n\\t))
			QMAKE_POST_LINK  += $$quote(xcopy /D /Y "$${MINGW_PATH}\\bin\\libstdc++-6.dll"  "$${TARGETDIR}"$$escape_expand(\\n))
		}
	}
}


Make group membership filter public

Make group membership filter public

INCLUDEPATH += filters

PUBLIC_HEADERS += \
    filters/qcontactactionfilter.h \
    filters/qcontactchangelogfilter.h \
    filters/qcontactdetailfilter.h \
    filters/qcontactdetailrangefilter.h \
    filters/qcontactfilters.h \
    filters/qcontactgroupmembershipfilter.h \
    filters/qcontactidlistfilter.h \
    filters/qcontactintersectionfilter.h \
    filters/qcontactinvalidfilter.h \
    filters/qcontactunionfilter.h

PRIVATE_HEADERS += \
    filters/qcontactactionfilter_p.h \
    filters/qcontactchangelogfilter_p.h \
    filters/qcontactdetailfilter_p.h \
    filters/qcontactdetailrangefilter_p.h \
    filters/qcontactgroupmembershipfilter_p.h \
    filters/qcontactintersectionfilter_p.h \
    filters/qcontactunionfilter_p.h \
    filters/qcontactidlistfilter_p.h

SOURCES += \
    filters/qcontactactionfilter.cpp \
    filters/qcontactchangelogfilter.cpp \
    filters/qcontactdetailfilter.cpp \
    filters/qcontactdetailrangefilter.cpp \
    filters/qcontactgroupmembershipfilter.cpp \
    filters/qcontactintersectionfilter.cpp \
    filters/qcontactunionfilter.cpp \
    filters/qcontactinvalidfilter.cpp \
    filters/qcontactidlistfilter.cpp

INCLUDEPATH += filters

PUBLIC_HEADERS += \
    filters/qcontactactionfilter.h \
    filters/qcontactchangelogfilter.h \
    filters/qcontactdetailfilter.h \
    filters/qcontactdetailrangefilter.h \
    filters/qcontactfilters.h \
    filters/qcontactintersectionfilter.h \
    filters/qcontactunionfilter.h \
    filters/qcontactinvalidfilter.h \
    filters/qcontactidlistfilter.h

PRIVATE_HEADERS += \
    filters/qcontactactionfilter_p.h \
    filters/qcontactchangelogfilter_p.h \
    filters/qcontactdetailfilter_p.h \
    filters/qcontactdetailrangefilter_p.h \
    filters/qcontactgroupmembershipfilter.h \
    filters/qcontactgroupmembershipfilter_p.h \
    filters/qcontactintersectionfilter_p.h \
    filters/qcontactunionfilter_p.h \
    filters/qcontactidlistfilter_p.h

SOURCES += \
    filters/qcontactactionfilter.cpp \
    filters/qcontactchangelogfilter.cpp \
    filters/qcontactdetailfilter.cpp \
    filters/qcontactdetailrangefilter.cpp \
    filters/qcontactgroupmembershipfilter.cpp \
    filters/qcontactintersectionfilter.cpp \
    filters/qcontactunionfilter.cpp \
    filters/qcontactinvalidfilter.cpp \
    filters/qcontactidlistfilter.cpp


Bump version to 0.2.10

Bump version to 0.2.10


[linux] Fixed coastlines generation bug with float point rounding

# This file is a template commmon for all qmake projects.
#
# To use it, define ROOT_DIR variable and include($$ROOT_DIR/common.pri)

# our own version variables
VERSION_MAJOR = 2
VERSION_MINOR = 0

# qt's variable
VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}

# Additional include directories, common to most projects.
INCLUDEPATH *= $$ROOT_DIR/3party/boost

# Automatically enable release config for production
CONFIG(production) {
  CONFIG *= release
}

CONFIG(release, debug|release) {
  DEFINES *= RELEASE _RELEASE NDEBUG
  CONFIG(production) {
    CONFIG_NAME = production
  } else {
    CONFIG_NAME = release
  }
} else {
  DEFINES *= DEBUG _DEBUG
  CONFIG_NAME = debug
}

# turn off maps downloader engine for desktops in release and production
#!iphone* {
#  CONFIG(release, debug|release)|CONFIG(production) {
#    CONFIG += no_downloader
#    DEFINES += NO_DOWNLOADER
#  }
#}

BINARIES_PATH = $$ROOT_DIR/out/$$CONFIG_NAME
TEMP_PATH = $$ROOT_DIR/out/$$CONFIG_NAME/tmp/$$TARGET

DESTDIR = $$BINARIES_PATH
OBJECTS_DIR = $$TEMP_PATH
RCC_DIR = $$TEMP_PATH
MOC_DIR = $$TEMP_PATH
UI_DIR = $$TEMP_PATH

QMAKE_LIBDIR *= $$BINARIES_PATH

# By default, do not include base QT classes in any project.
QT -= core gui

# Turn on compiler warnings.
CONFIG += warn_on

# Libraries' dependencies hack.
win32-msvc*|symbian {
  LIB_EXT = .lib
  LIB_PREFIX =
}
unix|win32-g++|bada-simulator {
 LIB_EXT = .a
 LIB_PREFIX = lib
}

# Add libraries' dependencies.
for(project, DEPENDENCIES) {
  PRE_TARGETDEPS += $$BINARIES_PATH/$$LIB_PREFIX$$project$$LIB_EXT
  LIBS += -l$$project
}

#INCLUDEPATH += $$ROOT_DIR/3party/protobuf/src/

# Windows-specific options for all projects
win32 {
  DEFINES += _WIN32_WINNT=0x0501
  DEFINES += WINVER=0x0501
  DEFINES += _WIN32_IE=0x0501
  DEFINES += WIN32_LEAN_AND_MEAN=1
  DEFINES += NTDDI_VERSION=0x05010000
}

win32-msvc* {
  QMAKE_CLEAN += *.user
  DEFINES += _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS NOMINMAX NO_MIN_MAX
  QMAKE_CXXFLAGS += /Fd$${DESTDIR}/$${TARGET}.pdb /Zi /fp:fast
  QMAKE_CFLAGS += /Fd$${DESTDIR}/$${TARGET}.pdb /Zi /fp:fast

  QMAKE_CXXFLAGS_RELEASE -= /O2
  # don't set -GL - bug in msvc2008
  QMAKE_CXXFLAGS_RELEASE += /Ox /GF
  # don't set /LTCG - bug in msvc2008
  QMAKE_LFLAGS_RELEASE += /MACHINE:X86

  QMAKE_LFLAGS *= /OPT:REF
  QMAKE_LFLAGS_RELEASE *= /OPT:ICF
  QMAKE_LFLAGS_DEBUG *= /OPT:NOICF

  CONFIG(release, debug|release) {
    DEFINES += _SECURE_SCL=0
  }
}

win32-msvc2010 {
  DEFINES += _HAS_CPP0X=0 # disable tr1 and c++0x features to avoid build errors
  QMAKE_CFLAGS_RELEASE += /GL
  QMAKE_CXXFLAGS_RELEASE += /GL
  QMAKE_LFLAGS_RELEASE += /LTCG
  QMAKE_LIB += /LTCG
}

unix|win32-g++ {
  QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-compare -Wno-strict-aliasing -Wno-unused-parameter \
      -Werror=return-type
  *-clang {
    QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-conversion
  }
  # experimental
  QMAKE_CFLAGS_RELEASE -= -O2
  QMAKE_CFLAGS_RELEASE += -O3
  QMAKE_CXXFLAGS_RELEASE -= -O2
  QMAKE_CXXFLAGS_RELEASE += -O3
  QMAKE_CFLAGS_RELEASE *= -ffast-math
  QMAKE_CXXFLAGS_RELEASE *= -ffast-math
}

linux-g++* {
#  QMAKE_CFLAGS_RELEASE   += -flto
#  QMAKE_CXXFLAGS_RELEASE += -flto
#  QMAKE_LFLAGS_RELEASE   += -flto
  QMAKE_CFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_CXXFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_LFLAGS *= -Wl,--gc-sections
  QMAKE_CFLAGS_RELEASE *= -ffloat-store
  QMAKE_CXXFLAGS_RELEASE *= -ffloat-store
}

android-g++ {
  QMAKE_CFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_CXXFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_LFLAGS *= -Wl,--gc-sections
}

win32-g++ {
  QMAKE_CFLAGS *= -Wextra
  QMAKE_CXXFLAGS *= -Wextra
  QMAKE_LFLAGS *= -s
  QMAKE_LFLAGS_RELEASE *= -O
}

macx* {
  # minimum supported Mac OS X version
  QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
  QMAKE_CFLAGS *= -mmacosx-version-min=10.6
  QMAKE_CXXFLAGS *= -mmacosx-version-min=10.6
  # replace 10.5 with 10.6
  QMAKE_CFLAGS_X86_64 -= -mmacosx-version-min=10.5
  QMAKE_CXXFLAGS_X86_64 -= -mmacosx-version-min=10.5
  QMAKE_CFLAGS_X86_64 += -mmacosx-version-min=10.6    # CXX is made based on CFLAGS
  QMAKE_OBJECTIVE_CFLAGS_X86_64 -= -mmacosx-version-min=10.5
  QMAKE_OBJECTIVE_CFLAGS_X86_64 += -mmacosx-version-min=10.6
  QMAKE_LFLAGS_X86_64 -= -mmacosx-version-min=10.5
  QMAKE_LFLAGS_X86_64 += -mmacosx-version-min=10.6
  QMAKE_LFLAGS *= -dead_strip

#  macx-clang {
#    QMAKE_CFLAGS_RELEASE -= -O3
#    QMAKE_CFLAGS_RELEASE += -O4 -flto
#    QMAKE_CXXFLAGS_RELEASE -= -O3
#    QMAKE_CXXFLAGS_RELEASE += -O4 -flto
#    QMAKE_LFLAGS_RELEASE += -O4 -flto
#  }
}

CONFIG(production) {
  DEFINES += OMIM_PRODUCTION
} else {
  # enable debugging information for non-production release builds
  unix|win32-g++ {
    QMAKE_CFLAGS_RELEASE += -g
    QMAKE_CXXFLAGS_RELEASE += -g
  } win32-msvc* {
    QMAKE_LFLAGS += /PDB:$${DESTDIR}/$${TARGET}.pdb /DEBUG
  }
}

# This file is a template commmon for all qmake projects.
#
# To use it, define ROOT_DIR variable and include($$ROOT_DIR/common.pri)

# our own version variables
VERSION_MAJOR = 2
VERSION_MINOR = 0

# qt's variable
VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}

# Additional include directories, common to most projects.
INCLUDEPATH *= $$ROOT_DIR/3party/boost

# Automatically enable release config for production
CONFIG(production) {
  CONFIG *= release
}

CONFIG(release, debug|release) {
  DEFINES *= RELEASE _RELEASE NDEBUG
  CONFIG(production) {
    CONFIG_NAME = production
  } else {
    CONFIG_NAME = release
  }
} else {
  DEFINES *= DEBUG _DEBUG
  CONFIG_NAME = debug
}

# turn off maps downloader engine for desktops in release and production
#!iphone* {
#  CONFIG(release, debug|release)|CONFIG(production) {
#    CONFIG += no_downloader
#    DEFINES += NO_DOWNLOADER
#  }
#}

BINARIES_PATH = $$ROOT_DIR/out/$$CONFIG_NAME
TEMP_PATH = $$ROOT_DIR/out/$$CONFIG_NAME/tmp/$$TARGET

DESTDIR = $$BINARIES_PATH
OBJECTS_DIR = $$TEMP_PATH
RCC_DIR = $$TEMP_PATH
MOC_DIR = $$TEMP_PATH
UI_DIR = $$TEMP_PATH

QMAKE_LIBDIR *= $$BINARIES_PATH

# By default, do not include base QT classes in any project.
QT -= core gui

# Turn on compiler warnings.
CONFIG += warn_on

# Libraries' dependencies hack.
win32-msvc*|symbian {
  LIB_EXT = .lib
  LIB_PREFIX =
}
unix|win32-g++|bada-simulator {
 LIB_EXT = .a
 LIB_PREFIX = lib
}

# Add libraries' dependencies.
for(project, DEPENDENCIES) {
  PRE_TARGETDEPS += $$BINARIES_PATH/$$LIB_PREFIX$$project$$LIB_EXT
  LIBS += -l$$project
}

#INCLUDEPATH += $$ROOT_DIR/3party/protobuf/src/

# Windows-specific options for all projects
win32 {
  DEFINES += _WIN32_WINNT=0x0501
  DEFINES += WINVER=0x0501
  DEFINES += _WIN32_IE=0x0501
  DEFINES += WIN32_LEAN_AND_MEAN=1
  DEFINES += NTDDI_VERSION=0x05010000
}

win32-msvc* {
  QMAKE_CLEAN += *.user
  DEFINES += _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS NOMINMAX NO_MIN_MAX
  QMAKE_CXXFLAGS += /Fd$${DESTDIR}/$${TARGET}.pdb /Zi /fp:fast
  QMAKE_CFLAGS += /Fd$${DESTDIR}/$${TARGET}.pdb /Zi /fp:fast

  QMAKE_CXXFLAGS_RELEASE -= /O2
  # don't set -GL - bug in msvc2008
  QMAKE_CXXFLAGS_RELEASE += /Ox /GF
  # don't set /LTCG - bug in msvc2008
  QMAKE_LFLAGS_RELEASE += /MACHINE:X86

  QMAKE_LFLAGS *= /OPT:REF
  QMAKE_LFLAGS_RELEASE *= /OPT:ICF
  QMAKE_LFLAGS_DEBUG *= /OPT:NOICF

  CONFIG(release, debug|release) {
    DEFINES += _SECURE_SCL=0
  }
}

win32-msvc2010 {
  DEFINES += _HAS_CPP0X=0 # disable tr1 and c++0x features to avoid build errors
  QMAKE_CFLAGS_RELEASE += /GL
  QMAKE_CXXFLAGS_RELEASE += /GL
  QMAKE_LFLAGS_RELEASE += /LTCG
  QMAKE_LIB += /LTCG
}

unix|win32-g++ {
  QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-compare -Wno-strict-aliasing -Wno-unused-parameter \
      -Werror=return-type
  *-clang {
    QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-conversion
  }
  # experimental
  QMAKE_CFLAGS_RELEASE -= -O2
  QMAKE_CFLAGS_RELEASE += -O3
  QMAKE_CXXFLAGS_RELEASE -= -O2
  QMAKE_CXXFLAGS_RELEASE += -O3
  QMAKE_CFLAGS_RELEASE *= -ffast-math
  QMAKE_CXXFLAGS_RELEASE *= -ffast-math
}

linux-g++* {
#  QMAKE_CFLAGS_RELEASE   += -flto
#  QMAKE_CXXFLAGS_RELEASE += -flto
#  QMAKE_LFLAGS_RELEASE   += -flto
  QMAKE_CFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_CXXFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_LFLAGS *= -Wl,--gc-sections
}

android-g++ {
  QMAKE_CFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_CXXFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_LFLAGS *= -Wl,--gc-sections
}

win32-g++ {
  QMAKE_CFLAGS *= -Wextra
  QMAKE_CXXFLAGS *= -Wextra
  QMAKE_LFLAGS *= -s
  QMAKE_LFLAGS_RELEASE *= -O
}

macx* {
  # minimum supported Mac OS X version
  QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
  QMAKE_CFLAGS *= -mmacosx-version-min=10.6
  QMAKE_CXXFLAGS *= -mmacosx-version-min=10.6
  # replace 10.5 with 10.6
  QMAKE_CFLAGS_X86_64 -= -mmacosx-version-min=10.5
  QMAKE_CXXFLAGS_X86_64 -= -mmacosx-version-min=10.5
  QMAKE_CFLAGS_X86_64 += -mmacosx-version-min=10.6    # CXX is made based on CFLAGS
  QMAKE_OBJECTIVE_CFLAGS_X86_64 -= -mmacosx-version-min=10.5
  QMAKE_OBJECTIVE_CFLAGS_X86_64 += -mmacosx-version-min=10.6
  QMAKE_LFLAGS_X86_64 -= -mmacosx-version-min=10.5
  QMAKE_LFLAGS_X86_64 += -mmacosx-version-min=10.6
  QMAKE_LFLAGS *= -dead_strip

#  macx-clang {
#    QMAKE_CFLAGS_RELEASE -= -O3
#    QMAKE_CFLAGS_RELEASE += -O4 -flto
#    QMAKE_CXXFLAGS_RELEASE -= -O3
#    QMAKE_CXXFLAGS_RELEASE += -O4 -flto
#    QMAKE_LFLAGS_RELEASE += -O4 -flto
#  }
}

CONFIG(production) {
  DEFINES += OMIM_PRODUCTION
} else {
  # enable debugging information for non-production release builds
  unix|win32-g++ {
    QMAKE_CFLAGS_RELEASE += -g
    QMAKE_CXXFLAGS_RELEASE += -g
  } win32-msvc* {
    QMAKE_LFLAGS += /PDB:$${DESTDIR}/$${TARGET}.pdb /DEBUG
  }
}


define QCA_STATIC if qca-static is used

define QCA_STATIC if qca-static is used

git-svn-id: ced07d5e10f05f45759cb75bdadb6610d25656be@187 ac7a513c-5e3a-0410-af42-968c3ac6e7dc

# common stuff for iris.pro and iris.pri

include(build.pri)

# HACK: check for psi configuration
unix:include(../conf.pri)
windows:include(../conf_windows.pri)

# HACK: use qca from psi if necessary
qca-static {
	DEFINES += QCA_STATIC
	INCLUDEPATH += $$PWD/../third-party/qca/qca/include/QtCrypto
}

# HACK: use zlib from psi if necessary
psi-zip {
	INCLUDEPATH += $$PWD/../src/tools/zip/minizip/win32
}

# HACK: this should not be in common.pri, since it means the user of iris gets
#  this code as well
mac {
	# Universal binaries
	qc_universal:contains(QT_CONFIG,x86):contains(QT_CONFIG,ppc) {
		CONFIG += x86 ppc
		QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk
		QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
	}
}

# default build configuration
!iris_build_pri {
	# build appledns on mac
	mac:CONFIG += appledns

	# bundle appledns inside of irisnetcore on mac
	mac:CONFIG += appledns_bundle

	# bundle irisnetcore inside of iris
	CONFIG += irisnetcore_bundle

	# don't build iris, app will include iris.pri
	#CONFIG += iris_bundle
}

# common stuff for iris.pro and iris.pri

include(build.pri)

# HACK: check for psi configuration
unix:include(../conf.pri)
windows:include(../conf_windows.pri)

# HACK: use qca from psi if necessary
qca-static {
	INCLUDEPATH += $$PWD/../third-party/qca/qca/include/QtCrypto
}

# HACK: use zlib from psi if necessary
psi-zip {
	INCLUDEPATH += $$PWD/../src/tools/zip/minizip/win32
}

# HACK: this should not be in common.pri, since it means the user of iris gets
#  this code as well
mac {
	# Universal binaries
	qc_universal:contains(QT_CONFIG,x86):contains(QT_CONFIG,ppc) {
		CONFIG += x86 ppc
		QMAKE_MAC_SDK=/Developer/SDKs/MacOSX10.4u.sdk
		QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.4
	}
}

# default build configuration
!iris_build_pri {
	# build appledns on mac
	mac:CONFIG += appledns

	# bundle appledns inside of irisnetcore on mac
	mac:CONFIG += appledns_bundle

	# bundle irisnetcore inside of iris
	CONFIG += irisnetcore_bundle

	# don't build iris, app will include iris.pri
	#CONFIG += iris_bundle
}


[paths] Restore compile dependencies for local hpp include files.

# This file is a template commmon for all qmake projects.
#
# To use it, define ROOT_DIR variable and include($$ROOT_DIR/common.pri)

#CONFIG *= drape

drape {
  DEFINES *= USE_DRAPE
}

# our own version variables
VERSION_MAJOR = 2
VERSION_MINOR = 4

# qt's variable
VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}

# Additional include directories, common to most projects.
INCLUDEPATH *= $$ROOT_DIR
INCLUDEPATH *= $$ROOT_DIR/3party/boost
INCLUDEPATH *= $$ROOT_DIR/3party/glm

# hack for Qt5 qmake to make it faster
CONFIG -= depend_includepath

DEPENDPATH *= $$ROOT_DIR

CONFIG *= c++11

!win32* {
  QMAKE_CFLAGS   *= -Wno-deprecated-register
  QMAKE_CXXFLAGS *= -Wno-deprecated-register
}

# Automatically enable release config for production
CONFIG(production) {
  CONFIG *= release
}

CONFIG(release, debug|release) {
  DEFINES *= RELEASE _RELEASE NDEBUG
  CONFIG(production) {
    CONFIG_NAME = production
  } else {
    CONFIG_NAME = release
  }
} else {
  DEFINES *= DEBUG _DEBUG
  CONFIG_NAME = debug
}

BINARIES_PATH = $$ROOT_DIR/out/$$CONFIG_NAME
TEMP_PATH = $$ROOT_DIR/out/$$CONFIG_NAME/tmp/$$TARGET

DESTDIR = $$BINARIES_PATH
OBJECTS_DIR = $$TEMP_PATH
RCC_DIR = $$TEMP_PATH
MOC_DIR = $$TEMP_PATH
UI_DIR = $$TEMP_PATH

QMAKE_LIBDIR *= $$BINARIES_PATH

# By default, do not include base QT classes in any project.
QT -= core gui

# Libraries' dependencies hack.
win32-msvc*|symbian {
  LIB_EXT = .lib
  LIB_PREFIX =
}
unix|win32-g++|tizen* {
 LIB_EXT = .a
 LIB_PREFIX = lib
}

# Add libraries' dependencies.
for(project, DEPENDENCIES) {
  PRE_TARGETDEPS += $$BINARIES_PATH/$$LIB_PREFIX$$project$$LIB_EXT
  LIBS += -l$$project
}

#INCLUDEPATH += $$ROOT_DIR/3party/protobuf/src/

# Windows-specific options for all projects
win32 {
  DEFINES += _WIN32_WINNT=0x0501
  DEFINES += WINVER=0x0501
  DEFINES += _WIN32_IE=0x0501
  DEFINES += WIN32_LEAN_AND_MEAN=1
  DEFINES += NTDDI_VERSION=0x05010000
}

win32-msvc* {
  QMAKE_CLEAN += *.user
  DEFINES += _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS NOMINMAX NO_MIN_MAX _USE_MATH_DEFINES BOOST_ALL_NO_LIB
  QMAKE_CXXFLAGS += /Zi /fp:fast
  QMAKE_CFLAGS += /Zi /fp:fast

  QMAKE_CXXFLAGS_RELEASE -= /O2
  # don't set -GL - bug in msvc2008
  QMAKE_CXXFLAGS_RELEASE += /Ox /GF
  # don't set /LTCG - bug in msvc2008
  QMAKE_LFLAGS_RELEASE += /MACHINE:X86

  QMAKE_LFLAGS *= /OPT:REF
  QMAKE_LFLAGS_RELEASE *= /OPT:REF,ICF
  QMAKE_LFLAGS_DEBUG *= /OPT:NOICF

  CONFIG(release, debug|release) {
    DEFINES += _SECURE_SCL=0
  }
}

win32-msvc201* {
  # disable tr1 and c++0x features to avoid build errors
#  DEFINES += _HAS_CPP0X=0
#  DEFINES += BOOST_NO_CXX11_HDR_ARRAY BOOST_NO_CXX11_HDR_TYPEINDEX BOOST_NO_CXX11_SMART_PTR
  QMAKE_CFLAGS *= /wd4100
  QMAKE_CXXFLAGS *= /wd4100
  QMAKE_CFLAGS_RELEASE += /GL
  QMAKE_CXXFLAGS_RELEASE += /GL
  QMAKE_LFLAGS_RELEASE += /LTCG
  QMAKE_LIB += /LTCG
}

# unix also works for Android
unix|win32-g++ {
  QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-compare -Wno-strict-aliasing -Wno-unused-parameter \
      -Werror=return-type
  *-clang {
    QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-conversion
  }

tizen{
  QMAKE_CFLAGS_RELEASE -= -O2
  QMAKE_CFLAGS_RELEASE += -O1
  QMAKE_CXXFLAGS_RELEASE -= -O2
  QMAKE_CXXFLAGS_RELEASE += -O1
  QMAKE_CFLAGS_RELEASE *= -ffast-math
  QMAKE_CXXFLAGS_RELEASE *= -ffast-math
} else {
  QMAKE_CFLAGS_RELEASE -= -O2
  QMAKE_CFLAGS_RELEASE += -O3
  QMAKE_CXXFLAGS_RELEASE -= -O2
  QMAKE_CXXFLAGS_RELEASE += -O3
  QMAKE_CFLAGS_RELEASE *= -ffast-math
  QMAKE_CXXFLAGS_RELEASE *= -ffast-math
}

}

linux-* {
  QMAKE_CFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_CXXFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_LFLAGS *= -Wl,--gc-sections -Wl,-Bsymbolic-functions
  linux-g++* {
    QMAKE_CFLAGS_RELEASE *= -ffloat-store
    QMAKE_CXXFLAGS_RELEASE *= -ffloat-store
  }
  # debian build requirements
  CONFIG(production) {
    QMAKE_CFLAGS_RELEASE = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security
    QMAKE_CXXFLAGS_RELEASE = -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security
    QMAKE_LFLAGS *= -Wl,-z,relro
  }

}

android-g++ {
  QMAKE_CFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_CXXFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_LFLAGS *= -Wl,--gc-sections
}

win32-g++ {
  QMAKE_CFLAGS *= -Wextra
  QMAKE_CXXFLAGS *= -Wextra
  QMAKE_LFLAGS *= -s
  QMAKE_LFLAGS_RELEASE *= -O
}

macx-* {
  QMAKE_LFLAGS *= -dead_strip

#  macx-clang {
#    QMAKE_CFLAGS_RELEASE -= -O3
#    QMAKE_CFLAGS_RELEASE += -O4 -flto
#    QMAKE_CXXFLAGS_RELEASE -= -O3
#    QMAKE_CXXFLAGS_RELEASE += -O4 -flto
#    QMAKE_LFLAGS_RELEASE += -O4 -flto
#  }
}

CONFIG(production) {
  DEFINES += OMIM_PRODUCTION
} else {
  # enable debugging information for non-production release builds
  unix|win32-g++ {
    QMAKE_CFLAGS_RELEASE += -g
    QMAKE_CXXFLAGS_RELEASE += -g
  } win32-msvc* {
    QMAKE_LFLAGS += /PDB:$${DESTDIR}/$${TARGET}.pdb /DEBUG
  }
}

# Fix boost compilation error
win32* {
    QMAKE_MOC = $$[QT_INSTALL_BINS]/moc.exe -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED
} else {
    QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED
}

# This file is a template commmon for all qmake projects.
#
# To use it, define ROOT_DIR variable and include($$ROOT_DIR/common.pri)

#CONFIG *= drape

drape {
  DEFINES *= USE_DRAPE
}

# our own version variables
VERSION_MAJOR = 2
VERSION_MINOR = 4

# qt's variable
VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}

# Additional include directories, common to most projects.
INCLUDEPATH *= $$ROOT_DIR
INCLUDEPATH *= $$ROOT_DIR/3party/boost
INCLUDEPATH *= $$ROOT_DIR/3party/glm

# hack for Qt5 qmake to make it faster
CONFIG -= depend_includepath

CONFIG *= c++11

!win32* {
  QMAKE_CFLAGS   *= -Wno-deprecated-register
  QMAKE_CXXFLAGS *= -Wno-deprecated-register
}

# Automatically enable release config for production
CONFIG(production) {
  CONFIG *= release
}

CONFIG(release, debug|release) {
  DEFINES *= RELEASE _RELEASE NDEBUG
  CONFIG(production) {
    CONFIG_NAME = production
  } else {
    CONFIG_NAME = release
  }
} else {
  DEFINES *= DEBUG _DEBUG
  CONFIG_NAME = debug
}

BINARIES_PATH = $$ROOT_DIR/out/$$CONFIG_NAME
TEMP_PATH = $$ROOT_DIR/out/$$CONFIG_NAME/tmp/$$TARGET

DESTDIR = $$BINARIES_PATH
OBJECTS_DIR = $$TEMP_PATH
RCC_DIR = $$TEMP_PATH
MOC_DIR = $$TEMP_PATH
UI_DIR = $$TEMP_PATH

QMAKE_LIBDIR *= $$BINARIES_PATH

# By default, do not include base QT classes in any project.
QT -= core gui

# Libraries' dependencies hack.
win32-msvc*|symbian {
  LIB_EXT = .lib
  LIB_PREFIX =
}
unix|win32-g++|tizen* {
 LIB_EXT = .a
 LIB_PREFIX = lib
}

# Add libraries' dependencies.
for(project, DEPENDENCIES) {
  PRE_TARGETDEPS += $$BINARIES_PATH/$$LIB_PREFIX$$project$$LIB_EXT
  LIBS += -l$$project
}

#INCLUDEPATH += $$ROOT_DIR/3party/protobuf/src/

# Windows-specific options for all projects
win32 {
  DEFINES += _WIN32_WINNT=0x0501
  DEFINES += WINVER=0x0501
  DEFINES += _WIN32_IE=0x0501
  DEFINES += WIN32_LEAN_AND_MEAN=1
  DEFINES += NTDDI_VERSION=0x05010000
}

win32-msvc* {
  QMAKE_CLEAN += *.user
  DEFINES += _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS NOMINMAX NO_MIN_MAX _USE_MATH_DEFINES BOOST_ALL_NO_LIB
  QMAKE_CXXFLAGS += /Zi /fp:fast
  QMAKE_CFLAGS += /Zi /fp:fast

  QMAKE_CXXFLAGS_RELEASE -= /O2
  # don't set -GL - bug in msvc2008
  QMAKE_CXXFLAGS_RELEASE += /Ox /GF
  # don't set /LTCG - bug in msvc2008
  QMAKE_LFLAGS_RELEASE += /MACHINE:X86

  QMAKE_LFLAGS *= /OPT:REF
  QMAKE_LFLAGS_RELEASE *= /OPT:REF,ICF
  QMAKE_LFLAGS_DEBUG *= /OPT:NOICF

  CONFIG(release, debug|release) {
    DEFINES += _SECURE_SCL=0
  }
}

win32-msvc201* {
  # disable tr1 and c++0x features to avoid build errors
#  DEFINES += _HAS_CPP0X=0
#  DEFINES += BOOST_NO_CXX11_HDR_ARRAY BOOST_NO_CXX11_HDR_TYPEINDEX BOOST_NO_CXX11_SMART_PTR
  QMAKE_CFLAGS *= /wd4100
  QMAKE_CXXFLAGS *= /wd4100
  QMAKE_CFLAGS_RELEASE += /GL
  QMAKE_CXXFLAGS_RELEASE += /GL
  QMAKE_LFLAGS_RELEASE += /LTCG
  QMAKE_LIB += /LTCG
}

# unix also works for Android
unix|win32-g++ {
  QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-compare -Wno-strict-aliasing -Wno-unused-parameter \
      -Werror=return-type
  *-clang {
    QMAKE_CXXFLAGS_WARN_ON += -Wno-sign-conversion
  }

tizen{
  QMAKE_CFLAGS_RELEASE -= -O2
  QMAKE_CFLAGS_RELEASE += -O1
  QMAKE_CXXFLAGS_RELEASE -= -O2
  QMAKE_CXXFLAGS_RELEASE += -O1
  QMAKE_CFLAGS_RELEASE *= -ffast-math
  QMAKE_CXXFLAGS_RELEASE *= -ffast-math
} else {
  QMAKE_CFLAGS_RELEASE -= -O2
  QMAKE_CFLAGS_RELEASE += -O3
  QMAKE_CXXFLAGS_RELEASE -= -O2
  QMAKE_CXXFLAGS_RELEASE += -O3
  QMAKE_CFLAGS_RELEASE *= -ffast-math
  QMAKE_CXXFLAGS_RELEASE *= -ffast-math
}

}

linux-* {
  QMAKE_CFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_CXXFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_LFLAGS *= -Wl,--gc-sections -Wl,-Bsymbolic-functions
  linux-g++* {
    QMAKE_CFLAGS_RELEASE *= -ffloat-store
    QMAKE_CXXFLAGS_RELEASE *= -ffloat-store
  }
  # debian build requirements
  CONFIG(production) {
    QMAKE_CFLAGS_RELEASE = -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security
    QMAKE_CXXFLAGS_RELEASE = -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security
    QMAKE_LFLAGS *= -Wl,-z,relro
  }

}

android-g++ {
  QMAKE_CFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_CXXFLAGS *= -fdata-sections -ffunction-sections
  QMAKE_LFLAGS *= -Wl,--gc-sections
}

win32-g++ {
  QMAKE_CFLAGS *= -Wextra
  QMAKE_CXXFLAGS *= -Wextra
  QMAKE_LFLAGS *= -s
  QMAKE_LFLAGS_RELEASE *= -O
}

macx-* {
  QMAKE_LFLAGS *= -dead_strip

#  macx-clang {
#    QMAKE_CFLAGS_RELEASE -= -O3
#    QMAKE_CFLAGS_RELEASE += -O4 -flto
#    QMAKE_CXXFLAGS_RELEASE -= -O3
#    QMAKE_CXXFLAGS_RELEASE += -O4 -flto
#    QMAKE_LFLAGS_RELEASE += -O4 -flto
#  }
}

CONFIG(production) {
  DEFINES += OMIM_PRODUCTION
} else {
  # enable debugging information for non-production release builds
  unix|win32-g++ {
    QMAKE_CFLAGS_RELEASE += -g
    QMAKE_CXXFLAGS_RELEASE += -g
  } win32-msvc* {
    QMAKE_LFLAGS += /PDB:$${DESTDIR}/$${TARGET}.pdb /DEBUG
  }
}

# Fix boost compilation error
win32* {
    QMAKE_MOC = $$[QT_INSTALL_BINS]/moc.exe -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED
} else {
    QMAKE_MOC = $$[QT_INSTALL_BINS]/moc -DBOOST_TT_HAS_OPERATOR_HPP_INCLUDED
}


Fix PlatformImpl being included in ios/android

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

HEADERS += \
    $$PWD/src/facebookqml.h \
    $$PWD/src/facebookqmlplatformimpl.h

SOURCES += \
    $$PWD/src/facebookqml.cpp

ios {
    # Ensure that the Facebook SDK has been included
    !exists($$FACEBOOKSDKPATH) {
        error("[FacebookQml] Please set a valid path to the Facebook SDK.")
    }

    # The individual frameworks from the Facebook SDK
    FBQMLFRAMEWORKS = \
        Bolts.framework \
        FBSDKCoreKit.framework \
        FBSDKLoginKit.framework

    # Ensure that every framework file exists
    for(framework, FBQMLFRAMEWORKS) {
        !exists($$FACEBOOKSDKPATH/$$framework) {
            error("[FacebookQml] $$framework was not found in the Facebook SDK directory.")
        }
    }

    # Include the Facebook SDK
    QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ -F$$FACEBOOKSDKPATH
    QMAKE_LFLAGS += -stdlib=libc++ -F$$FACEBOOKSDKPATH

    for(framework, FBQMLFRAMEWORKS) {
        LIBS += -lz -framework $$replace(framework, ".framework", "")
    }

    OBJECTIVE_HEADERS += \
        $$PWD/src/ios/facebookqmliosutils.h

    OBJECTIVE_SOURCES += \
        $$PWD/src/ios/facebookqmlplatformimpl.mm
}

android {
    QT += androidextras

    HEADERS += \
        $$PWD/src/android/facebookqmlandroidutils.h

    SOURCES += \
        $$PWD/src/android/facebookqmlplatformimpl.cpp

    # This dirty hack ensures that our .java files end up in the source android build directory
    !isEmpty(ANDROID_PACKAGE_SOURCE_DIR) {
        copydata.commands += $(COPY_DIR) $$shell_path($$PWD/src/android/bundle/*) $$shell_path($$ANDROID_PACKAGE_SOURCE_DIR/src)
        first.depends = $(first) copydata
        export(first.depends)
        export(copydata.commands)
        android:QMAKE_EXTRA_TARGETS += first copydata
    }
}

!ios:!android {
    SOURCES += \
        $$PWD/src/generic/facebookqmlplatformimpl.cpp
}

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

HEADERS += \
    $$PWD/src/facebookqml.h \
    $$PWD/src/facebookqmlplatformimpl.h

SOURCES += \
    $$PWD/src/facebookqml.cpp

ios {
    # Ensure that the Facebook SDK has been included
    !exists($$FACEBOOKSDKPATH) {
        error("[FacebookQml] Please set a valid path to the Facebook SDK.")
    }

    # The individual frameworks from the Facebook SDK
    FBQMLFRAMEWORKS = \
        Bolts.framework \
        FBSDKCoreKit.framework \
        FBSDKLoginKit.framework

    # Ensure that every framework file exists
    for(framework, FBQMLFRAMEWORKS) {
        !exists($$FACEBOOKSDKPATH/$$framework) {
            error("[FacebookQml] $$framework was not found in the Facebook SDK directory.")
        }
    }

    # Include the Facebook SDK
    QMAKE_CXXFLAGS += -std=c++11 -stdlib=libc++ -F$$FACEBOOKSDKPATH
    QMAKE_LFLAGS += -stdlib=libc++ -F$$FACEBOOKSDKPATH

    for(framework, FBQMLFRAMEWORKS) {
        LIBS += -lz -framework $$replace(framework, ".framework", "")
    }

    OBJECTIVE_HEADERS += \
        $$PWD/src/ios/facebookqmliosutils.h

    OBJECTIVE_SOURCES += \
        $$PWD/src/ios/facebookqmlplatformimpl.mm
}

android {
    QT += androidextras

    HEADERS += \
        $$PWD/src/android/facebookqmlandroidutils.h

    SOURCES += \
        $$PWD/src/android/facebookqmlplatformimpl.cpp

    # This dirty hack ensures that our .java files end up in the source android build directory
    !isEmpty(ANDROID_PACKAGE_SOURCE_DIR) {
        copydata.commands += $(COPY_DIR) $$shell_path($$PWD/src/android/bundle/*) $$shell_path($$ANDROID_PACKAGE_SOURCE_DIR/src)
        first.depends = $(first) copydata
        export(first.depends)
        export(copydata.commands)
        android:QMAKE_EXTRA_TARGETS += first copydata
    }
}

!ios|!android {
    SOURCES += \
        $$PWD/src/generic/facebookqmlplatformimpl.cpp
}


Changes: Make default plugin configurable

Details: Use meego-keyboard-quick as default plugin for nomeegootuch
case for now.

Full, original commit at 6de998183fcbf9a1915e4a44045fd6fc6fee9eb7 in maliit-framework

# Linker optimization for release build
QMAKE_LFLAGS_RELEASE+=-Wl,--as-needed
# Compiler warnings are error if the build type is debug
QMAKE_CXXFLAGS_DEBUG+=-Werror

isEmpty(M_IM_VERSION) {
    M_IM_VERSION=$$system(sed -e \'/^meego-im-framework/!d\'  -e \'s/^meego-im-framework (\\([^-~]*\\)[-~].*).*$/\\1/\' $$PWD/debian/changelog | head -1)
}

isEmpty(M_IM_PREFIX) {
    M_IM_PREFIX = /usr
}
isEmpty(M_IM_INSTALL_BIN) {
    M_IM_INSTALL_BIN = $$M_IM_PREFIX/bin
}
isEmpty(M_IM_INSTALL_LIBS) {
    M_IM_INSTALL_LIBS = $$M_IM_PREFIX/lib
}
isEmpty(M_IM_INSTALL_HEADERS) {
    M_IM_INSTALL_HEADERS = $$M_IM_PREFIX/include
}
isEmpty(M_IM_INSTALL_SCHEMAS) {
    M_IM_INSTALL_SCHEMAS = /usr/share/gconf/schemas
}

M_IM_PLUGINS_DIR = $$M_IM_INSTALL_LIBS/meego-im-plugins

DEFINES += M_IM_PLUGINS_DIR=\\\"$$M_IM_PLUGINS_DIR\\\"

isEmpty(M_IM_ENABLE_MULTITOUCH) {
    M_IM_ENABLE_MULTITOUCH=true
}

!nomeegotouch {
    M_IM_DEFAULT_PLUGIN = libmeego-keyboard.so
    M_IM_DEFAULT_SUBVIEW = en_gb.xml
} else {
    M_IM_DEFAULT_PLUGIN = libmeego-keyboard-quick.so
    M_IM_DEFAULT_SUBVIEW =
}

mac {
    # Do mac stuff here
    M_BUILD_FEATURES = debug
    M_PROFILE_PARTS =
    INCLUDEPATH += include/
}

# Linker optimization for release build
QMAKE_LFLAGS_RELEASE+=-Wl,--as-needed
# Compiler warnings are error if the build type is debug
QMAKE_CXXFLAGS_DEBUG+=-Werror

isEmpty(M_IM_VERSION) {
    M_IM_VERSION=$$system(sed -e \'/^meego-im-framework/!d\'  -e \'s/^meego-im-framework (\\([^-~]*\\)[-~].*).*$/\\1/\' $$PWD/debian/changelog | head -1)
}

isEmpty(M_IM_PREFIX) {
    M_IM_PREFIX = /usr
}
isEmpty(M_IM_INSTALL_BIN) {
    M_IM_INSTALL_BIN = $$M_IM_PREFIX/bin
}
isEmpty(M_IM_INSTALL_LIBS) {
    M_IM_INSTALL_LIBS = $$M_IM_PREFIX/lib
}
isEmpty(M_IM_INSTALL_HEADERS) {
    M_IM_INSTALL_HEADERS = $$M_IM_PREFIX/include
}
isEmpty(M_IM_INSTALL_SCHEMAS) {
    M_IM_INSTALL_SCHEMAS = /usr/share/gconf/schemas
}

M_IM_PLUGINS_DIR = $$M_IM_INSTALL_LIBS/meego-im-plugins

DEFINES += M_IM_PLUGINS_DIR=\\\"$$M_IM_PLUGINS_DIR\\\"

isEmpty(M_IM_ENABLE_MULTITOUCH) {
    M_IM_ENABLE_MULTITOUCH=true
}

mac {
    # Do mac stuff here
    M_BUILD_FEATURES = debug
    M_PROFILE_PARTS =
    INCLUDEPATH += include/
}


fixed android icons deploy

fixed android icons deploy

isEmpty(FK_IOS_PLIST){
    warning("FK_IOS_PLIST path is not set")
}

isEmpty(FK_MOBILE_ICONS){
    warning("FK_MOBILE_ICONS path is not set")
}

isEmpty(FK_MOBILE_SPLASH_SCREENS){
    ios{
        FK_MOBILE_SPLASH_SCREENS = $$PWD/ios_splashScreen
    }
    android{
        FK_MOBILE_SPLASH_SCREENS = $$PWD/android_splashScreen
    }
    warning("FK_MOBILE_SPLASH_SCREENS path is not set, default splash screens used")
}

ios{
    QMAKE_INFO_PLIST = $$FK_IOS_PLIST

    QMAKE_IOS_DEPLOYMENT_TARGET = 7.0

    ios_icon.files = $$files($$FK_MOBILE_ICONS/AppIcon*.png) $$files($$FK_MOBILE_ICONS/iTunesArtwork*)
    QMAKE_BUNDLE_DATA += ios_icon

    app_launch_images.files = $$files($$FK_MOBILE_SPLASH_SCREENS/LaunchImage*.png)
    QMAKE_BUNDLE_DATA += app_launch_images
}

android{
    android_icon.files = $$FK_MOBILE_ICONS/mipmap*
    android_icon.path = /res
    android_icon.extra += $(COPY_DIR) $$system_path($$FK_MOBILE_ICONS) $$system_path($$ANDROID_PACKAGE_SOURCE_DIR/res)
    INSTALLS += android_icon

    app_launch_images.files = $$FK_MOBILE_SPLASH_SCREENS/drawable*
    app_launch_images.path = /res
    app_launch_images.extra = $(COPY_DIR) $$system_path($$FK_MOBILE_SPLASH_SCREENS) $$system_path($$ANDROID_PACKAGE_SOURCE_DIR/res)
    INSTALLS += app_launch_images
}

isEmpty(FK_IOS_PLIST){
    warning("FK_IOS_PLIST path is not set")
}

isEmpty(FK_MOBILE_ICONS){
    warning("FK_MOBILE_ICONS path is not set")
}

isEmpty(FK_MOBILE_SPLASH_SCREENS){
    ios{
        FK_MOBILE_SPLASH_SCREENS = $$PWD/ios_splashScreen
    }
    android{
        FK_MOBILE_SPLASH_SCREENS = $$PWD/android_splashScreen
    }
    warning("FK_MOBILE_SPLASH_SCREENS path is not set, default splash screens used")
}

ios{
    QMAKE_INFO_PLIST = $$FK_IOS_PLIST

    QMAKE_IOS_DEPLOYMENT_TARGET = 7.0

    ios_icon.files = $$files($$FK_MOBILE_ICONS/AppIcon*.png) $$files($$FK_MOBILE_ICONS/iTunesArtwork*)
    QMAKE_BUNDLE_DATA += ios_icon

    app_launch_images.files = $$files($$FK_MOBILE_SPLASH_SCREENS/LaunchImage*.png)
    QMAKE_BUNDLE_DATA += app_launch_images
}

android{
    android_icon.files = $$FK_MOBILE_ICONS/mipmap*
    android_icon.path = $$ANDROID_PACKAGE_SOURCE_DIR/res
    INSTALLS += android_icon

    app_launch_images.files = $$FK_MOBILE_SPLASH_SCREENS/drawable*
    app_launch_images.path = $$ANDROID_PACKAGE_SOURCE_DIR/res
    INSTALLS += app_launch_images
}


TravisCI: Attempt to fix OSX builds

TravisCI: Attempt to fix OSX builds

# Copyright 2014 - 2016 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

COMPILER = $$(CXX)

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

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

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:!CONFIG(debug):CONFIG *= release
CONFIG(release):CONFIG -= debug
CONFIG(no-sanitizers): CONFIG *= nosanitizers
CONFIG = $$unique(CONFIG)

CONFIG(debug) {
	isEmpty(CONFIGURATION): CONFIGURATION = $$ARCHITECTURE-debug
	unix {
		QMAKE_CXXFLAGS += -coverage
		QMAKE_LFLAGS += -coverage
	}
	CONFIGURATION_SUFFIX=-d
} else {
	isEmpty(CONFIGURATION): CONFIGURATION = $$ARCHITECTURE-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 }

CONFIG += link_pkgconfig
!win32:PKGCONFIG += python-2.7
macx:QT_CONFIG -= no-pkg-config

isEmpty(DESTDIR) {
	DESTDIR = $$PWD/bin/$$CONFIGURATION
}

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) {
	unix:!macx {
		QMAKE_LFLAGS += -Wl,-rpath-link,$$DESTDIR
		!CONFIG(no_rpath) QMAKE_LFLAGS += -Wl,-O1,-rpath,\'\$$ORIGIN\'
	}
	macx:!CONFIG(no_rpath) {
		QMAKE_LFLAGS += -rpath . -rpath @executable_path/../Lib -rpath @executable_path/../Frameworks -rpath @executable_path/../../../
	}
}

#Workaround for a known gcc/ld (before 7.3/bionic) issue
CONFIG(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/
}

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

!CONFIG(nosanitizers) {
	CONFIG += sanitizer
}

unix:!CONFIG(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 }

	CONFIG(sanitize_leak) {
		QMAKE_CFLAGS += -fsanitize=leak
		QMAKE_CXXFLAGS += -fsanitize=leak
		QMAKE_LFLAGS += -fsanitize=leak
	}

	CONFIG(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:gcc:*-g++*: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){
		CONFIG(gcc4) {
			message("Too old compiler: $$QMAKE_CXX")
		} else {
			QMAKE_CFLAGS += -fsanitize-recover=all
			QMAKE_CXXFLAGS += -fsanitize-recover=all
		}
	}

}

#CONFIG(ltcg):win32:QMAKE_LFLAGS += -fno-use-linker-plugin

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

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

INCLUDEPATH += \
	$$PWD/qslog \

LIBS += -L$$DESTDIR

IS_QSLOG = $$find(PROJECT_NAME, [qQ]s[lL]og)

isEmpty(IS_QSLOG) {
	LIBS += -lqslog$$CONFIGURATION_SUFFIX
}

CONFIG += c++11

QMAKE_CXXFLAGS += -pedantic-errors -ansi -Wextra

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

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

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

GLOBAL_PWD = $$PWD

# Useful function to copy additional files to destination,
# from http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output
defineTest(isDir) {
	exists($$system_path($$1/*)):return(true)
	return(false)
}

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 "
		} else {
		 	COPY_DIR = "rsync -avz "
		}
		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(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$$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 -= precompiled_header
	PRECOMPILED_HEADER =
	export(CONFIG)
	export(PRECOMPILED_HEADER)
}

#seems obsolete, atleast for qmake-qt5
unix:equals(ARCHITECTURE, "x86"):!CONFIG(nosanitizers) {
	CONFIG(debug) {
		QMAKE_CXXFLAGS += -fno-omit-frame-pointer
		CONFIG(sanitize_address) {
			QMAKE_CXXFLAGS += -fsanitize=address
			QMAKE_LFLAGS += -fsanitize=address
		}
		CONFIG(sanitize_undefined) {
			# UBSan does not play well with precompiled headers for some reason.
			noPch()
			QMAKE_CXXFLAGS += -fsanitize=undefined
			QMAKE_LFLAGS += -fsanitize=undefined
		}
		CONFIG(sanitize_thread) {
			QMAKE_CXXFLAGS += -fsanitize=thread
			QMAKE_LFLAGS += -fsanitize=thread
			LIBS += -ltsan
		}
	}
}

CONFIG(noPch) {
	noPch()
}

# Copyright 2014 - 2016 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

COMPILER = $$(CXX)

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

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

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:!CONFIG(debug):CONFIG *= release
CONFIG(release):CONFIG -= debug
CONFIG(no-sanitizers): CONFIG *= nosanitizers
CONFIG = $$unique(CONFIG)

CONFIG(debug) {
	isEmpty(CONFIGURATION): CONFIGURATION = $$ARCHITECTURE-debug
	unix {
		QMAKE_CXXFLAGS += -coverage
		QMAKE_LFLAGS += -coverage
	}
	CONFIGURATION_SUFFIX=-d
} else {
	isEmpty(CONFIGURATION): CONFIGURATION = $$ARCHITECTURE-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 }

#CONFIG += link_pkgconfig
#!win32:PKGCONFIG += python-2.7
#macx:QT_CONFIG -= no-pkg-config

isEmpty(DESTDIR) {
	DESTDIR = $$PWD/bin/$$CONFIGURATION
}

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) {
	unix:!macx {
		QMAKE_LFLAGS += -Wl,-rpath-link,$$DESTDIR
		!CONFIG(no_rpath) QMAKE_LFLAGS += -Wl,-O1,-rpath,\'\$$ORIGIN\'
	}
	macx:!CONFIG(no_rpath) {
		QMAKE_LFLAGS += -rpath . -rpath @executable_path/../Lib -rpath @executable_path/../Frameworks -rpath @executable_path/../../../
	}
}

#Workaround for a known gcc/ld (before 7.3/bionic) issue
CONFIG(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/
}

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

!CONFIG(nosanitizers) {
	CONFIG += sanitizer
}

unix:!CONFIG(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 }

	CONFIG(sanitize_leak) {
		QMAKE_CFLAGS += -fsanitize=leak
		QMAKE_CXXFLAGS += -fsanitize=leak
		QMAKE_LFLAGS += -fsanitize=leak
	}

	CONFIG(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:gcc:*-g++*: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){
		CONFIG(gcc4) {
			message("Too old compiler: $$QMAKE_CXX")
		} else {
			QMAKE_CFLAGS += -fsanitize-recover=all
			QMAKE_CXXFLAGS += -fsanitize-recover=all
		}
	}

}

#CONFIG(ltcg):win32:QMAKE_LFLAGS += -fno-use-linker-plugin

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

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

INCLUDEPATH += \
	$$PWD/qslog \

LIBS += -L$$DESTDIR

IS_QSLOG = $$find(PROJECT_NAME, [qQ]s[lL]og)

isEmpty(IS_QSLOG) {
	LIBS += -lqslog$$CONFIGURATION_SUFFIX
}

CONFIG += c++11

QMAKE_CXXFLAGS += -pedantic-errors -ansi -Wextra

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

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

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

GLOBAL_PWD = $$PWD

# Useful function to copy additional files to destination,
# from http://stackoverflow.com/questions/3984104/qmake-how-to-copy-a-file-to-the-output
defineTest(isDir) {
	exists($$system_path($$1/*)):return(true)
	return(false)
}

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 "
		} else {
		 	COPY_DIR = "rsync -avz "
		}
		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(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$$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 -= precompiled_header
	PRECOMPILED_HEADER =
	export(CONFIG)
	export(PRECOMPILED_HEADER)
}

#seems obsolete, atleast for qmake-qt5
unix:equals(ARCHITECTURE, "x86"):!CONFIG(nosanitizers) {
	CONFIG(debug) {
		QMAKE_CXXFLAGS += -fno-omit-frame-pointer
		CONFIG(sanitize_address) {
			QMAKE_CXXFLAGS += -fsanitize=address
			QMAKE_LFLAGS += -fsanitize=address
		}
		CONFIG(sanitize_undefined) {
			# UBSan does not play well with precompiled headers for some reason.
			noPch()
			QMAKE_CXXFLAGS += -fsanitize=undefined
			QMAKE_LFLAGS += -fsanitize=undefined
		}
		CONFIG(sanitize_thread) {
			QMAKE_CXXFLAGS += -fsanitize=thread
			QMAKE_LFLAGS += -fsanitize=thread
			LIBS += -ltsan
		}
	}
}

CONFIG(noPch) {
	noPch()
}