Skip to content
This repository has been archived by the owner on Jun 8, 2023. It is now read-only.

CMake split into lib and project files #39

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ jobs:
- name: Build QtWebApp
run: |
if [ "${{ matrix.os }}" == "ubuntu-latest" ] && [ "$CC" == "clang" ]; then export LDFLAGS=-fuse-ld=lld; fi
pushd QtWebApp
mkdir build
pushd build
cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Release ..
make
sudo make install
popd # build
popd # QtWebApp
env:
CC: ${{ matrix.compiler.cc }}
CXX: ${{ matrix.compiler.cxx }}
Expand Down Expand Up @@ -109,7 +107,7 @@ jobs:
if: matrix.arch == 'win32_mingw81'
run: echo "$env:IQTA_TOOLS/mingw810_32/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append

- run: cmake -S QtWebApp -B build-qtwebapp ${{ matrix.generator }} -DCMAKE_BUILD_TYPE=Release
- run: cmake -B build-qtwebapp ${{ matrix.generator }} -DCMAKE_BUILD_TYPE=Release
- run: cmake --build build-qtwebapp
- run: cmake --build build-qtwebapp --target install

Expand Down
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.22)
project(QtWebApp CXX)

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED HINTS $ENV{Qt6_DIR} $ENV{Qt5_DIR})

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format -Werror=return-type")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=format -Werror=return-type")
endif()

if(CMAKE_BUILD_TYPE MATCHES Debug)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fsanitize=undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
endif()
add_definitions("-D_GLIBCXX_DEBUG")
add_definitions("-DQT_SHAREDPOINTER_TRACK_POINTERS")
add_definitions("-DCMAKE_DEBUG")
add_definitions("-DSUPERVERBOSE")
endif()

set(CMAKE_AUTOMOC ON)

add_subdirectory(QtWebApp)
26 changes: 0 additions & 26 deletions QtWebApp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,42 +1,16 @@
cmake_minimum_required(VERSION 3.1)
project(QtWebApp CXX)

set(qtwebapp_MAJOR 1)
set(qtwebapp_MINOR 8)
set(qtwebapp_PATCH 3)
set(qtwebapp_VERSION ${qtwebapp_MAJOR}.${qtwebapp_MINOR}.${qtwebapp_PATCH})

find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED HINTS $ENV{Qt6_DIR} $ENV{Qt5_DIR})
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Core Network REQUIRED)

if (Qt6_FOUND)
find_package(Qt6 COMPONENTS Core5Compat REQUIRED)
endif()

set(CMAKE_AUTOMOC ON)

add_definitions(-DQTWEBAPPLIB_EXPORT)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror=format -Werror=return-type")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=format -Werror=return-type")
endif()

if(CMAKE_BUILD_TYPE MATCHES Debug)
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fsanitize=undefined")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
endif()
add_definitions("-D_GLIBCXX_DEBUG")
add_definitions("-DQT_SHAREDPOINTER_TRACK_POINTERS")
add_definitions("-DCMAKE_DEBUG")
add_definitions("-DSUPERVERBOSE")
endif()
add_definitions("-DCMAKE_QTWEBAPP_SO")

configure_file(qtwebappglobal.h.in qtwebappglobal.h @ONLY)
Expand Down
6 changes: 4 additions & 2 deletions QtWebApp/httpserver/httprequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,9 +369,11 @@ void HttpRequest::parseMultiPartFile() {
#endif
QTemporaryFile *uploadedFile = nullptr;
QByteArray fieldValue;
QByteArray boundaryStart = "--" + boundary;
QByteArray boundaryEnd = boundary + "--";
while (!tempFile->atEnd() && !finished && !tempFile->error()) {
QByteArray line = tempFile->readLine(65536);
if (line.startsWith("--" + boundary)) {
if (line.startsWith(boundaryStart)) {
// Boundary found. Until now we have collected 2 bytes too much,
// so remove them from the last result
if (fileName.isEmpty() && !fieldName.isEmpty()) {
Expand Down Expand Up @@ -403,7 +405,7 @@ void HttpRequest::parseMultiPartFile() {
qWarning("HttpRequest: format error, unexpected end of file data");
}
}
if (line.contains(boundary + "--")) {
if (line.contains(boundaryEnd)) {
finished = true;
}
break;
Expand Down