From fc8599299e785cd18a483fa6e6e64bb63db73f0e Mon Sep 17 00:00:00 2001 From: Yehonal Date: Wed, 10 Aug 2016 12:39:25 +0200 Subject: [PATCH] [CORE] Allowing compilation with c++11 --- CMakeLists.txt | 2 +- src/cmake/compiler/clang/settings.cmake | 2 ++ src/cmake/compiler/gcc/settings.cmake | 12 ++++++++++++ src/server/shared/Common.h | 2 +- src/server/shared/Logging/Log.h | 1 + src/server/shared/Threading/Threading.h | 2 ++ 6 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e0be32872..3cc6c562e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -59,7 +59,7 @@ include(CheckPlatform) # basic packagesearching and setup (further support will be needed, this is a preliminary release!) set(OPENSSL_EXPECTED_VERSION 1.0.0) -set(ACE_EXPECTED_VERSION 5.8.3) +set(ACE_EXPECTED_VERSION 6.0.3) find_package(PCHSupport) find_package(ACE REQUIRED) diff --git a/src/cmake/compiler/clang/settings.cmake b/src/cmake/compiler/clang/settings.cmake index ae07b1fc3..28db45aea 100644 --- a/src/cmake/compiler/clang/settings.cmake +++ b/src/cmake/compiler/clang/settings.cmake @@ -13,3 +13,5 @@ if(WITH_COREDEBUG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3") message(STATUS "Clang: Debug-flags set (-g3)") endif() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-narrowing -Wno-deprecated-register") diff --git a/src/cmake/compiler/gcc/settings.cmake b/src/cmake/compiler/gcc/settings.cmake index 25ee96c85..bd6df376f 100644 --- a/src/cmake/compiler/gcc/settings.cmake +++ b/src/cmake/compiler/gcc/settings.cmake @@ -1,6 +1,18 @@ # Set build-directive (used in core to tell which buildtype we used) add_definitions(-D_BUILD_DIRECTIVE='"${CMAKE_BUILD_TYPE}"') +set(GCC_EXPECTED_VERSION 4.8.2) + +if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS GCC_EXPECTED_VERSION) + message(FATAL_ERROR "GCC: AzerothCore requires version ${GCC_EXPECTED_VERSION} to build but found ${CMAKE_CXX_COMPILER_VERSION}") +endif() + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +message(STATUS "GCC: Enabled c++11 support") + +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") +#message(STATUS "GCC: Enabled C99 support") + if(PLATFORM EQUAL 32) # Required on 32-bit systems to enable SSE2 (standard on x64) set(SSE_FLAGS "-msse2 -mfpmath=sse") diff --git a/src/server/shared/Common.h b/src/server/shared/Common.h index c3620f207..3415a0336 100644 --- a/src/server/shared/Common.h +++ b/src/server/shared/Common.h @@ -139,7 +139,7 @@ inline float finiteAlways(float f) { return finite(f) ? f : 0.0f; } #if COMPILER == COMPILER_MICROSOFT inline bool myisfinite(float f) { return _finite(f) && !_isnan(f); } #else -inline bool myisfinite(float f) { return finite(f) && !isnan(f); } +inline bool myisfinite(float f) { return finite(f) && !std::isnan(f); } #endif #define atol(a) strtoul( a, NULL, 10) diff --git a/src/server/shared/Logging/Log.h b/src/server/shared/Logging/Log.h index c7f857272..5bd353c58 100644 --- a/src/server/shared/Logging/Log.h +++ b/src/server/shared/Logging/Log.h @@ -20,6 +20,7 @@ #define AZEROTHCORE_LOG_H #include "Common.h" +#include #include class WorldPacket; diff --git a/src/server/shared/Threading/Threading.h b/src/server/shared/Threading/Threading.h index 39ea88af6..8ec585382 100644 --- a/src/server/shared/Threading/Threading.h +++ b/src/server/shared/Threading/Threading.h @@ -19,6 +19,8 @@ #ifndef THREADING_H #define THREADING_H +#include "Common.h" +#include #include #include #include