xref: /aosp_15_r20/external/libcxx/lib/abi/CMakeLists.txt (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker
2*58b9f456SAndroid Build Coastguard Workerif (DEFINED TARGET_TRIPLE)
3*58b9f456SAndroid Build Coastguard Worker    if (TARGET_TRIPLE MATCHES "darwin")
4*58b9f456SAndroid Build Coastguard Worker        # Ignore the major, minor, and patchlevel versions of darwin targets.
5*58b9f456SAndroid Build Coastguard Worker        string(REGEX REPLACE "darwin[0-9]+\\.[0-9]+\\.[0-9]+" "darwin"
6*58b9f456SAndroid Build Coastguard Worker               GENERIC_TARGET_TRIPLE "${TARGET_TRIPLE}")
7*58b9f456SAndroid Build Coastguard Worker    elseif(TARGET_TRIPLE MATCHES "freebsd")
8*58b9f456SAndroid Build Coastguard Worker        # Ignore the major and minor versions of freebsd targets.
9*58b9f456SAndroid Build Coastguard Worker        string(REGEX REPLACE "freebsd[0-9]+\\.[0-9]+" "freebsd"
10*58b9f456SAndroid Build Coastguard Worker               GENERIC_TARGET_TRIPLE "${TARGET_TRIPLE}")
11*58b9f456SAndroid Build Coastguard Worker    else()
12*58b9f456SAndroid Build Coastguard Worker        set(GENERIC_TARGET_TRIPLE "${TARGET_TRIPLE}")
13*58b9f456SAndroid Build Coastguard Worker    endif()
14*58b9f456SAndroid Build Coastguard Workerendif()
15*58b9f456SAndroid Build Coastguard Worker
16*58b9f456SAndroid Build Coastguard Worker# Detect if we are building in the same configuration used to generate
17*58b9f456SAndroid Build Coastguard Worker# the abilist files.
18*58b9f456SAndroid Build Coastguard Workerset(ABILIST_FILE "${CMAKE_CURRENT_LIST_DIR}/${GENERIC_TARGET_TRIPLE}.v${LIBCXX_ABI_VERSION}.abilist")
19*58b9f456SAndroid Build Coastguard Workerset(SYMDIFF_EXE "${LIBCXX_SOURCE_DIR}/utils/sym_diff.py")
20*58b9f456SAndroid Build Coastguard Workerif (EXISTS "${ABILIST_FILE}"
21*58b9f456SAndroid Build Coastguard Worker    AND TARGET cxx_shared
22*58b9f456SAndroid Build Coastguard Worker    AND ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi" OR
23*58b9f456SAndroid Build Coastguard Worker         (APPLE AND "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default"))
24*58b9f456SAndroid Build Coastguard Worker    AND NOT LIBCXX_ABI_UNSTABLE)
25*58b9f456SAndroid Build Coastguard Worker    add_custom_target(check-cxx-abilist
26*58b9f456SAndroid Build Coastguard Worker            ${SYMDIFF_EXE} --only-stdlib-symbols --strict ${ABILIST_FILE}
27*58b9f456SAndroid Build Coastguard Worker            $<TARGET_SONAME_FILE:cxx_shared>
28*58b9f456SAndroid Build Coastguard Worker            DEPENDS cxx_shared
29*58b9f456SAndroid Build Coastguard Worker            COMMENT "Testing ABI compatibility...")
30*58b9f456SAndroid Build Coastguard Workerelse()
31*58b9f456SAndroid Build Coastguard Worker    message(STATUS "there is no pre-generated ABI list for the requested libc++ configuration. "
32*58b9f456SAndroid Build Coastguard Worker            "check-cxx-abilist target is not supported")
33*58b9f456SAndroid Build Coastguard Workerendif()
34