Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support Qt6 builds #317

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
88 changes: 59 additions & 29 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,25 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [windows-2022, macos-11.0, ubuntu-22.04]
compiler: ['clang', 'gcc', 'msvc']
exclude:
include:
- os: ubuntu-22.04
compiler: 'msvc'
- os: macos-11.0
compiler: 'gcc'
compiler: gcc
qt: qt5
- os: ubuntu-22.04
compiler: clang
qt: qt5
- os: macos-11.0
compiler: 'msvc'
compiler: clang
qt: qt5
- os: windows-2022
compiler: 'clang'
compiler: gcc
qt: qt5
- os: windows-2022
compiler: 'gcc'
compiler: msvc
qt: qt5
- os: macos-11.0
compiler: clang
qt: qt6
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -43,7 +49,15 @@ jobs:
name: Install Packages for Ubuntu
run: |
sudo apt update -qq
sudo apt install -y build-essential git qt5-qmake libqt5opengl5-dev zlib1g-dev libssl-dev libminiupnpc-dev
sudo apt install -y build-essential git zlib1g-dev libssl-dev libminiupnpc-dev
- if: contains( matrix.os, 'ubuntu' ) && matrix.qt == 'qt5'
name: Install Qt5 for Ubuntu
run: |
sudo apt install -y qt5-qmake libqt5opengl5-dev
- if: contains( matrix.os, 'ubuntu' ) && matrix.qt == 'qt6'
name: Install Qt6 for Ubuntu
run: |
sudo apt install -y qmake6 libqt6opengl6-dev libqt6core5compat6-dev
- if: contains( matrix.os, 'ubuntu' ) && matrix.compiler == 'gcc'
name: Install GCC for Ubuntu
run: |
Expand All @@ -69,46 +83,62 @@ jobs:
- if: runner.os == 'macOS'
name: Install Packages for Mac
run: |
brew install qt5 openssl\@1.1 lcov miniupnpc
brew install lcov miniupnpc
- if: runner.os == 'macOS' && matrix.qt == 'qt5'
name: Install Qt5 for Mac
run: |
brew install qt5 openssl\@1.1
brew link qt5 --force
echo "$(brew --prefix qt5)/bin" >> $GITHUB_PATH
echo "MMAPPER_CMAKE_EXTRA=-DUSE_CODE_COVERAGE=true -DOPENSSL_ROOT_DIR=/usr/local/opt/[email protected]" >> $GITHUB_ENV
echo "COVERAGE=true" >> $GITHUB_ENV
echo "MMAPPER_CMAKE_EXTRA=-DOPENSSL_ROOT_DIR=/usr/local/opt/[email protected]" >> $GITHUB_ENV
- if: runner.os == 'macOS' && matrix.qt == 'qt6'
name: Install Qt6 for Mac
run: |
brew install qt6 openssl\@3
brew link qt6 --force
echo "$(brew --prefix qt6)/bin" >> $GITHUB_PATH
echo "MMAPPER_CMAKE_EXTRA=-DOPENSSL_ROOT_DIR=/usr/local/opt/openssl@3" >> $GITHUB_ENV


#
# Install Packages (Windows)
#
- if: runner.os == 'Windows'
- if: runner.os == 'Windows' && matrix.compiler == 'msvc'
name: Install Qt for Windows MSVC
uses: jurplel/install-qt-action@v3
with:
version: 5.15.2
dir: 'C:\'
arch: win64_msvc2019_64
cache: true
tools: 'tools_openssl_x64'
- if: runner.os == 'Windows' && matrix.compiler == 'msvc'
name: Add MSVC to PATH for Windows
run: |
echo "MMAPPER_CMAKE_EXTRA=-DCMAKE_PREFIX_PATH=C:\Qt\5.12.2\msvc2019_64" >> $GITHUB_ENV
- if: runner.os == 'Windows' && matrix.compiler == 'gcc'
name: Install Qt for Windows GCC
uses: jurplel/install-qt-action@v3
with:
version: 5.15.2
dir: 'C:\'
arch: win64_mingw81
cache: true
- if: runner.os == 'Windows' && matrix.compiler == 'gcc'
name: Add GCC to PATH for Windows
run: |
echo "MMAPPER_CMAKE_EXTRA=-DCMAKE_PREFIX_PATH=C:\Qt\5.12.2\win64_mingw81" >> $GITHUB_ENV



