aboutsummaryrefslogtreecommitdiff
path: root/dep/SFMT/CMakeLists.txt
diff options
context:
space:
mode:
authordaMaex <damaex@live.de>2019-10-30 10:42:08 +0100
committerShauren <shauren.trinity@gmail.com>2021-12-19 00:12:41 +0100
commit08b40733a58da23ced34915cb67c0ef24e6e9059 (patch)
treebfbc36e2e6396cfde3accb05f970beb16063e44c /dep/SFMT/CMakeLists.txt
parent5ae84caf23e42f1005cfa0437896a86e1cb40fd1 (diff)
Dep/SFMT: updated to newest upstream version from https://github.com/MersenneTwister-Lab/SFMT
* only needed files added * used CMake and SFMTRand from https://github.com/TrinityCore/TrinityCore/pull/23240 (Thank you Artox) (cherry picked from commit 4e0279b0e48c9992842010b9f3f132e54a460128)
Diffstat (limited to 'dep/SFMT/CMakeLists.txt')
-rw-r--r--dep/SFMT/CMakeLists.txt65
1 files changed, 64 insertions, 1 deletions
diff --git a/dep/SFMT/CMakeLists.txt b/dep/SFMT/CMakeLists.txt
index 1348d3203b1..84f5cc6afc4 100644
--- a/dep/SFMT/CMakeLists.txt
+++ b/dep/SFMT/CMakeLists.txt
@@ -1,4 +1,5 @@
# This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
+# Copyright 2019 Josua Mayer <josua.mayer97@gmail.com>
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
@@ -8,8 +9,70 @@
# 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)
+
+add_library(sfmt STATIC ${SFMT_SOURCES})
target_include_directories(sfmt
INTERFACE
${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 ()
+
+# inherit trinitycore generic build options (e.g. fPIC)
+target_link_libraries(sfmt PRIVATE trinity-dependency-interface)