2014-10-18 09:15:17 +08:00
|
|
|
#===============================================================================
|
|
|
|
# Add an ABI library if appropriate
|
|
|
|
#===============================================================================
|
|
|
|
|
2022-01-16 14:00:29 +08:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
2014-10-18 09:15:17 +08:00
|
|
|
#
|
|
|
|
# _setup_abi: Set up the build to use an ABI library
|
|
|
|
#
|
|
|
|
# Parameters:
|
|
|
|
# abidefines: A list of defines needed to compile libc++ with the ABI library
|
2019-04-03 09:33:14 +08:00
|
|
|
# abishared : The shared ABI library to link against.
|
|
|
|
# abistatic : The static ABI library to link against.
|
2014-10-18 09:15:17 +08:00
|
|
|
# abifiles : A list of files (which may be relative paths) to copy into the
|
2017-01-05 10:55:10 +08:00
|
|
|
# libc++ build tree for the build. These files will be copied
|
|
|
|
# twice: once into include/, so the libc++ build itself can find
|
|
|
|
# them, and once into include/c++/v1, so that a clang built into
|
|
|
|
# the same build area will find them. These files will also be
|
2014-10-18 09:15:17 +08:00
|
|
|
# installed alongside the libc++ headers.
|
|
|
|
# abidirs : A list of relative paths to create under an include directory
|
|
|
|
# in the libc++ build directory.
|
|
|
|
#
|
2017-01-17 04:47:35 +08:00
|
|
|
|
2019-04-03 09:33:14 +08:00
|
|
|
macro(setup_abi_lib abidefines abishared abistatic abifiles abidirs)
|
2014-11-16 01:25:23 +08:00
|
|
|
list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines})
|
2015-03-20 04:59:45 +08:00
|
|
|
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}"
|
2014-10-18 09:15:17 +08:00
|
|
|
CACHE PATH
|
|
|
|
"Paths to C++ ABI header directories separated by ';'." FORCE
|
|
|
|
)
|
2016-05-28 07:05:37 +08:00
|
|
|
set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_CXX_ABI_LIBRARY_PATH}"
|
|
|
|
CACHE PATH
|
|
|
|
"Paths to C++ ABI library directory"
|
|
|
|
)
|
2019-04-03 09:33:14 +08:00
|
|
|
set(LIBCXX_CXX_SHARED_ABI_LIBRARY ${abishared})
|
|
|
|
set(LIBCXX_CXX_STATIC_ABI_LIBRARY ${abistatic})
|
2014-10-18 09:15:17 +08:00
|
|
|
set(LIBCXX_ABILIB_FILES ${abifiles})
|
|
|
|
|
|
|
|
foreach(fpath ${LIBCXX_ABILIB_FILES})
|
|
|
|
set(found FALSE)
|
2015-03-20 04:59:45 +08:00
|
|
|
foreach(incpath ${LIBCXX_CXX_ABI_INCLUDE_PATHS})
|
2020-03-12 02:00:46 +08:00
|
|
|
message(STATUS "Looking for ${fpath} in ${incpath}")
|
2014-10-18 09:15:17 +08:00
|
|
|
if (EXISTS "${incpath}/${fpath}")
|
|
|
|
set(found TRUE)
|
2020-03-12 02:00:46 +08:00
|
|
|
message(STATUS "Looking for ${fpath} in ${incpath} - found")
|
2014-10-18 09:15:17 +08:00
|
|
|
get_filename_component(dstdir ${fpath} PATH)
|
|
|
|
get_filename_component(ifile ${fpath} NAME)
|
2018-06-12 11:10:02 +08:00
|
|
|
set(src ${incpath}/${fpath})
|
|
|
|
|
2018-10-04 13:38:53 +08:00
|
|
|
set(dst ${LIBCXX_BINARY_INCLUDE_DIR}/${dstdir}/${ifile})
|
2018-06-12 11:10:02 +08:00
|
|
|
add_custom_command(OUTPUT ${dst}
|
|
|
|
DEPENDS ${src}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
|
|
|
|
COMMENT "Copying C++ ABI header ${fpath}...")
|
|
|
|
list(APPEND abilib_headers "${dst}")
|
|
|
|
|
2020-06-27 00:08:59 +08:00
|
|
|
# TODO: libc++ shouldn't be responsible for copying the libc++abi
|
|
|
|
# headers into the right location.
|
2021-04-28 14:30:53 +08:00
|
|
|
set(dst "${LIBCXX_GENERATED_INCLUDE_DIR}/${dstdir}/${fpath}")
|
2020-06-27 00:08:59 +08:00
|
|
|
add_custom_command(OUTPUT ${dst}
|
|
|
|
DEPENDS ${src}
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${src} ${dst}
|
|
|
|
COMMENT "Copying C++ ABI header ${fpath}...")
|
|
|
|
list(APPEND abilib_headers "${dst}")
|
2018-06-12 11:10:02 +08:00
|
|
|
|
2015-08-27 04:18:21 +08:00
|
|
|
if (LIBCXX_INSTALL_HEADERS)
|
2017-01-17 04:47:35 +08:00
|
|
|
install(FILES "${LIBCXX_BINARY_INCLUDE_DIR}/${fpath}"
|
2022-01-16 14:00:29 +08:00
|
|
|
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/c++/v1/${dstdir}"
|
2017-11-26 07:39:17 +08:00
|
|
|
COMPONENT cxx-headers
|
2015-08-27 04:18:21 +08:00
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
|
|
|
)
|
|
|
|
endif()
|
2020-03-12 02:00:46 +08:00
|
|
|
else()
|
|
|
|
message(STATUS "Looking for ${fpath} in ${incpath} - not found")
|
2014-10-18 09:15:17 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if (NOT found)
|
2020-03-12 02:00:46 +08:00
|
|
|
message(WARNING "Failed to find ${fpath} in ${LIBCXX_CXX_ABI_INCLUDE_PATHS}")
|
2014-10-18 09:15:17 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2017-01-17 04:47:35 +08:00
|
|
|
include_directories("${LIBCXX_BINARY_INCLUDE_DIR}")
|
2018-06-12 14:58:06 +08:00
|
|
|
add_custom_target(cxx_abi_headers ALL DEPENDS ${abilib_headers})
|
|
|
|
set(LIBCXX_CXX_ABI_HEADER_TARGET "cxx_abi_headers")
|
2014-10-18 09:15:17 +08:00
|
|
|
endmacro()
|
|
|
|
|
2015-07-31 06:30:34 +08:00
|
|
|
|
|
|
|
# Configure based on the selected ABI library.
|
2014-10-18 09:15:17 +08:00
|
|
|
if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR
|
|
|
|
"${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libsupc++")
|
|
|
|
set(_LIBSUPCXX_INCLUDE_FILES
|
|
|
|
cxxabi.h bits/c++config.h bits/os_defines.h bits/cpu_defines.h
|
|
|
|
bits/cxxabi_tweaks.h bits/cxxabi_forced.h
|
|
|
|
)
|
|
|
|
if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++")
|
|
|
|
set(_LIBSUPCXX_DEFINES "-DLIBSTDCXX")
|
|
|
|
set(_LIBSUPCXX_LIBNAME stdc++)
|
|
|
|
else()
|
|
|
|
set(_LIBSUPCXX_DEFINES "")
|
|
|
|
set(_LIBSUPCXX_LIBNAME supc++)
|
|
|
|
endif()
|
2015-03-20 04:59:45 +08:00
|
|
|
setup_abi_lib(
|
2014-10-18 09:15:17 +08:00
|
|
|
"-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}"
|
2019-04-03 09:33:14 +08:00
|
|
|
"${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits"
|
2014-10-18 09:15:17 +08:00
|
|
|
)
|
|
|
|
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
|
2020-06-19 00:07:49 +08:00
|
|
|
if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS)
|
|
|
|
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_SOURCE_DIR}/../libcxxabi/include")
|
|
|
|
endif()
|
2020-04-02 21:34:02 +08:00
|
|
|
|
2020-04-04 02:08:53 +08:00
|
|
|
if(LIBCXX_STANDALONE_BUILD AND NOT (LIBCXX_CXX_ABI_INTREE OR HAVE_LIBCXXABI))
|
2020-04-02 21:34:02 +08:00
|
|
|
set(shared c++abi)
|
|
|
|
set(static c++abi)
|
|
|
|
else()
|
|
|
|
set(shared cxxabi_shared)
|
|
|
|
set(static cxxabi_static)
|
|
|
|
endif()
|
|
|
|
|
2019-04-03 09:33:14 +08:00
|
|
|
setup_abi_lib(
|
|
|
|
"-DLIBCXX_BUILDING_LIBCXXABI"
|
2020-04-02 21:34:02 +08:00
|
|
|
"${shared}" "${static}" "cxxabi.h;__cxxabi_config.h" "")
|
2014-10-18 09:15:17 +08:00
|
|
|
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
|
2020-06-19 00:07:49 +08:00
|
|
|
if(NOT LIBCXX_CXX_ABI_INCLUDE_PATHS)
|
|
|
|
set(LIBCXX_CXX_ABI_INCLUDE_PATHS "/usr/include/c++/v1")
|
|
|
|
endif()
|
2021-02-16 01:22:01 +08:00
|
|
|
# libcxxrt does not provide aligned new and delete operators
|
|
|
|
set(LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS ON)
|
2019-04-03 09:33:14 +08:00
|
|
|
setup_abi_lib(
|
|
|
|
"-DLIBCXXRT"
|
|
|
|
"cxxrt" "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
|
2014-10-18 09:15:17 +08:00
|
|
|
)
|
2017-01-17 04:47:35 +08:00
|
|
|
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "vcruntime")
|
2020-05-02 01:10:06 +08:00
|
|
|
# Nothing to do
|
2017-01-03 09:18:48 +08:00
|
|
|
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none")
|
|
|
|
list(APPEND LIBCXX_COMPILE_FLAGS "-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY")
|
|
|
|
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default")
|
2020-05-02 01:10:06 +08:00
|
|
|
# Nothing to do
|
2017-01-03 09:18:48 +08:00
|
|
|
else()
|
2014-10-18 09:15:17 +08:00
|
|
|
message(FATAL_ERROR
|
2017-01-03 09:18:48 +08:00
|
|
|
"Unsupported c++ abi: '${LIBCXX_CXX_ABI_LIBNAME}'. \
|
|
|
|
Currently libstdc++, libsupc++, libcxxabi, libcxxrt, default and none are
|
|
|
|
supported for c++ abi."
|
2014-10-18 09:15:17 +08:00
|
|
|
)
|
2015-02-06 07:56:33 +08:00
|
|
|
endif ()
|