Add cmake support for Qt6/dev branch

Change-Id: Icca0edab01d6028d786b76f99fba388565bd6e76
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Mikhail Svetkin 2020-04-09 11:18:07 +02:00
parent 6d0a9b6f83
commit 4b2790aa6d
19 changed files with 236 additions and 8 deletions

15
CMakeLists.txt Normal file
View File

@ -0,0 +1,15 @@
# Generated from qthttpserver.pro.
cmake_minimum_required(VERSION 3.15.0)
project(QtHttpServer
VERSION 6.0.0
DESCRIPTION "Qt HTTP Server"
HOMEPAGE_URL "https://qt.io/"
LANGUAGES CXX C
)
find_package(Qt6 ${PROJECT_VERSION} CONFIG REQUIRED COMPONENTS BuildInternals Core Network)
find_package(Qt6 ${PROJECT_VERSION} CONFIG OPTIONAL_COMPONENTS Concurrent)
qt_build_repo()

7
examples/CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
# Generated from examples.pro.
qt_examples_build_begin()
add_subdirectory(httpserver)
qt_examples_build_end()

View File

@ -0,0 +1,3 @@
# Generated from httpserver.pro.
add_subdirectory(simple)

View File

@ -0,0 +1,40 @@
# Generated from simple.pro.
cmake_minimum_required(VERSION 3.14)
project(simple LANGUAGES CXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
set(INSTALL_EXAMPLEDIR "examples/httpserver/simple")
find_package(Qt6 COMPONENTS HttpServer)
add_executable(simple
main.cpp
)
target_link_libraries(simple PUBLIC
Qt::HttpServer
)
# Resources:
set(assets_resource_files
"assets/qt-logo.png"
)
qt6_add_resources(simple "assets"
PREFIX
"/"
FILES
${assets_resource_files}
)
install(TARGETS simple
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)

6
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,6 @@
# Generated from src.pro.
if(QT_FEATURE_ssl)
add_subdirectory(sslserver)
endif()
add_subdirectory(httpserver)

View File

@ -0,0 +1,54 @@
# Generated from httpserver.pro.
#####################################################################
## HttpServer Module:
#####################################################################
qt_add_module(HttpServer
SOURCES
../3rdparty/http-parser/http_parser.c ../3rdparty/http-parser/http_parser.h
qabstracthttpserver.cpp qabstracthttpserver.h qabstracthttpserver_p.h
qhttpserver.cpp qhttpserver.h qhttpserver_p.h
qhttpserverliterals.cpp qhttpserverliterals_p.h
qhttpserverrequest.cpp qhttpserverrequest.h qhttpserverrequest_p.h
qhttpserverresponder.cpp qhttpserverresponder.h qhttpserverresponder_p.h
qhttpserverresponse.cpp qhttpserverresponse.h qhttpserverresponse_p.h
qhttpserverrouter.cpp qhttpserverrouter.h qhttpserverrouter_p.h
qhttpserverrouterrule.cpp qhttpserverrouterrule.h qhttpserverrouterrule_p.h
qhttpserverrouterviewtraits.h
qthttpserverglobal.h
INCLUDE_DIRECTORIES
.
../3rdparty/http-parser
LIBRARIES
Qt::CorePrivate
PUBLIC_LIBRARIES
Qt::Core
Qt::Network
PRIVATE_MODULE_INTERFACE
Qt::CorePrivate
)
## Scopes:
#####################################################################
qt_extend_target(HttpServer CONDITION TARGET Qt::WebSockets
LIBRARIES
Qt::WebSocketsPrivate
PUBLIC_LIBRARIES
Qt::WebSockets
PRIVATE_MODULE_INTERFACE
Qt::WebSocketsPrivate
)
qt_extend_target(HttpServer CONDITION QT_FEATURE_ssl
PUBLIC_LIBRARIES
Qt::SslServer
)
qt_extend_target(HttpServer CONDITION TARGET Qt::Concurrent
SOURCES
qhttpserverfutureresponse.cpp qhttpserverfutureresponse.h
PUBLIC_LIBRARIES
Qt::Concurrent
)

View File

@ -0,0 +1,16 @@
# Generated from sslserver.pro.
#####################################################################
## SslServer Module:
#####################################################################
qt_add_module(SslServer
SOURCES
qsslserver.cpp qsslserver.h qsslserver_p.h
qtsslserverglobal.h
INCLUDE_DIRECTORIES
.
PUBLIC_LIBRARIES
Qt::Core
Qt::Network
)

7
tests/CMakeLists.txt Normal file
View File

@ -0,0 +1,7 @@
# Generated from tests.pro.
if(QT_BUILD_STANDALONE_TESTS)
# Add qt_find_package calls for extra dependencies that need to be found when building
# the standalone tests here.
endif()
qt_build_tests()

View File

@ -0,0 +1,7 @@
# Generated from auto.pro.
add_subdirectory(qabstracthttpserver)
add_subdirectory(qhttpserver)
add_subdirectory(qhttpserverresponder)
add_subdirectory(qhttpserverrouter)
add_subdirectory(qhttpserverresponse)

View File

@ -0,0 +1,12 @@
# Generated from qabstracthttpserver.pro.
#####################################################################
## tst_qabstracthttpserver Test:
#####################################################################
qt_add_test(tst_qabstracthttpserver
SOURCES
tst_qabstracthttpserver.cpp
PUBLIC_LIBRARIES
Qt::HttpServer
)

View File

@ -3,5 +3,3 @@ TARGET = tst_qabstracthttpserver
SOURCES += tst_qabstracthttpserver.cpp
QT = httpserver testlib
qtHaveModule(websockets): QT += websockets

View File

@ -30,7 +30,7 @@
#include <QtHttpServer/qabstracthttpserver.h>
#if defined(QT_WEBSOCKETS_LIB)
#include <QtWebSockets/qwebsocket.h>
# include <QtWebSockets/qwebsocket.h>
#endif
#include <QtTest/qsignalspy.h>
@ -45,8 +45,8 @@
#include <QtHttpServer/qhttpserverrequest.h>
#if defined(Q_OS_UNIX)
# include <signal.h>
# include <unistd.h>
# include <signal.h>
# include <unistd.h>
#endif
QT_BEGIN_NAMESPACE

View File

@ -0,0 +1,17 @@
# Generated from qhttpserver.pro.
#####################################################################
## tst_qhttpserver Test:
#####################################################################
# Collect test data
list(APPEND test_data "data/")
qt_add_test(tst_qhttpserver
SOURCES
tst_qhttpserver.cpp
PUBLIC_LIBRARIES
Qt::HttpServer
Qt::HttpServerPrivate
TESTDATA ${test_data}
)

View File

@ -0,0 +1,17 @@
# Generated from qhttpserverresponder.pro.
#####################################################################
## tst_qhttpserverresponder Test:
#####################################################################
# Collect test data
list(APPEND test_data "data/")
qt_add_test(tst_qhttpserverresponder
SOURCES
tst_qhttpserverresponder.cpp
PUBLIC_LIBRARIES
Qt::HttpServer
Qt::HttpServerPrivate
TESTDATA ${test_data}
)

View File

@ -4,4 +4,4 @@ SOURCES += tst_qhttpserverresponder.cpp
QT = httpserver httpserver-private testlib
TESTDATA += *.html
TESTDATA += data/

View File

@ -189,7 +189,7 @@ void tst_QHttpServerResponder::writeFile_data()
QTest::addColumn<QString>("data");
QTest::addRow("index.html")
<< qobject_cast<QIODevice *>(new QFile(QFINDTESTDATA("index.html"), this))
<< qobject_cast<QIODevice *>(new QFile(QFINDTESTDATA("data/index.html"), this))
<< 200
<< "text/html"
<< "<html></html>";
@ -231,7 +231,7 @@ void tst_QHttpServerResponder::writeFile()
void tst_QHttpServerResponder::writeFileExtraHeader()
{
auto file = new QFile(QFINDTESTDATA("index.html"), this);
auto file = new QFile(QFINDTESTDATA("data/index.html"), this);
QSignalSpy spyDestroyIoDevice(file, &QObject::destroyed);
HttpServer server([=](QHttpServerResponder responder) {

View File

@ -0,0 +1,17 @@
# Generated from qhttpserverresponse.pro.
#####################################################################
## tst_qhttpserverresponse Test:
#####################################################################
# Collect test data
list(APPEND test_data "data/")
qt_add_test(tst_qhttpserverresponse
SOURCES
tst_qhttpserverresponse.cpp
PUBLIC_LIBRARIES
Qt::HttpServer
Qt::HttpServerPrivate
TESTDATA ${test_data}
)

View File

@ -0,0 +1,12 @@
# Generated from qhttpserverrouter.pro.
#####################################################################
## tst_qhttpserverrouter Test:
#####################################################################
qt_add_test(tst_qhttpserverrouter
SOURCES
tst_qhttpserverrouter.cpp
PUBLIC_LIBRARIES
Qt::HttpServer
)