Skip to content

Commit

Permalink
make qhttp::client optional by adding a qmake variable
Browse files Browse the repository at this point in the history
  • Loading branch information
azadkuh committed Jun 28, 2016
1 parent 6079c50 commit 3271cea
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 39 deletions.
21 changes: 11 additions & 10 deletions commondir.pri
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
# specifying common dirs

DEFINES *= QHTTP_HAS_CLIENT
# Qt5.5.1 on OSX needs both c++11 and c++14!! the c++14 is not enough
CONFIG += c++11 c++14

unix {
TEMPDIR = $$PRJDIR/tmp/unix/$$TARGET
macx:TEMPDIR = $$PRJDIR/tmp/osx/$$TARGET
QMAKE_CFLAGS += -std=gnu99
QMAKE_CXXFLAGS += -std=c++11
}

win32 {
warning("Windows port of this library has not been tested nor profiled.")
TEMPDIR = $$PRJDIR/tmp/win32/$$TARGET
CONFIG += c++11
DEFINES += _WINDOWS WIN32_LEAN_AND_MEAN NOMINMAX
}


DESTDIR = $$PRJDIR/xbin
MOC_DIR = $$TEMPDIR
OBJECTS_DIR = $$TEMPDIR
RCC_DIR = $$TEMPDIR
UI_DIR = $$TEMPDIR/Ui
LIBS += -L$$PRJDIR/xbin
DESTDIR = $$PRJDIR/xbin
MOC_DIR = $$TEMPDIR
OBJECTS_DIR = $$TEMPDIR
RCC_DIR = $$TEMPDIR
UI_DIR = $$TEMPDIR/Ui
LIBS += -L$$PRJDIR/xbin

INCLUDEPATH += . $$PRJDIR/src $$PRJDIR/3rdparty
INCLUDEPATH += . $$PRJDIR/src $$PRJDIR/3rdparty

12 changes: 6 additions & 6 deletions example/example.pro
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
TEMPLATE = subdirs

SUBDIRS += helloworld
SUBDIRS += basic-server
SUBDIRS += benchmark
SUBDIRS += nodejs

unix:SUBDIRS += keep-alive
# SUBDIRS += helloworld
# SUBDIRS += basic-server
# SUBDIRS += benchmark
# SUBDIRS += nodejs
#
# unix:SUBDIRS += keep-alive


4 changes: 4 additions & 0 deletions src/qhttpclient.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef QHTTPCLIENT_HPP
#define QHTTPCLIENT_HPP

// configured by src.pro
#if defined(QHTTP_HAS_CLIENT)

///////////////////////////////////////////////////////////////////////////////
#include "qhttpfwd.hpp"

Expand Down Expand Up @@ -175,4 +178,5 @@ class QHTTP_API QHttpClient : public QObject
} // namespace client
} // namespace qhttp
///////////////////////////////////////////////////////////////////////////////
#endif // QHTTP_HAS_CLIENT
#endif // define QHTTPCLIENT_HPP
4 changes: 4 additions & 0 deletions src/qhttpclientrequest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#ifndef QHTTPCLIENT_REQUEST_HPP
#define QHTTPCLIENT_REQUEST_HPP

// configured by src.pro
#if defined(QHTTP_HAS_CLIENT)

///////////////////////////////////////////////////////////////////////////////
#include "qhttpabstracts.hpp"
#include <QUrl>
Expand Down Expand Up @@ -60,4 +63,5 @@ class QHTTP_API QHttpRequest : public QHttpAbstractOutput
} // namespace client
} // namespace qhttp
///////////////////////////////////////////////////////////////////////////////
#endif // QHTTP_HAS_CLIENT
#endif // define QHTTPCLIENT_REQUEST_HPP
5 changes: 5 additions & 0 deletions src/qhttpclientresponse.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@

#ifndef QHTTPCLIENT_RESPONSE_HPP
#define QHTTPCLIENT_RESPONSE_HPP

// configured by src.pro
#if defined(QHTTP_HAS_CLIENT)

///////////////////////////////////////////////////////////////////////////////

#include "qhttpabstracts.hpp"
Expand Down Expand Up @@ -70,4 +74,5 @@ class QHTTP_API QHttpResponse : public QHttpAbstractInput
} // namespace client
} // namespace qhttp
///////////////////////////////////////////////////////////////////////////////
#endif // QHTTP_HAS_CLIENT
#endif // define QHTTPCLIENT_RESPONSE_HPP
42 changes: 19 additions & 23 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,40 @@ QT -= gui

TARGET = qhttp
TEMPLATE = lib
CONFIG += c++14

PRJDIR = ..
include($$PRJDIR/commondir.pri)

DEFINES += QHTTP_MEMORY_LOG=0
win32:DEFINES += QHTTP_EXPORT
DEFINES *= QHTTP_MEMORY_LOG=0
win32:DEFINES *= QHTTP_EXPORT

# Joyent http_parser
SOURCES += $$PRJDIR/3rdparty/http-parser/http_parser.c
HEADERS += $$PRJDIR/3rdparty/http-parser/http_parser.h

SOURCES += \
qhttpabstracts.cpp \
qhttpserverconnection.cpp \
qhttpserverrequest.cpp \
qhttpserverresponse.cpp \
qhttpserver.cpp \
qhttpclientrequest.cpp \
qhttpclientresponse.cpp \
qhttpclient.cpp
qhttpserver.cpp

HEADERS += \
qhttpfwd.hpp \
qhttpabstracts.hpp \
qhttpserverconnection.hpp \
qhttpserverrequest.hpp \
qhttpserverresponse.hpp \
qhttpserver.hpp \
qhttpclient.hpp \
qhttpclientresponse.hpp \
qhttpclientrequest.hpp \
private/qhttpbase.hpp \
private/qhttpserverconnection_private.hpp \
private/qhttpserverrequest_private.hpp \
private/qhttpserverresponse_private.hpp \
private/qhttpserver_private.hpp \
private/qhttpclientrequest_private.hpp \
private/qhttpclientresponse_private.hpp \
private/qhttpclient_private.hpp

SOURCES += $$PRJDIR/3rdparty/http-parser/http_parser.c
HEADERS += $$PRJDIR/3rdparty/http-parser/http_parser.h

qhttpserver.hpp

contains(DEFINES, QHTTP_HAS_CLIENT) {
SOURCES += \
qhttpclientrequest.cpp \
qhttpclientresponse.cpp \
qhttpclient.cpp

HEADERS += \
qhttpclient.hpp \
qhttpclientresponse.hpp \
qhttpclientrequest.hpp
}

0 comments on commit 3271cea

Please sign in to comment.