11cmake_minimum_required (VERSION 3.10 )
22
33project (SerializatonTwitterBenchmark) # Name your project
4- if (NOT CMAKE_BUILD_TYPE )
5- message (STATUS "No build type selected, default to Release" )
6- set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
7- endif ()
84
95# Set C++ standard to C++17 or higher if needed
106#set(CMAKE_CXX_STANDARD 23)
@@ -14,6 +10,32 @@ endif()
1410set (CMAKE_C_COMPILER clang)
1511set (CMAKE_CXX_COMPILER clang++)
1612
13+
14+ option (SIMDJSON_SANITIZE_MEMORY "Sanitize memory" OFF )
15+
16+ if (SIMDJSON_SANITIZE_MEMORY)
17+ message (STATUS "Setting the memory sanitizer." )
18+ add_compile_options (
19+ -fsanitize=memory -fno-sanitize-recover=all
20+ )
21+ link_libraries (
22+ -fsanitize=memory -fno-sanitize-recover=all
23+ )
24+ endif ()
25+
26+ if (NOT CMAKE_BUILD_TYPE )
27+ if (SIMDJSON_SANITIZE OR SIMDJSON_SANITIZE_UNDEFINED)
28+ message (STATUS "No build type selected and you have enabled the sanitizer, \
29+ default to Debug. Consider setting CMAKE_BUILD_TYPE." )
30+ message (STATUS "Setting debug optimization flag to -O1 to help sanitizer." )
31+ set (CMAKE_CXX_FLAGS_DEBUG "-O1" CACHE STRING "" FORCE )
32+ set (CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE )
33+ else ()
34+ message (STATUS "No build type selected, default to Release" )
35+ set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE )
36+ endif ()
37+ endif ()
38+
1739# set(CMAKE_OSX_ARCHITECTURES "arm64")
1840
1941# if(CMAKE_BUILD_TYPE STREQUAL "Debug")
0 commit comments