aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/simdutf/src/CMakeLists.txt
blob: 7a4a5c93b0a898bda84e63e625ecdaa4378f006d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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()