TARGET = CablesDatabaseServer

VERSION_MAJOR = 1
VERSION_MINOR = 1
VERSION_BUILD = 2

VERSION = $${VERSION_MAJOR}.$${VERSION_MINOR}.$${VERSION_BUILD}
DEFINES += APP_VERSION=\\\"$$VERSION\\\"

QT += core
QT += network
QT += sql

CONFIG += c++17
CONFIG += console

!versionAtLeast(QT_VERSION, 5.15) {
  DEFINES += OLD_QT_VERSION
}

versionAtLeast(QT_VERSION, 6.0) {
  DEFINES += QT_VERSION_6_OR_HIGHER
  QT += core5compat
}

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    $$PWD/src/Http/ParsingQuery.cpp \
    $$PWD/src/Http/PrepareAnswer.cpp \
    $$PWD/src/Http/SimpleServer.cpp \
    $$PWD/src/Sql/DBHelper.cpp \
    $$PWD/lib/tinyxml2-9.0.0/tinyxml2.cpp \
    $$PWD/src/main.cpp \

HEADERS += \
    $$PWD/include/Http/ParsingQuery.h \
    $$PWD/include/Http/PrepareAnswer.h \
    $$PWD/include/Http/SimpleServer.h \
    $$PWD/include/Sql/DBHelper.h \
    $$PWD/lib/CppCommon/Common/Basic/FileProxy.h \
    $$PWD/lib/tinyxml2-9.0.0/tinyxml2.h

INCLUDEPATH += include
INCLUDEPATH += $$PWD/lib/tinyxml2-9.0.0

PROJECT_DIR_PATH = $$PWD

CONFIG(debug, debug|release) {
  DESTDIR_PATH = $$PWD/../build-$${TARGET}-debug
}
CONFIG(release, debug|release) {
  DESTDIR_PATH = $$PWD/../build-$${TARGET}-release
}

RC_FILE = app.rc

DESTDIR = $${DESTDIR_PATH}
OBJECTS_DIR = $${DESTDIR_PATH}/.obj
MOC_DIR = $${DESTDIR_PATH}/.moc
RCC_DIR = $${DESTDIR_PATH}/.rcc
UI_DIR = $${DESTDIR_PATH}/.ui

win32 {
  DESTDIR_PATH ~= s,/,\\,g
  PROJECT_DIR_PATH ~= s,/,\\,g
}

!equals(PROJECT_DIR_PATH, $${DESTDIR_PATH}) {
  linux-g++{
    QMAKE_POST_LINK +=$$quote(cp $${PROJECT_DIR_PATH}/resources/CablesSQLite.db $${DESTDIR_PATH}/CablesSQLite.db $$escape_expand(\n\t))
    QMAKE_POST_LINK +=$$quote(cp $${PROJECT_DIR_PATH}/resources/CablesV2.xml $${DESTDIR_PATH}/CablesV2.xml $$escape_expand(\n\t))
    QMAKE_POST_LINK +=$$quote(cp $${PROJECT_DIR_PATH}/DatabaseSettings.json $${DESTDIR_PATH}/DatabaseSettings.json $$escape_expand(\n\t))
  }
  win32 {
    QMAKE_POST_LINK += $$quote(copy /Y $${PROJECT_DIR_PATH}\\resources\\CablesSQLite.db $${DESTDIR_PATH}\\CablesSQLite.db $$escape_expand(\n\t))
    QMAKE_POST_LINK += $$quote(copy /Y $${PROJECT_DIR_PATH}\\resources\\CablesV2.xml $${DESTDIR_PATH}\\CablesV2.xml $$escape_expand(\n\t))
    QMAKE_POST_LINK += $$quote(copy /Y $${PROJECT_DIR_PATH}\\DatabaseSettings.json $${DESTDIR_PATH}\\DatabaseSettings.json $$escape_expand(\n\t))
  }
}

# Deployment - Automatically Detect and Copy Dependencies to Build Folder
win32 {
  TARGET_CUSTOM_EXT = .exe
  DEPLOY_COMMAND = $$[QT_INSTALL_BINS]/windeployqt
  DEPLOY_OPTIONS = "--no-svg --no-system-d3d-compiler --no-opengl --no-opengl-sw"
  DEPLOY_TARGET = $$shell_quote($$shell_path($${DESTDIR_PATH}/$${TARGET}$${TARGET_CUSTOM_EXT}))
  CONFIG(debug, debug|release) {
    # debug
    DEPLOY_OPTIONS += "--debug"
  } else {
    # release
    DEPLOY_OPTIONS += "--release"
  }
  # Uncomment the following line to help debug the deploy command when running qmake
  #message($${DEPLOY_COMMAND} $${DEPLOY_OPTIONS} $${DEPLOY_TARGET})

  QMAKE_POST_LINK += $${DEPLOY_COMMAND} $${DEPLOY_OPTIONS} $${DEPLOY_TARGET}
}

INCLUDEPATH += $$PWD/include/Sql
INCLUDEPATH += $$PWD/include/Http
INCLUDEPATH += $$PWD/lib
INCLUDEPATH += $$PWD/lib/CppCommon/Common/Basic

DISTFILES += \
  DatabaseSettings.json