#
# Build
#
- if: runner.os == 'Windows' && matrix.compiler == 'msvc'
name: Build MMapper for Windows
shell: cmd
- name: Build MMapper
run: |
mkdir -p ${{ github.workspace }}/artifact
mkdir -p build
cd build
cmake --version
cmake -DCMAKE_BUILD_TYPE=Debug -G "NMake Makefiles" -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/artifact -DUSE_UNITY_BUILD=false -DCMAKE_PREFIX_PATH="C:\Qt\5.12.2\msvc2019_64" -DOPENSSL_ROOT_DIR=C:/Qt/Tools/OpenSSL/Win_x64 -S .. || exit -1
cmake --build . -j %NUMBER_OF_PROCESSORS%
- if: runner.os == 'Linux' || runner.os == 'macOS'
name: Build MMapper for Linux and Mac
run: |
mkdir -p build ${{ github.workspace }}/artifact
cd build
cmake --version
cmake -DCMAKE_BUILD_TYPE=Debug -G 'Ninja' -DUSE_UNITY_BUILD=false -DCPACK_PACKAGE_DIRECTORY=${{ github.workspace }}/artifact $MMAPPER_CMAKE_EXTRA -S .. || exit -1
cmake --build .

Expand Down Expand Up @@ -173,17 +203,17 @@ jobs:
name: Upload Package for Mac
uses: actions/upload-artifact@v3
with:
name: build-test Mac ${{ matrix.os }} ${{ matrix.compiler }}
name: build-test Mac ${{ matrix.os }} ${{ matrix.compiler }} ${{ matrix.qt }}
path: ${{ github.workspace }}/artifact/*.dmg
- if: contains( matrix.os, 'ubuntu' )
name: Upload Package for Ubuntu
uses: actions/upload-artifact@v3
with:
name: build-test Linux ${{ matrix.os }} ${{ matrix.compiler }}
name: build-test Linux ${{ matrix.os }} ${{ matrix.compiler }} ${{ matrix.qt }}
path: ${{ github.workspace }}/artifact/*.deb
- if: runner.os == 'Windows'
name: Upload Package for Windows
uses: actions/upload-artifact@v3
with:
name: build-test Windows ${{ matrix.os }} ${{ matrix.compiler }}
name: build-test Windows ${{ matrix.os }} ${{ matrix.compiler }} ${{ matrix.qt }}
path: ${{ github.workspace }}/artifact/*.exe
15 changes: 11 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,23 @@ if(WIN32 AND MINGW)
option(WITH_DRMINGW "Include Dr. Mingw crash dumping (Windows only)" ON)
endif()

find_package(Qt5 COMPONENTS REQUIRED Core Widgets Network OpenGL Test)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS REQUIRED Core Widgets Network OpenGL Test)

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)

if(Qt5Core_FOUND)
if(Qt5Core_VERSION VERSION_LESS 5.15.0)
message(FATAL_ERROR "Minimum supported Qt version is 5.15")
if(Qt5Core_FOUND OR Qt6Core_FOUND)
if(QT_VERSION_MAJOR MATCHES 5)
message(STATUS "Qt5 found")
if (Qt5Core_VERSION VERSION_LESS 5.15.0)
message(FATAL_ERROR "Minimum supported Qt version is 5.15")
endif()
elseif(QT_VERSION_MAJOR MATCHES 6)
message(STATUS "Qt6 found")
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS REQUIRED OpenGLWidgets Core5Compat)
endif()
endif()

Expand Down
32 changes: 25 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -493,12 +493,19 @@ add_executable(mmapper WIN32 MACOSX_BUNDLE
)

target_link_libraries(mmapper PUBLIC
Qt5::Core
Qt5::Widgets
Qt5::Network
Qt5::OpenGL
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Network
Qt${QT_VERSION_MAJOR}::OpenGL
)

if (QT_VERSION_MAJOR MATCHES 6)
target_link_libraries(mmapper PUBLIC
Qt::OpenGLWidgets
Qt::Core5Compat
)
endif()

set_target_properties(
mmapper PROPERTIES
CXX_STANDARD 17
Expand Down Expand Up @@ -676,12 +683,20 @@ if(UNIX AND NOT APPLE)
# Debian
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "[email protected]")
set(CPACK_DEBIAN_PACKAGE_NAME "mmapper")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a (>= 5.15.0), libqt5gui5 (>= 5.15.0), libqt5opengl5 (>= 5.15.0), libqt5network5 (>= 5.15.0)")
if (QT_VERSION_MAJOR MATCHES 5)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt5core5a (>= 5.15.0), libqt5gui5 (>= 5.15.0), libqt5opengl5 (>= 5.15.0), libqt5network5 (>= 5.15.0)")
else()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libqt6core6, libqt6gui6, libqt6opengl6, libqt6network6, libqt6core5compat6")
endif()
if(WITH_ZLIB)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, zlib1g")
endif()
if(WITH_OPENSSL)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libssl1.1")
if (QT_VERSION_MAJOR MATCHES 5)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libssl1.1")
else()
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libssl3")
endif()
endif()
if(WITH_MINIUPNPC)
set(CPACK_DEBIAN_PACKAGE_DEPENDS "${CPACK_DEBIAN_PACKAGE_DEPENDS}, libminiupnpc${MINIUPNPC_API_VERSION}")
Expand All @@ -701,7 +716,10 @@ if(WIN32)
)

# Bundle Library Files
set(WINDEPLOYQT_ARGS ${WINDEPLOYQT_ARGS} --dir ${CMAKE_CURRENT_BINARY_DIR}/bin --compiler-runtime --no-angle)
set(WINDEPLOYQT_ARGS ${WINDEPLOYQT_ARGS} --dir ${CMAKE_CURRENT_BINARY_DIR}/bin --compiler-runtime)
if (QT_VERSION_MAJOR MATCHES 5)
set(WINDEPLOYQT_ARGS ${WINDEPLOYQT_ARGS} --no-angle)
endif()
find_program(WINDEPLOYQT_APP windeployqt HINTS ${QTDIR} ENV QTDIR PATH_SUFFIXES bin)
message(" - windeployqt path: ${WINDEPLOYQT_APP}")
message(" - windeployqt args: ${WINDEPLOYQT_ARGS}")
Expand Down
4 changes: 4 additions & 0 deletions src/adventure/xpstatuswidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,11 @@ void XPStatusWidget::slot_updatedSession(const std::shared_ptr<AdventureSession>
updateContent();
}

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void XPStatusWidget::enterEvent(QEvent *event)
#else
void XPStatusWidget::enterEvent(QEnterEvent *event)
#endif
{
if (m_session) {
auto xpHourly = m_session->calculateHourlyRateXP();
Expand Down
4 changes: 4 additions & 0 deletions src/adventure/xpstatuswidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ public slots:
void slot_updatedSession(const std::shared_ptr<AdventureSession> &session);

protected:
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
void enterEvent(QEvent *event) override;
#else
void enterEvent(QEnterEvent *event) override;
#endif
void leaveEvent(QEvent *event) override;

private:
Expand Down
6 changes: 3 additions & 3 deletions src/client/displaywidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ void DisplayWidget::slot_displayText(const QString &str)
QRegularExpressionMatchIterator it = ansiRx.globalMatch(str);
while (it.hasNext()) {
QRegularExpressionMatch match = it.next();
ansiIndex = match.capturedStart(0);
ansiIndex = static_cast<int>(match.capturedStart(0));
textList << str.mid(textIndex, ansiIndex - textIndex);
ansiList << match.captured(1);
textIndex = match.capturedEnd(0);
textIndex = static_cast<int>(match.capturedEnd(0));
}
if (textIndex < str.length()) {
textList << str.mid(textIndex);
Expand All @@ -149,7 +149,7 @@ void DisplayWidget::slot_displayText(const QString &str)
m_cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor, 1);
m_backspace = false;
}
int backspaceIndex = textStr.indexOf('\10');
auto backspaceIndex = textStr.indexOf('\10');
if (backspaceIndex == -1) {
// No backspace
m_cursor.insertText(textStr, m_format);
Expand Down
4 changes: 3 additions & 1 deletion src/client/inputwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,9 @@ void InputWidget::tabComplete()
// Found a previous word to complete to
current.insertText(word);
if (current.movePosition(QTextCursor::StartOfWord, QTextCursor::KeepAnchor)) {
current.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, m_tabFragment.size());
current.movePosition(QTextCursor::Right,
QTextCursor::KeepAnchor,
static_cast<int>(m_tabFragment.size()));
setTextCursor(current);
}
m_tabHistory.forward();
Expand Down
30 changes: 15 additions & 15 deletions src/global/TextUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ void AnsiColorParser::for_each(QStringView ansi) const
// ESC[...m -> ...
ansi = ansi.mid(2, ansi.length() - 3);

const int len = ansi.length();
int pos = 0;
const auto len = ansi.length();
qsizetype pos = 0;

const auto try_report = [this, &ansi, &pos](const auto idx) -> void {
if (idx <= pos)
Expand Down Expand Up @@ -181,7 +181,7 @@ int findTrailingWhitespace(const QStringView line)
auto m = trailingWhitespaceRegex.match(line);
if (!m.hasMatch())
return -1;
return m.capturedStart();
return static_cast<int>(m.capturedStart());
}

int findTrailingWhitespace(const QString &line)
Expand Down Expand Up @@ -618,7 +618,7 @@ struct NODISCARD Prefix final
{
auto m = quotePrefixRegex.match(line);
if (m.hasMatch()) {
const int len = m.capturedLength(0);
const auto len = m.capturedLength(0);
quotePrefix = line.left(len);
prefixLen = measureExpandedTabsOneLine(quotePrefix, 0);

Expand All @@ -639,7 +639,7 @@ struct NODISCARD Prefix final
if (m.hasMatch()) {
const QStringView sv = m.capturedView();
/* this could fail if someone breaks the regex pattern for the escaped asterisk */
bulletLength = sv.length();
bulletLength = static_cast<int>(sv.length());
prefixLen = measureExpandedTabsOneLine(sv, prefixLen);
hasPrefix2 = true;
append(sv);
Expand Down Expand Up @@ -771,7 +771,7 @@ TextBuffer normalizeAnsi(const QStringView old)
}

