[Sanitizer] CMake build rules for unittests: depend on headers when compiling a file with custom clang.
llvm-svn: 170897
This commit is contained in:
parent
b3bf5651bd
commit
e30a84f08f
|
|
@ -16,6 +16,11 @@ include(CompilerRTUnittests)
|
|||
include_directories(..)
|
||||
include_directories(../..)
|
||||
|
||||
set(ASAN_UNITTEST_HEADERS
|
||||
asan_mac_test.h
|
||||
asan_test_config.h
|
||||
asan_test_utils.h)
|
||||
|
||||
set(ASAN_UNITTEST_COMMON_CFLAGS
|
||||
${COMPILER_RT_GTEST_INCLUDE_CFLAGS}
|
||||
-I${COMPILER_RT_SOURCE_DIR}/include
|
||||
|
|
@ -89,6 +94,7 @@ macro(asan_compile obj_list source arch)
|
|||
clang_compile(${output_obj} ${source}
|
||||
CFLAGS ${ARGN} ${TARGET_CFLAGS}
|
||||
DEPS gtest ${ASAN_RUNTIME_LIBRARIES}
|
||||
${ASAN_UNITTEST_HEADERS}
|
||||
${ASAN_BLACKLIST_FILE})
|
||||
list(APPEND ${obj_list} ${output_obj})
|
||||
endmacro()
|
||||
|
|
|
|||
|
|
@ -20,6 +20,30 @@ set(SANITIZER_SOURCES
|
|||
sanitizer_win.cc
|
||||
)
|
||||
|
||||
# Explicitly list all sanitizer_common headers. Not all of these are
|
||||
# included in sanitizer_common source files, but we need to depend on
|
||||
# headers when building our custom unit tests.
|
||||
set(SANITIZER_HEADERS
|
||||
sanitizer_allocator.h
|
||||
sanitizer_atomic_clang.h
|
||||
sanitizer_atomic_msvc.h
|
||||
sanitizer_atomic.h
|
||||
sanitizer_common.h
|
||||
sanitizer_common_interceptors.h
|
||||
sanitizer_flags.h
|
||||
sanitizer_internal_defs.h
|
||||
sanitizer_libc.h
|
||||
sanitizer_list.h
|
||||
sanitizer_mutex.h
|
||||
sanitizer_placement_new.h
|
||||
sanitizer_platform_interceptors.h
|
||||
sanitizer_procmaps.h
|
||||
sanitizer_report_decorator.h
|
||||
sanitizer_stackdepot.h
|
||||
sanitizer_stacktrace.h
|
||||
sanitizer_symbolizer.h
|
||||
)
|
||||
|
||||
set(SANITIZER_CFLAGS ${SANITIZER_COMMON_CFLAGS})
|
||||
|
||||
set(SANITIZER_RUNTIME_LIBRARIES)
|
||||
|
|
|
|||
|
|
@ -12,6 +12,11 @@ set(SANITIZER_UNITTESTS
|
|||
sanitizer_test_main.cc
|
||||
)
|
||||
|
||||
set(SANITIZER_TEST_HEADERS)
|
||||
foreach(header ${SANITIZER_HEADERS})
|
||||
list(APPEND SANITIZER_TEST_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/../${header})
|
||||
endforeach()
|
||||
|
||||
include_directories(..)
|
||||
include_directories(../..)
|
||||
|
||||
|
|
@ -55,7 +60,8 @@ macro(add_sanitizer_tests_for_arch arch)
|
|||
set(output_obj "${basename}.${arch}.o")
|
||||
clang_compile(${output_obj} ${source}
|
||||
CFLAGS ${SANITIZER_TEST_CFLAGS}
|
||||
DEPS gtest ${SANITIZER_RUNTIME_LIBRARIES})
|
||||
DEPS gtest ${SANITIZER_RUNTIME_LIBRARIES}
|
||||
${SANITIZER_TEST_HEADERS})
|
||||
list(APPEND SANITIZER_TEST_OBJECTS ${output_obj})
|
||||
endforeach()
|
||||
get_sanitizer_common_lib_for_arch(${arch} SANITIZER_COMMON_LIB
|
||||
|
|
|
|||
Loading…
Reference in New Issue