2 #===============================================================================
3 # Add an ABI library if appropriate
4 #===============================================================================
7 # _setup_abi: Set up the build to use an ABI library
10 # abidefines: A list of defines needed to compile libc++ with the ABI library
11 # abishared : The shared ABI library to link against.
12 # abistatic : The static ABI library to link against.
13 # abifiles : A list of files (which may be relative paths) to copy into the
14 # libc++ build tree for the build. These files will be copied
15 # twice: once into include/, so the libc++ build itself can find
16 # them, and once into include/c++/v1, so that a clang built into
17 # the same build area will find them. These files will also be
18 # installed alongside the libc++ headers.
19 # abidirs : A list of relative paths to create under an include directory
20 # in the libc++ build directory.
23 macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs)
24 list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines})
25 set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}"
27 "Paths to C++ ABI header directories separated by ';'." FORCE
29 set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_CXX_ABI_LIBRARY_PATH}"
31 "Paths to C++ ABI library directory"
33 set(LIBCXX_CXX_SHARED_ABI_LIBRARY ${abishared})
34 set(LIBCXX_CXX_STATIC_ABI_LIBRARY ${abistatic})
35 set(LIBCXX_ABILIB_FILES ${abifiles})
37 foreach(fpath ${LIBCXX_ABILIB_FILES})
39 foreach(incpath ${LIBCXX_CXX_ABI_INCLUDE_PATHS})
40 message(STATUS "Looking for ${fpath} in ${incpath}")
41 if (EXISTS "${incpath}/${fpath}")
43 message(STATUS "Looking for ${fpath} in ${incpath} - found")
44 get_filename_component(dstdir ${fpath} PATH)
45 get_filename_component(ifile ${fpath} NAME)
46 set(src ${incpath}/${fpath})
48 set(dst ${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}/${ifile})
49 add_custom_command(OUTPUT ${dst}
51 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
52 COMMENT "Copying C++ ABI header ${fpath}...")
53 list(APPEND abilib_headers "${dst}")
55 if (LIBCXX_HEADER_DIR)
56 set(dst "${LIBCXX_HEADER_DIR}/include/c++/v1/${dstdir}/${fpath}")
57 add_custom_command(OUTPUT ${dst}
59 COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
60 COMMENT "Copying C++ ABI header ${fpath}...")
61 list(APPEND abilib_headers "${dst}")
64 if (LIBCXX_INSTALL_HEADERS)
65 install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
66 DESTINATION ${LIBCXX_INSTALL_HEADER_PREFIX}include/c++/v1/${dstdir}
68 PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
72 message(STATUS "Looking for ${fpath} in ${incpath} - not found")
76 message(WARNING "Failed to find ${fpath} in ${LIBCXX_CXX_ABI_INCLUDE_PATHS}")
80 include_directories("${LIBCXX_BINARY_INCLUDE_DIR}")
81 add_custom_target(cxx_abi_headers ALL DEPENDS ${abilib_headers})
82 set(LIBCXX_CXX_ABI_HEADER_TARGET "cxx_abi_headers")
86 # Configure based on the selected ABI library.
87 if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR
88 "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libsupc++")
89 set(_LIBSUPCXX_INCLUDE_FILES
90 cxxabi.h bits/c++config.h bits/os_defines.h bits/cpu_defines.h
91 bits/cxxabi_tweaks.h bits/cxxabi_forced.h
93 if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++")
94 set(_LIBSUPCXX_DEFINES "-DLIBSTDCXX")
95 set(_LIBSUPCXX_LIBNAME stdc++)
97 set(_LIBSUPCXX_DEFINES "")
98 set(_LIBSUPCXX_LIBNAME supc++)
101 "-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}"
102 "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits"
104 elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
105 if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS)
106 set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_SOURCE_DIR}/../libcxxabi/include")
109 if(LIBCXX_STANDALONE_BUILD AND NOT (LIBCXX_CXX_ABI_INTREE OR HAVE_LIBCXXABI))
113 set(shared cxxabi_shared)
114 set(static cxxabi_static)
118 "-DLIBCXX_BUILDING_LIBCXXABI"
119 "${shared}" "${static}" "cxxabi.h;__cxxabi_config.h" "")
120 elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
121 if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS)
122 set(LIBCXX_CXX_ABI_INCLUDE_PATHS "/usr/include/c++/v1")
126 "cxxrt" "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
128 elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "vcruntime")
130 elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
131 list(APPEND LIBCXX_COMPILE_FLAGS "-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY")
132 elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default")
136 "Unsupported c++ abi: '${LIBCXX_CXX_ABI_LIBNAME}'. \
137 Currently libstdc++, libsupc++, libcxxabi, libcxxrt, default and none are
138 supported for c++ abi."