TextBuffer output;
output.reserve(2 * old.length()); /* no idea */
output.reserve(2 * static_cast<int>(old.length())); /* no idea */

const auto reset = AnsiString::get_reset_string();

Expand All @@ -797,15 +797,15 @@ TextBuffer normalizeAnsi(const QStringView old)
output.append(sv);
};

int pos = 0;
auto pos = 0;
foreachAnsi(line, [&next, &line, &pos, &print](const auto begin, const QStringView ansiStr) {
assert(line.at(begin) == '\x1b');
if (begin > pos) {
print(line.mid(pos, begin - pos));
}

pos = begin + ansiStr.length();
ansiForeachColorCode(ansiStr, [&next](int code) { next.process_code(code); });
pos = static_cast<int>(begin + ansiStr.length());
ansiForeachColorCode(ansiStr, [&next](auto code) { next.process_code(code); });
});

if (pos < line.length()) {
Expand Down Expand Up @@ -839,9 +839,9 @@ AnsiStringToken::AnsiStringToken(AnsiStringToken::TokenTypeEnum _type,
, length_{_length}
{
const auto maxlen = _text.length();
assert(isClamped(start_offset(), 0, maxlen));
assert(isClamped(length(), 0, maxlen));
assert(isClamped(end_offset(), 0, maxlen));
assert(isClamped(start_offset(), static_cast<size_type>(0), maxlen));
assert(isClamped(length(), static_cast<size_type>(0), maxlen));
assert(isClamped(end_offset(), static_cast<size_type>(0), maxlen));
}

QStringView AnsiStringToken::getQStringView() const
Expand All @@ -859,17 +859,17 @@ AnsiTokenizer::Iterator::Iterator(const QString &_str, AnsiTokenizer::Iterator::
: str_{_str}
, pos_{_pos}
{
assert(isClamped(pos_, 0, str_.size()));
assert(isClamped(pos_, static_cast<size_type>(0), str_.size()));
}

AnsiStringToken AnsiTokenizer::Iterator::next()
{
assert(hasNext());
const auto len = str_.size();
const auto token = getCurrent();
assert(isClamped(pos_, 0, len));
assert(isClamped(pos_, static_cast<size_type>(0), len));
assert(token.start_offset() == pos_);
assert(isClamped(token.length(), 1, len - pos_));
assert(isClamped(token.length(), static_cast<size_type>(1), len - pos_));
pos_ = token.end_offset();
return token;
}
Expand Down
Loading