mirror of
https://github.com/Nheko-Reborn/nheko.git
synced 2024-11-24 20:18:53 +03:00
Switch to C++20
This commit is contained in:
parent
7efb4a22c7
commit
efb9970178
7 changed files with 39 additions and 78 deletions
|
@ -18,7 +18,7 @@ set(
|
|||
CACHE
|
||||
FILEPATH "Default toolchain"
|
||||
)
|
||||
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard")
|
||||
set(CMAKE_CXX_STANDARD 20 CACHE STRING "C++ standard")
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE BOOL "Require C++ standard to be supported")
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON CACHE BOOL "compile as PIC by default")
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
@ -582,7 +582,7 @@ if(USE_BUNDLED_MTXCLIENT)
|
|||
FetchContent_Declare(
|
||||
MatrixClient
|
||||
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
|
||||
GIT_TAG 251dc12469ecd96d0ec491551589b244f12d6d92
|
||||
GIT_TAG 8dd9214f622fe5f307249b37029c17f1fdff25ab
|
||||
)
|
||||
set(BUILD_LIB_EXAMPLES OFF CACHE INTERNAL "")
|
||||
set(BUILD_LIB_TESTS OFF CACHE INTERNAL "")
|
||||
|
|
|
@ -245,7 +245,7 @@ sharing easier.
|
|||
- [libnice](https://gitlab.freedesktop.org/libnice/libnice)
|
||||
- XCB, XCB-EWMH: For screensharing support on X11. VOIP needs to be enabled. Can be disabled with `-DSCREENSHARE_X11=OFF`.
|
||||
- [qtkeychain](https://github.com/frankosterfeld/qtkeychain) (You need at least version 0.12 for proper Gnome Keychain support. The bundled version requires libsecret, unless you pass `-DLIBSECRET_SUPPORT=OFF`.)
|
||||
- A compiler that supports C++ 17:
|
||||
- A compiler that supports C++ 20:
|
||||
- Clang 6 (tested on Travis CI)
|
||||
- GCC 7 (tested on Travis CI)
|
||||
- MSVC 19.13 (tested on AppVeyor)
|
||||
|
@ -346,12 +346,11 @@ brew install qt5 lmdb cmake llvm spdlog boost cmark libolm qtkeychain
|
|||
|
||||
##### Windows
|
||||
|
||||
1. Install Visual Studio 2017's "Desktop Development" and "Linux Development with C++"
|
||||
1. Install Visual Studio 2022's "Desktop Development" and "Linux Development with C++"
|
||||
(for the CMake integration) workloads.
|
||||
|
||||
2. Download the latest Qt for windows installer and install it somewhere.
|
||||
Make sure to install the `MSVC 2017 64-bit` toolset for at least Qt 5.10
|
||||
(lower versions does not support VS2017).
|
||||
Make sure to install the `MSVC 2022 64-bit` toolset for at least Qt 5.15.
|
||||
|
||||
3. If you don't have openssl installed, you will need to install perl to build it (i.e. Strawberry Perl).
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
version: 0.10.1-{build}
|
||||
|
||||
configuration: Release
|
||||
image: Visual Studio 2019
|
||||
image: Visual Studio 2022
|
||||
platform: x64
|
||||
|
||||
environment:
|
||||
|
@ -23,9 +23,7 @@ build:
|
|||
|
||||
install:
|
||||
- set QT_DIR=C:\Qt\5.15\msvc2019_64
|
||||
- set PATH=Path=C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files\Git\cmd;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\PowerShell\7\;C:\Program Files\7-Zip;C:\Program Files\Microsoft\Web Platform Installer\;C:\Tools\NuGet;C:\Tools\PsTools;C:\Program Files\Git\usr\bin;C:\Program Files\Git LFS;C:\Program Files\Mercurial\;C:\Program Files (x86)\Subversion\bin;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\dotnet\;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\Microsoft\SQLDB\DAC\150;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin;C:\Tools\xUnit;C:\Tools\xUnit20;C:\Tools\NUnit\bin;C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\Extensions\TestPlatform;C:\Ruby193\bin;C:\Tools\WebDriver;C:\Python27;C:\Python27\Scripts;C:\Program Files\erl10.7\bin;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft DirectX SDK;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Tools\Doxygen;C:\Program Files (x86)\CMake\bin;C:\ProgramData\chocolatey\bin;C:\Tools\vcpkg;C:\Tools\Coverity\bin;C:\Program Files (x86)\NSIS;C:\Tools\Octopus;C:\Program Files\Meson\;C:\Tools\GitVersion;C:\Tools\NUnit3\bin;C:\Users\appveyor\AppData\Local\Microsoft\WindowsApps;C:\Users\appveyor\.dotnet\tools;C:\Program Files\AppVeyor\BuildAgent\
|
||||
- set PATH=C:\Strawberry\perl\bin;C:\Python39-x64;%QT_DIR%\bin;%PATH%
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat" x64
|
||||
|
||||
build_script:
|
||||
# VERSION format: branch-master/branch-1.2
|
||||
|
@ -47,7 +45,7 @@ build_script:
|
|||
- echo %DATE%
|
||||
|
||||
# Build nheko
|
||||
- cmake -G "Visual Studio 16 2019" -A x64 -H. -Bbuild
|
||||
- cmake -G "Visual Studio 17 2022" -A x64 -H. -Bbuild
|
||||
-DHUNTER_ROOT="C:\hunter"
|
||||
-DHUNTER_ENABLED=ON -DBUILD_SHARED_LIBS=OFF -DUSE_BUNDLED_OPENSSL=ON
|
||||
-DCMAKE_BUILD_TYPE=Release -DHUNTER_CONFIGURATION_TYPES=Release
|
||||
|
|
|
@ -173,7 +173,7 @@ modules:
|
|||
buildsystem: cmake-ninja
|
||||
name: mtxclient
|
||||
sources:
|
||||
- commit: 251dc12469ecd96d0ec491551589b244f12d6d92
|
||||
- commit: 8dd9214f622fe5f307249b37029c17f1fdff25ab
|
||||
#tag: v0.8.2
|
||||
type: git
|
||||
url: https://github.com/Nheko-Reborn/mtxclient.git
|
||||
|
|
|
@ -9,12 +9,10 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <cctype>
|
||||
#include <concepts>
|
||||
#include <type_traits>
|
||||
|
||||
namespace {
|
||||
template<template<class...> class Op, class... Args>
|
||||
using is_detected = typename nheko::detail::detector<nheko::nonesuch, void, Op, Args...>::value_t;
|
||||
|
||||
struct IsStateEvent
|
||||
{
|
||||
template<class T>
|
||||
|
@ -31,19 +29,13 @@ struct IsStateEvent
|
|||
|
||||
struct EventMsgType
|
||||
{
|
||||
template<class E>
|
||||
using msgtype_t = decltype(E::msgtype);
|
||||
template<class T>
|
||||
mtx::events::MessageType operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<msgtype_t, T>::value) {
|
||||
if constexpr (std::is_same_v<std::optional<std::string>,
|
||||
std::remove_cv_t<decltype(e.content.msgtype)>>)
|
||||
return mtx::events::getMessageType(e.content.msgtype.value());
|
||||
else if constexpr (std::is_same_v<std::string,
|
||||
std::remove_cv_t<decltype(e.content.msgtype)>>)
|
||||
return mtx::events::getMessageType(e.content.msgtype);
|
||||
}
|
||||
if constexpr (requires(decltype(e) t) { t.content.msgtype.value(); })
|
||||
return mtx::events::getMessageType(e.content.msgtype.value());
|
||||
else if constexpr (requires(decltype(e) t) { std::string{t.content.msgtype}; })
|
||||
return mtx::events::getMessageType(e.content.msgtype);
|
||||
return mtx::events::MessageType::Unknown;
|
||||
}
|
||||
};
|
||||
|
@ -94,31 +86,23 @@ struct CallType
|
|||
|
||||
struct EventBody
|
||||
{
|
||||
template<class C>
|
||||
using body_t = decltype(C::body);
|
||||
template<class T>
|
||||
std::string operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<body_t, T>::value) {
|
||||
if constexpr (std::is_same_v<std::optional<std::string>,
|
||||
std::remove_cv_t<decltype(e.content.body)>>)
|
||||
return e.content.body ? e.content.body.value() : "";
|
||||
else if constexpr (std::is_same_v<std::string,
|
||||
std::remove_cv_t<decltype(e.content.body)>>)
|
||||
return e.content.body;
|
||||
}
|
||||
if constexpr (requires(decltype(e) t) { t.content.body.value(); })
|
||||
return e.content.body ? e.content.body.value() : "";
|
||||
else if constexpr (requires(decltype(e) t) { std::string{t.content.body}; })
|
||||
return e.content.body;
|
||||
return "";
|
||||
}
|
||||
};
|
||||
|
||||
struct EventFormattedBody
|
||||
{
|
||||
template<class C>
|
||||
using formatted_body_t = decltype(C::formatted_body);
|
||||
template<class T>
|
||||
std::string operator()(const mtx::events::RoomEvent<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<formatted_body_t, T>::value) {
|
||||
if constexpr (requires { T::formatted_body; }) {
|
||||
if (e.content.format == "org.matrix.custom.html")
|
||||
return e.content.formatted_body;
|
||||
}
|
||||
|
@ -128,12 +112,10 @@ struct EventFormattedBody
|
|||
|
||||
struct EventFile
|
||||
{
|
||||
template<class Content>
|
||||
using file_t = decltype(Content::file);
|
||||
template<class T>
|
||||
std::optional<mtx::crypto::EncryptedFile> operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<file_t, T>::value)
|
||||
if constexpr (requires { T::file; })
|
||||
return e.content.file;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -141,12 +123,10 @@ struct EventFile
|
|||
|
||||
struct EventThumbnailFile
|
||||
{
|
||||
template<class Content>
|
||||
using file_t = decltype(Content::info.thumbnail_file);
|
||||
template<class T>
|
||||
std::optional<mtx::crypto::EncryptedFile> operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<file_t, T>::value)
|
||||
if constexpr (requires { T::thumbnail_file; })
|
||||
return e.content.info.thumbnail_file;
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -154,12 +134,10 @@ struct EventThumbnailFile
|
|||
|
||||
struct EventUrl
|
||||
{
|
||||
template<class Content>
|
||||
using url_t = decltype(Content::url);
|
||||
template<class T>
|
||||
std::string operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<url_t, T>::value) {
|
||||
if constexpr (requires { T::url; }) {
|
||||
if (auto file = EventFile{}(e))
|
||||
return file->url;
|
||||
return e.content.url;
|
||||
|
@ -170,12 +148,10 @@ struct EventUrl
|
|||
|
||||
struct EventThumbnailUrl
|
||||
{
|
||||
template<class Content>
|
||||
using thumbnail_url_t = decltype(Content::info.thumbnail_url);
|
||||
template<class T>
|
||||
std::string operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<thumbnail_url_t, T>::value) {
|
||||
if constexpr (requires { e.content.info.thumbnail_url; }) {
|
||||
if (auto file = EventThumbnailFile{}(e))
|
||||
return file->url;
|
||||
return e.content.info.thumbnail_url;
|
||||
|
@ -186,12 +162,10 @@ struct EventThumbnailUrl
|
|||
|
||||
struct EventDuration
|
||||
{
|
||||
template<class Content>
|
||||
using thumbnail_url_t = decltype(Content::info.duration);
|
||||
template<class T>
|
||||
uint64_t operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<thumbnail_url_t, T>::value) {
|
||||
if constexpr (requires { e.content.info.duration; }) {
|
||||
return e.content.info.duration;
|
||||
}
|
||||
return 0;
|
||||
|
@ -200,12 +174,10 @@ struct EventDuration
|
|||
|
||||
struct EventBlurhash
|
||||
{
|
||||
template<class Content>
|
||||
using blurhash_t = decltype(Content::info.blurhash);
|
||||
template<class T>
|
||||
std::string operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<blurhash_t, T>::value) {
|
||||
if constexpr (requires { e.content.info.blurhash; }) {
|
||||
return e.content.info.blurhash;
|
||||
}
|
||||
return "";
|
||||
|
@ -245,12 +217,10 @@ struct EventFilename
|
|||
|
||||
struct EventMimeType
|
||||
{
|
||||
template<class Content>
|
||||
using mimetype_t = decltype(Content::info.mimetype);
|
||||
template<class T>
|
||||
std::string operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<mimetype_t, T>::value) {
|
||||
if constexpr (requires { e.content.info.mimetype; }) {
|
||||
return e.content.info.mimetype;
|
||||
}
|
||||
return "";
|
||||
|
@ -259,12 +229,10 @@ struct EventMimeType
|
|||
|
||||
struct EventFilesize
|
||||
{
|
||||
template<class Content>
|
||||
using filesize_t = decltype(Content::info.size);
|
||||
template<class T>
|
||||
int64_t operator()(const mtx::events::RoomEvent<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<filesize_t, T>::value) {
|
||||
if constexpr (requires { e.content.info.size; }) {
|
||||
return e.content.info.size;
|
||||
}
|
||||
return 0;
|
||||
|
@ -275,12 +243,10 @@ struct EventRelations
|
|||
{
|
||||
inline const static mtx::common::Relations empty;
|
||||
|
||||
template<class Content>
|
||||
using related_ev_id_t = decltype(Content::relations);
|
||||
template<class T>
|
||||
const mtx::common::Relations &operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<related_ev_id_t, T>::value) {
|
||||
if constexpr (requires { T::relations; }) {
|
||||
return e.content.relations;
|
||||
}
|
||||
return empty;
|
||||
|
@ -290,12 +256,10 @@ struct EventRelations
|
|||
struct SetEventRelations
|
||||
{
|
||||
mtx::common::Relations new_relations;
|
||||
template<class Content>
|
||||
using related_ev_id_t = decltype(Content::relations);
|
||||
template<class T>
|
||||
void operator()(mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<related_ev_id_t, T>::value) {
|
||||
if constexpr (requires { T::relations; }) {
|
||||
e.content.relations = std::move(new_relations);
|
||||
}
|
||||
}
|
||||
|
@ -317,12 +281,10 @@ struct EventTransactionId
|
|||
|
||||
struct EventMediaHeight
|
||||
{
|
||||
template<class Content>
|
||||
using h_t = decltype(Content::info.h);
|
||||
template<class T>
|
||||
uint64_t operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<h_t, T>::value) {
|
||||
if constexpr (requires { e.content.info.h; }) {
|
||||
return e.content.info.h;
|
||||
}
|
||||
return -1;
|
||||
|
@ -331,12 +293,10 @@ struct EventMediaHeight
|
|||
|
||||
struct EventMediaWidth
|
||||
{
|
||||
template<class Content>
|
||||
using w_t = decltype(Content::info.w);
|
||||
template<class T>
|
||||
uint64_t operator()(const mtx::events::Event<T> &e)
|
||||
{
|
||||
if constexpr (is_detected<w_t, T>::value) {
|
||||
if constexpr (requires { e.content.info.h; }) {
|
||||
return e.content.info.w;
|
||||
}
|
||||
return -1;
|
||||
|
|
|
@ -852,7 +852,8 @@ CommunitiesModel::updateSpaceStatus(QString space,
|
|||
.arg(QString::fromStdString(err->matrix_error.error)));
|
||||
nhlog::net()->error("Failed to update child {} of {}: {}",
|
||||
room.toStdString(),
|
||||
space.toStdString());
|
||||
space.toStdString(),
|
||||
*err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -869,7 +870,8 @@ CommunitiesModel::updateSpaceStatus(QString space,
|
|||
.arg(QString::fromStdString(err->matrix_error.error)));
|
||||
nhlog::net()->error("Failed to delete child {} of {}: {}",
|
||||
room.toStdString(),
|
||||
space.toStdString());
|
||||
space.toStdString(),
|
||||
*err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -891,7 +893,8 @@ CommunitiesModel::updateSpaceStatus(QString space,
|
|||
.arg(QString::fromStdString(err->matrix_error.error)));
|
||||
nhlog::net()->error("Failed to update parent {} of {}: {}",
|
||||
space.toStdString(),
|
||||
room.toStdString());
|
||||
room.toStdString(),
|
||||
*err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -908,7 +911,8 @@ CommunitiesModel::updateSpaceStatus(QString space,
|
|||
.arg(QString::fromStdString(err->matrix_error.error)));
|
||||
nhlog::net()->error("Failed to delete parent {} of {}: {}",
|
||||
space.toStdString(),
|
||||
room.toStdString());
|
||||
room.toStdString(),
|
||||
*err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
|
Loading…
Reference in a new issue