[gui_option_test.pro]


contains(QT, gui) {

  message (gui)

} else {

  message (no_gui)

}


TARGET = gui_option_test

CONFIG   += console

CONFIG   -= app_bundle


TEMPLATE = app


SOURCES += main.cpp



[main.cpp]

#ifdef QT_GUI_LIB
  #include <QApplication>  
  #include <QMessageBox>
#else
  #include <QCoreApplication>
#endif // QT_GUI_LIB
#include <QDebug>

int main(int argc, char *argv[])
{
  #ifdef QT_GUI_LIB
    QApplication a(argc, argv);
  #else
    QCoreApplication a(argc, argv);
  #endif // QT_GUI_LIB

  qDebug() << "bef messagebox";
#ifdef QT_GUI_LIB
  QMessageBox::information(NULL, "title", "text");
#endif // QT_GUI_LIB
  qDebug() << "aft messagebox";
  
  return 0;
}


[qmake_gui.bat]

call _clear.bat
qmake "QT+=gui"



[qmake_no_gui.bat]

call _clear.bat
qmake "QT-=gui"



[Download]

gui_option_test.zip