1add_custom_target(safestack)
2
3set(SAFESTACK_SOURCES safestack.cc)
4
5include_directories(..)
6
7set(SAFESTACK_CFLAGS ${SANITIZER_COMMON_CFLAGS})
8
9if(APPLE)
10  # Build universal binary on APPLE.
11  add_compiler_rt_runtime(clang_rt.safestack
12    STATIC
13    OS osx
14    ARCHS ${SAFESTACK_SUPPORTED_ARCH}
15    SOURCES ${SAFESTACK_SOURCES}
16            $<TARGET_OBJECTS:RTInterception.osx>
17            $<TARGET_OBJECTS:RTSanitizerCommon.osx>
18            $<TARGET_OBJECTS:RTSanitizerCommonNoLibc.osx>
19    CFLAGS ${SAFESTACK_CFLAGS}
20    PARENT_TARGET safestack)
21else()
22  # Otherwise, build separate libraries for each target.
23  foreach(arch ${SAFESTACK_SUPPORTED_ARCH})
24    add_compiler_rt_runtime(clang_rt.safestack
25      STATIC
26      ARCHS ${arch}
27      SOURCES ${SAFESTACK_SOURCES}
28              $<TARGET_OBJECTS:RTInterception.${arch}>
29              $<TARGET_OBJECTS:RTSanitizerCommon.${arch}>
30              $<TARGET_OBJECTS:RTSanitizerCommonNoLibc.${arch}>
31      CFLAGS ${SAFESTACK_CFLAGS}
32      PARENT_TARGET safestack)
33  endforeach()
34endif()
35