Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / lib / memprof / tests / CMakeLists.txt
blobf812bd1f86ff8facb0c8a0e2f76701cfb7102d8f
1 include(CheckCXXCompilerFlag)
2 include(CompilerRTCompile)
3 include(CompilerRTLink)
5 set(MEMPROF_UNITTEST_CFLAGS
6   ${COMPILER_RT_UNITTEST_CFLAGS}
7   ${COMPILER_RT_GTEST_CFLAGS}
8   ${COMPILER_RT_GMOCK_CFLAGS}
9   ${SANITIZER_TEST_CXX_CFLAGS}
10   -I${COMPILER_RT_SOURCE_DIR}/lib/
11   -DSANITIZER_COMMON_NO_REDEFINE_BUILTINS
12   -O2
13   -g
14   -fno-rtti
15   -Wno-pedantic
16   -fno-omit-frame-pointer)
18 # Suppress warnings for gmock variadic macros for clang and gcc respectively.
19 append_list_if(SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG -Wno-gnu-zero-variadic-macro-arguments MEMPROF_UNITTEST_CFLAGS)
20 append_list_if(COMPILER_RT_HAS_WVARIADIC_MACROS_FLAG -Wno-variadic-macros MEMPROF_UNITTEST_CFLAGS)
22 file(GLOB MEMPROF_HEADERS ../*.h)
24 set(MEMPROF_SOURCES
25   ../memprof_mibmap.cpp
26   ../memprof_rawprofile.cpp)
28 set(MEMPROF_UNITTESTS
29   rawprofile.cpp
30   driver.cpp)
32 include_directories(../../../include)
34 set(MEMPROF_UNIT_TEST_HEADERS
35   ${MEMPROF_HEADERS})
37 set(MEMPROF_UNITTEST_LINK_FLAGS
38   ${COMPILER_RT_UNITTEST_LINK_FLAGS})
40 if(NOT WIN32)
41   list(APPEND MEMPROF_UNITTEST_LINK_FLAGS -pthread)
42 endif()
44 set(MEMPROF_UNITTEST_LINK_LIBRARIES
45   ${COMPILER_RT_UNWINDER_LINK_LIBS}
46   ${SANITIZER_TEST_CXX_LIBRARIES})
47 list(APPEND MEMPROF_UNITTEST_LINK_LIBRARIES "dl")
49 if(COMPILER_RT_DEFAULT_TARGET_ARCH IN_LIST MEMPROF_SUPPORTED_ARCH)
50   # MemProf unit tests are only run on the host machine.
51   set(arch ${COMPILER_RT_DEFAULT_TARGET_ARCH})
53   add_executable(MemProfUnitTests 
54     ${MEMPROF_UNITTESTS}
55     ${COMPILER_RT_GTEST_SOURCE}
56     ${COMPILER_RT_GMOCK_SOURCE}
57     ${MEMPROF_SOURCES}
58     $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
59     $<TARGET_OBJECTS:RTSanitizerCommonCoverage.${arch}>
60     $<TARGET_OBJECTS:RTSanitizerCommonLibc.${arch}>
61     $<TARGET_OBJECTS:RTSanitizerCommonSymbolizer.${arch}>
62     $<TARGET_OBJECTS:RTSanitizerCommonSymbolizerInternal.${arch}>)
63   set_target_compile_flags(MemProfUnitTests ${MEMPROF_UNITTEST_CFLAGS})
64   set_target_link_flags(MemProfUnitTests ${MEMPROF_UNITTEST_LINK_FLAGS})
65   target_link_libraries(MemProfUnitTests ${MEMPROF_UNITTEST_LINK_LIBRARIES})
67   if (TARGET cxx-headers OR HAVE_LIBCXX)
68     add_dependencies(MemProfUnitTests cxx-headers)
69   endif()
71   set_target_properties(MemProfUnitTests PROPERTIES
72     RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
73 endif()