feat(Core/Random): port random system from TrinityCore (#5454)

* feat(Core/Random): port random system from TrinityCore

* lic

* logic correct

* MultimapErasePair move

* whitespace

17:13:34 1. 'Containers.h'. Replace (1)
17:13:40 2. 'LootMgr.h'. Replace (1)
17:13:44 3. 'World.cpp'. Replace (1)
17:13:47 4. 'instance_scholomance.cpp'. Replace (1)

* correct debug build
This commit is contained in:
Kargatum
2021-05-17 02:53:21 +07:00
committed by GitHub
parent 0d699222de
commit 13f71c9c4d
33 changed files with 2933 additions and 651 deletions

View File

@@ -1,3 +1,4 @@
#
# Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
# Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-AGPL3
#
@@ -8,12 +9,79 @@
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
add_library(sfmt INTERFACE)
set(SFMT_SOURCES
SFMT.c
SFMT.h
SFMT-alti.h
SFMT-common.h
SFMT-neon.h
SFMT-params.h
SFMT-params607.h
SFMT-params1279.h
SFMT-params2281.h
SFMT-params4253.h
SFMT-params11213.h
SFMT-params19937.h
SFMT-params44497.h
SFMT-params86243.h
SFMT-params132049.h
SFMT-params216091.h
SFMT-sse2.h
SFMT-sse2-msc.h)
# Group sources
GroupSources(${CMAKE_CURRENT_SOURCE_DIR})
add_library(sfmt STATIC ${SFMT_SOURCES})
target_include_directories(sfmt
INTERFACE
${CMAKE_CURRENT_SOURCE_DIR})
${CMAKE_CURRENT_SOURCE_DIR})
# using the standard Mersenne exponent 19937
target_compile_definitions(sfmt PUBLIC -DSFMT_MEXP=19937)
# enable SIMD instructions if available
include(CheckCCompilerFlag)
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(powerpc|ppc)64|(powerpc|ppc)64le")
check_c_compiler_flag("-maltivec" HAVE_ALTIVEC)
if (HAVE_ALTIVEC)
target_compile_options(sfmt PRIVATE -mabi=altivec -maltivec)
target_compile_definitions(sfmt PUBLIC -DHAVE_ALTIVEC)
else ()
message(WARNING "Altivec not available - performance will be poor!")
endif ()
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "arm|ARM")
check_c_compiler_flag(-mfpu=neon HAVE_NEON)
if (HAVE_NEON)
target_compile_options(sfmt PRIVATE -mfpu=neon -ftree-vectorize)
target_compile_definitions(sfmt PUBLIC -DHAVE_NEON)
else ()
message(WARNING "Neon not available - performance will be poor!")
endif ()
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64")
check_c_compiler_flag(-march=armv8-a+simd HAVE_NEON)
if (HAVE_NEON)
target_compile_options(sfmt PRIVATE -ftree-vectorize)
target_compile_definitions(sfmt PUBLIC -DHAVE_NEON)
else ()
message(WARNING "Neon not available - performance will be poor!")
endif ()
elseif (CMAKE_SYSTEM_PROCESSOR MATCHES "i686|amd64|x86_64|AMD64")
#SSE2 is always available
set(HAVE_SSE2 1)
if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
target_compile_options(sfmt PRIVATE -msse2)
endif ()
target_compile_definitions(sfmt PUBLIC -DHAVE_SSE2)
endif ()
set_target_properties(sfmt PROPERTIES LINKER_LANGUAGE CXX)
# inherit generic build options (e.g. fPIC)
target_link_libraries(sfmt PRIVATE acore-dependency-interface)
set_target_properties(sfmt
PROPERTIES
FOLDER
"deps")