1
2if (DEFINED TARGET_TRIPLE)
3    # Ignore the minor and patchlevel versions of the darwin
4    # target.
5    string(REGEX REPLACE "darwin16\\.[0-9]\\.[0-9]" "darwin16"
6      GENERIC_TARGET_TRIPLE "${TARGET_TRIPLE}")
7endif()
8
9# Detect if we are building in the same configuration used to generate
10# the abilist files.
11if (DEFINED GENERIC_TARGET_TRIPLE
12    AND EXISTS "${CMAKE_CURRENT_LIST_DIR}/${GENERIC_TARGET_TRIPLE}.abilist"
13    AND TARGET cxx_shared
14    AND ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi" OR
15         (APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default"))
16    AND NOT LIBCXX_ABI_UNSTABLE
17    AND LIBCXX_ABI_VERSION EQUAL "1")
18    set(LIBCXX_HAS_ABILIST_CONFIGURATION 1 CACHE INTERNAL "")
19else()
20    if (NOT DEFINED LIBCXX_HAS_ABILIST_CONFIGURATION)
21        message(STATUS "libc++ configuration differs from the abilist configuration. "
22                "check-cxx-abilist target is not supported")
23    endif()
24    set(LIBCXX_HAS_ABILIST_CONFIGURATION 0 CACHE INTERNAL "")
25endif()
26
27
28if (LIBCXX_HAS_ABILIST_CONFIGURATION)
29    set(ABILIST_FILE "${CMAKE_CURRENT_LIST_DIR}/${GENERIC_TARGET_TRIPLE}.abilist")
30    set(SYMDIFF_EXE "${LIBCXX_SOURCE_DIR}/utils/sym_diff.py")
31    add_custom_target(check-cxx-abilist
32            ${SYMDIFF_EXE} --only-stdlib-symbols --strict ${ABILIST_FILE}
33            $<TARGET_SONAME_FILE:cxx_shared>
34            DEPENDS cxx_shared
35            COMMENT "Testing ABI compatibility...")
36endif()
37