diff options
author | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-11-29 11:31:35 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@rspamd.com> | 2024-11-29 11:31:35 +0000 |
commit | b39a9f52ed3f33082f13f51678d053ee80a2e1f4 (patch) | |
tree | 2144a18d85681df09f83e255f2e5c6d04e61e878 /contrib/simdutf/src/CMakeLists.txt | |
parent | 6c0223b32b8fcb6621fa64197214abb400a09f52 (diff) | |
download | rspamd-b39a9f52ed3f33082f13f51678d053ee80a2e1f4.tar.gz rspamd-b39a9f52ed3f33082f13f51678d053ee80a2e1f4.zip |
[Rework] Replace fastutf with simdutf
Simdutf is faster and has way better support of the architectures (especially
when it comes to non-x86 stuff). Hence, it is a good idea to use it instead
of the non-supported fastutf8 stuff.
Diffstat (limited to 'contrib/simdutf/src/CMakeLists.txt')
-rw-r--r-- | contrib/simdutf/src/CMakeLists.txt | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/contrib/simdutf/src/CMakeLists.txt b/contrib/simdutf/src/CMakeLists.txt new file mode 100644 index 000000000..7a4a5c93b --- /dev/null +++ b/contrib/simdutf/src/CMakeLists.txt @@ -0,0 +1,46 @@ +add_library(simdutf-include-source INTERFACE) +target_include_directories(simdutf-include-source INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>) +add_library(simdutf-source INTERFACE) +target_sources(simdutf-source INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>/simdutf.cpp) +target_link_libraries(simdutf-source INTERFACE simdutf-include-source) +add_library(simdutf STATIC simdutf.cpp ../../../src/libutil/cxx/rspamd-simdutf.cxx) +target_include_directories(simdutf PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> ) +target_include_directories(simdutf PUBLIC "$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>") + +if(MSVC) + if("${MSVC_TOOLSET_VERSION}" STREQUAL "140") + target_compile_options(simdutf PRIVATE /W0 /sdl) + set(SIMDUTF_LEGACY_VISUAL_STUDIO TRUE) + else() + target_compile_options(simdutf PRIVATE /WX /W3 /sdl /w34714) # https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-4-c4714?view=vs-2019 + endif() +else(MSVC) + if(NOT WIN32) + target_compile_options(simdutf INTERFACE -fPIC) + endif() + target_compile_options(simdutf PRIVATE -Wall -Wextra -Weffc++) + target_compile_options(simdutf PRIVATE -Wfatal-errors -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wconversion -Wno-sign-conversion -Wunused-function) +endif(MSVC) + +# workaround for GNU GCC poor AVX load/store code generation +if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_SYSTEM_PROCESSOR MATCHES "^(i.86|x86(_64)?)$")) + target_compile_options(simdutf PRIVATE -mno-avx256-split-unaligned-load -mno-avx256-split-unaligned-store) +endif() + +if(SIMDUTF_ALWAYS_INCLUDE_FALLBACK) + message(STATUS "SIMDUTF_ALWAYS_INCLUDE_FALLBACK is set to ${SIMDUTF_ALWAYS_INCLUDE_FALLBACK}") + target_compile_definitions(simdutf PRIVATE SIMDUTF_IMPLEMENTATION_FALLBACK=1) +endif() + +if(SIMDUTF_SANITIZE) + target_compile_options(simdutf PUBLIC -fsanitize=address -fno-omit-frame-pointer -fno-sanitize-recover=all) + target_compile_definitions(simdutf PUBLIC ASAN_OPTIONS=detect_leaks=1) + target_link_libraries(simdutf PUBLIC -fsanitize=address -fno-omit-frame-pointer -fno-sanitize-recover=all) +endif() +if(SIMDUTF_SANITIZE_UNDEFINED) + target_compile_options(simdutf PUBLIC -fsanitize=undefined -fno-sanitize-recover=all) + target_link_libraries(simdutf PUBLIC -fsanitize=undefined) +endif() +if(MSVC AND BUILD_SHARED_LIBS) + set(SIMDUTF_WINDOWS_DLL TRUE) +endif() |