1 include(CompilerRTCompile)
3 set(NSAN_UNITTEST_CFLAGS
4 ${COMPILER_RT_UNITTEST_CFLAGS}
5 ${COMPILER_RT_GTEST_CFLAGS}
6 ${SANITIZER_TEST_CXX_CFLAGS}
7 -I${COMPILER_RT_SOURCE_DIR}/include
8 -I${COMPILER_RT_SOURCE_DIR}/lib
9 -DSANITIZER_COMMON_REDEFINE_BUILTINS_IN_STD
12 -fno-omit-frame-pointer)
14 set(NSAN_UNITTEST_LINK_FLAGS
15 ${COMPILER_RT_UNITTEST_LINK_FLAGS}
16 ${COMPILER_RT_UNWINDER_LINK_LIBS}
17 ${SANITIZER_TEST_CXX_LIBRARIES})
18 set(NSAN_UNITTEST_INSTRUMENTED_LINK_FLAGS ${NSAN_UNITTEST_LINK_FLAGS})
19 list(APPEND NSAN_UNITTEST_INSTRUMENTED_LINK_FLAGS -fsanitize=numerical)
21 file(GLOB NSAN_HEADERS ../*.h)
24 nsan_unit_test_main.cpp)
26 add_custom_target(NsanUnitTests)
28 if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST NSAN_SUPPORTED_ARCH)
29 # NSan unit tests are only run on the host machine.
30 set(arch ${COMPILER_RT_DEFAULT_TARGET_ARCH})
33 generate_compiler_rt_tests(NsanTestObjects
34 NsanUnitTests "Nsan-${arch}-Test" ${arch}
35 SOURCES ${NSAN_UNITTESTS} ${COMPILER_RT_GTEST_SOURCE}
36 DEPS ${NSAN_UNIT_TEST_HEADERS}
37 CFLAGS ${NSAN_UNITTEST_CFLAGS}
38 LINK_FLAGS ${NSAN_UNITTEST_INSTRUMENTED_LINK_FLAGS})
39 set_target_properties(NsanUnitTests PROPERTIES
40 RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})