@@ -9,11 +9,6 @@ set (CMAKE_CXX_STANDARD 11) # for constexpr specifier and other goodies
99set (CMAKE_CXX_STANDARD_REQUIRED True )
1010set (CMAKE_C_STANDARD 99)
1111set (CMAKE_C_STANDARD_REQUIRED True )
12- if (NOT CMAKE_BUILD_TYPE )
13- message (STATUS "No build type selected, default to Release" )
14- set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
15- endif ()
16- MESSAGE ( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} )
1712
1813list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR} /cmake_modules" )
1914include (AppendCompilerFlags)
@@ -71,14 +66,31 @@ target_sources(FastPFOR PRIVATE
7166 src/streamvbyte.c
7267)
7368set_target_properties (FastPFOR PROPERTIES POSITION_INDEPENDENT_CODE TRUE )
69+
70+ option (FASTPFOR_SANITIZE "Use sanitizers" OFF )
71+
72+ if (FASTPFOR_SANITIZE)
73+ message (STATUS "Enabling Sanitizers" )
74+ target_compile_options (FastPFOR PUBLIC -fsanitize=address -fno-omit-frame-pointer -fno-sanitize-recover=all )
75+ target_compile_definitions (FastPFOR PUBLIC ASAN_OPTIONS=detect_leaks=1)
76+ target_link_libraries (FastPFOR PUBLIC -fsanitize=address -fno-omit-frame-pointer -fno-sanitize-recover=all )
77+ endif ()
78+
79+ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES AND NOT FASTPFOR_SANITIZE)
80+ message (STATUS "No build type selected, default to Release" )
81+ set (CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
82+ endif ()
83+ MESSAGE ( STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE} )
84+
85+
7486if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "AppleClang" )
7587 target_compile_options (FastPFOR PRIVATE -Wall -Wextra)
7688endif ()
7789include (CheckCXXCompilerFlag)
7890unset (FASTPFOR_COMPILER_SUPPORTS_MARCH_NATIVE CACHE )
7991CHECK_CXX_COMPILER_FLAG(-march=native FASTPFOR_COMPILER_SUPPORTS_MARCH_NATIVE)
8092if (FASTPFOR_COMPILER_SUPPORTS_MARCH_NATIVE)
81- add_compile_options ( -march=native)
93+ target_compile_options (FastPFOR PRIVATE -march=native)
8294else ()
8395 message (STATUS "native target not supported" )
8496endif ()
@@ -161,9 +173,9 @@ else()
161173 target_link_libraries (inmemorybenchmarksnappy FastPFOR ${snappy_LIBRARIES} )
162174endif ()
163175
164- option (WITH_TEST "Build with Google Test" ON )
176+ option (FASTPFOR_WITH_TEST "Build with Google Test" ON )
165177
166- if (WITH_TEST )
178+ if (FASTPFOR_WITH_TEST )
167179 CPMAddPackage(
168180 NAME googletest
169181 GITHUB_REPOSITORY google/googletest
0 commit comments