project {
  expand(QT5_INCDIR) {
    $QT5_INCDIR
    $(QTDIR)/include
  }
  expand(QT5_BINDIR) {
    $QT5_BINDIR
    $(QTDIR)/bin
  }
  expand(QT5_LIBDIR) {
    $QT5_LIBDIR
    $(QTDIR)/lib
  }
  // On some linux systems with both Qt4 and Qt5 installed, the uic and moc
  // executables for Qt5 need to be run as "uic-qt5"
  // Expand the variable here to avoid the "undefined" warning from msvc.
  expand(QT5_SUFFIX) {
    $QT5_SUFFIX
    ""
  }

  requires += qt5
  includes += $(QT5_INCDIR)
  libpaths += $(QT5_LIBDIR)

  // Use lit_libs instead of libs for qt5's libraries.
  // When generating -static projects of a type that uses lib_modifier,
  // the lib_modifier will have an "s" in it (s for Release, sd for Debug).
  // However, the libraries produced by the Qt project never have an "s" suffix.
  // When MPC generates -static projects, the Qt being used may or may not be
  // static (it doesn't matter for project generation).
  // Since the Qt projects do use a "d" suffix for Debug whether or not the
  // libs are static, we need to account for that with $(QT5_LIBSUFFIX).
  lit_libs += Qt5Core$(QT5_LIBSUFFIX)

  // On Linux at least, Qt5 by default requires position independent code
  specific (gnuace) {
    compile_flags += $(if $(PIC),$(PIC),-fPIC)
  }

  specific (prop:microsoft) {
    // On Windows it's possible for Qt to include winsock.h through windows.h
    // which will conflict with winsock2.h. This makes windows.h not include
    // winsock.h
    macros += WIN32_LEAN_AND_MEAN
    Debug::QT5_LIBSUFFIX = d
  }

  Define_Custom(UIC) {
    command          = $(QT5_BINDIR)/uic$(QT5_SUFFIX)
    output_option    = -o
    inputext         = .ui
    pre_filename     = ui_
    header_outputext = .h
  }

  Define_Custom(MOC) {
    automatic_in     = 0
    automatic_out    = 0
    command          = $(QT5_BINDIR)/moc$(QT5_SUFFIX)
    output_option    = -o
    pch_postrule     = 1
    inputext         = .h
    pre_extension    = _moc
    source_outputext = .cpp
  }

  Define_Custom(QRC) {
    command          = $(QT5_BINDIR)/rcc$(QT5_SUFFIX)
    output_option    = -o
    commandflags     = -name <%input_noext%>
    pch_postrule     = 1
    inputext         = .qrc
    pre_extension    = _qrc
    source_outputext = .cpp
  }
}
