summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKitzunu <24550914+Kitzunu@users.noreply.github.com>2022-02-11 14:37:24 +0100
committerGitHub <noreply@github.com>2022-02-11 14:37:24 +0100
commit7e8b021db36bd54fe7bd10eefa2902416e75c97e (patch)
treee3a3c7221174c9dd5063ebc3010fee4d5e716a87
parent8a9a3c6fac57577d8849ec5aea81c5583fbf6092 (diff)
feat(Core): Enable C++20 support (#10440)
* feat(Core): Enable C++20 support * Update Duration.h * Revert "Update Duration.h" This reverts commit 177093e992c5d47d8c3b978c84857f5ecba12889. * maybe fix GCC * cherry-pick https://gcc.gnu.org/pipermail/gcc-cvs/2020-June/299715.html * Update Duration.h * Update Duration.h * Update Duration.h * Update Duration.h * Update Duration.h * Update Duration.h * Update Duration.h * Revert "Update Duration.h" This reverts commit dc4e2ce281dd1a33cfac5be56488a3b96131bfd5. * Update Duration.h * Update Duration.h * Update Duration.h * cleanup * more cleanup * maybe fix build * restore advstd::type_identity because GCC8 is garbage * Update advstd.h * fix gcc8 :zzz: * Update CMakeLists.txt * Update CMakeLists.txt * Update src/common/Utilities/advstd.h Co-authored-by: Francesco Borzì <borzifrancesco@gmail.com>
-rw-r--r--.github/workflows/cpp20.yml46
-rw-r--r--conf/dist/config.cmake3
-rw-r--r--deps/boost/CMakeLists.txt2
-rw-r--r--src/cmake/macros/ConfigureBaseTargets.cmake12
-rw-r--r--src/cmake/showoptions.cmake6
-rw-r--r--src/common/Utilities/Duration.h30
-rw-r--r--src/common/Utilities/EventProcessor.h1
-rw-r--r--src/common/Utilities/advstd.h2
-rw-r--r--src/server/game/Chat/Hyperlinks.cpp1
9 files changed, 23 insertions, 80 deletions
diff --git a/.github/workflows/cpp20.yml b/.github/workflows/cpp20.yml
deleted file mode 100644
index 3fcd885b77..0000000000
--- a/.github/workflows/cpp20.yml
+++ /dev/null
@@ -1,46 +0,0 @@
-name: C++20
-on:
- push:
- branches:
- - 'master'
- pull_request:
- types: ['labeled', 'labeled', 'opened', 'synchronize', 'reopened']
-
-concurrency:
- group: ${{ github.head_ref }} || concat(${{ github.ref }}, ${{ github.workflow }})
- cancel-in-progress: true
-
-jobs:
- build:
- runs-on: ubuntu-20.04
- name: C++20
- env:
- COMPILER: clang
- ENABLE_CPP_20: 1
- if: github.repository == 'azerothcore/azerothcore-wotlk' && (github.ref == 'refs/heads/master' || contains(github.event.pull_request.labels.*.name, 'file-cpp') || github.event.label.name == 'file-cpp' || contains(github.event.pull_request.labels.*.name, 'run-build') || github.event.label.name == 'run-build')
- steps:
- - uses: actions/checkout@v2
- - name: Cache
- uses: actions/cache@v2
- with:
- path: var/ccache
- key: ccache:C++20:${{ github.ref }}:${{ github.sha }}
- restore-keys: |
- ccache:C++20:${{ github.ref }}
- ccache:C++20
- - name: Configure OS
- run: source ./acore.sh install-deps
- env:
- CONTINUOUS_INTEGRATION: true
- - name: Create conf/config.sh
- run: source ./apps/ci/ci-conf.sh
- - name: Import db
- run: source ./apps/ci/ci-import-db.sh
- - name: Build
- run: source ./apps/ci/ci-compile.sh
- - name: Dry run
- run: source ./apps/ci/ci-worldserver-dry-run.sh
- - name: Check startup errors
- run: source ./apps/ci/ci-error-check.sh
- - name: Run unit tests
- run: source ./apps/ci/ci-run-unit-tests.sh
diff --git a/conf/dist/config.cmake b/conf/dist/config.cmake
index 329f2656eb..43bc3dd5ee 100644
--- a/conf/dist/config.cmake
+++ b/conf/dist/config.cmake
@@ -87,8 +87,5 @@ endif()
set(WITH_SOURCE_TREE "hierarchical" CACHE STRING "Build the source tree for IDE's.")
set_property(CACHE WITH_SOURCE_TREE PROPERTY STRINGS no flat hierarchical)
-# If disable - use c++17
-option(USE_CPP_20 "Enable c++20 standard" 0)
-
# Config abort
option(CONFIG_ABORT_INCORRECT_OPTIONS "Enable abort if core found incorrect option in config files" 0)
diff --git a/deps/boost/CMakeLists.txt b/deps/boost/CMakeLists.txt
index afe44ba4a3..db4ef4ef5d 100644
--- a/deps/boost/CMakeLists.txt
+++ b/deps/boost/CMakeLists.txt
@@ -27,7 +27,7 @@ include (CheckCXXSourceCompiles)
if (WIN32)
# On windows the requirements are higher according to the wiki.
- set(BOOST_REQUIRED_VERSION 1.70)
+ set(BOOST_REQUIRED_VERSION 1.74)
else()
set(BOOST_REQUIRED_VERSION 1.67)
endif()
diff --git a/src/cmake/macros/ConfigureBaseTargets.cmake b/src/cmake/macros/ConfigureBaseTargets.cmake
index 046b8728f1..830a634ba6 100644
--- a/src/cmake/macros/ConfigureBaseTargets.cmake
+++ b/src/cmake/macros/ConfigureBaseTargets.cmake
@@ -16,15 +16,9 @@ add_library(acore-compile-option-interface INTERFACE)
# Use -std=c++11 instead of -std=gnu++11
set(CXX_EXTENSIONS OFF)
-if (USE_CPP_20)
- # Enable support С++20
- set(CMAKE_CXX_STANDARD 20)
- message(STATUS "Enabled С++20 standard")
-else()
- # Enable support С++17
- set(CMAKE_CXX_STANDARD 17)
- message(STATUS "Enabled С++17 standard")
-endif()
+# Enable C++20 support
+set(CMAKE_CXX_STANDARD 20)
+message(STATUS "Enabled С++20 standard")
# An interface library to make the warnings level available to other targets
# This interface taget is set-up through the platform specific script
diff --git a/src/cmake/showoptions.cmake b/src/cmake/showoptions.cmake
index 906692e106..1d2366a281 100644
--- a/src/cmake/showoptions.cmake
+++ b/src/cmake/showoptions.cmake
@@ -182,12 +182,6 @@ if(BUILD_SHARED_LIBS)
WarnAboutSpacesInBuildPath()
endif()
-if (USE_CPP_20)
- message("")
- message(" *** Enabled C++20 standart")
- message(" *** Please note that this is an experimental feature!")
-endif()
-
if (CONFIG_ABORT_INCORRECT_OPTIONS)
message("")
message(" WARNING !")
diff --git a/src/common/Utilities/Duration.h b/src/common/Utilities/Duration.h
index 9ddb1a68a1..ed6bbf8817 100644
--- a/src/common/Utilities/Duration.h
+++ b/src/common/Utilities/Duration.h
@@ -35,7 +35,22 @@ using Minutes = std::chrono::minutes;
/// Hours shorthand typedef.
using Hours = std::chrono::hours;
-#if __cplusplus > 201703L
+// Workaround for GCC and Clang 10 in C++20
+#if defined(__GNUC__) && (!defined(__clang__) || (__clang_major__ == 10))
+/// Days shorthand typedef.
+using Days = std::chrono::duration<__INT64_TYPE__, std::ratio<86400>>;
+
+/// Weeks shorthand typedef.
+using Weeks = std::chrono::duration<__INT64_TYPE__, std::ratio<604800>>;
+
+/// Years shorthand typedef.
+using Years = std::chrono::duration<__INT64_TYPE__, std::ratio<31556952>>;
+
+/// Months shorthand typedef.
+using Months = std::chrono::duration<__INT64_TYPE__, std::ratio<2629746>>;
+
+#else
+
/// Days shorthand typedef.
using Days = std::chrono::days;
@@ -47,19 +62,8 @@ using Years = std::chrono::years;
/// Months shorthand typedef.
using Months = std::chrono::months;
-#else
-/// Days shorthand typedef. (delete after start support c++20)
-using Days = std::chrono::duration<int, std::ratio_multiply<std::ratio<24>, Hours::period>>;
-/// Weeks shorthand typedef. (delete after start support c++20)
-using Weeks = std::chrono::duration<int, std::ratio_multiply<std::ratio<7>, Days::period>>;
-
-/// Years shorthand typedef. (delete after start support c++20)
-using Years = std::chrono::duration<int, std::ratio_multiply<std::ratio<146097, 400>, Days::period>>;
-
-/// Months shorthand typedef. (delete after start support c++20)
-using Months = std::chrono::duration<int, std::ratio_divide<Years::period, std::ratio<12>>>;
-#endif
+#endif // GCC_VERSION
/// time_point shorthand typedefs
using TimePoint = std::chrono::steady_clock::time_point;
diff --git a/src/common/Utilities/EventProcessor.h b/src/common/Utilities/EventProcessor.h
index 81b3bf79c3..aaf6481a76 100644
--- a/src/common/Utilities/EventProcessor.h
+++ b/src/common/Utilities/EventProcessor.h
@@ -21,7 +21,6 @@
#include "Define.h"
#include "Duration.h"
#include "Random.h"
-
#include "advstd.h"
#include <map>
#include <type_traits>
diff --git a/src/common/Utilities/advstd.h b/src/common/Utilities/advstd.h
index 3e58973058..3b33dbaec6 100644
--- a/src/common/Utilities/advstd.h
+++ b/src/common/Utilities/advstd.h
@@ -24,6 +24,8 @@
// this namespace holds implementations of upcoming stdlib features that our c++ version doesn't have yet
namespace advstd
{
+ // This workaround for std::remove_cvref_t, std::type_identify is needed for GCC 8...
+ // TODO: remove when we drop GCC 8 support. https://en.cppreference.com/w/cpp/compiler_support/20
// C++20 advstd::remove_cvref_t
template <class T>
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>;
diff --git a/src/server/game/Chat/Hyperlinks.cpp b/src/server/game/Chat/Hyperlinks.cpp
index e817ac461f..cc9e43cafc 100644
--- a/src/server/game/Chat/Hyperlinks.cpp
+++ b/src/server/game/Chat/Hyperlinks.cpp
@@ -24,7 +24,6 @@
#include "SharedDefines.h"
#include "SpellInfo.h"
#include "SpellMgr.h"
-#include "advstd.h"
using namespace Acore::Hyperlinks;