2014-10-18 09:15:17 +08:00
|
|
|
|
|
|
|
#===============================================================================
|
|
|
|
# Add an ABI library if appropriate
|
|
|
|
#===============================================================================
|
|
|
|
|
|
|
|
#
|
|
|
|
# _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
|
2014-10-19 08:42:41 +08:00
|
|
|
# abilib : The 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
|
|
|
|
# libc++ build tree for the build. These files will also be
|
|
|
|
# installed alongside the libc++ headers.
|
|
|
|
# abidirs : A list of relative paths to create under an include directory
|
|
|
|
# in the libc++ build directory.
|
|
|
|
#
|
2015-03-20 04:59:45 +08:00
|
|
|
macro(setup_abi_lib abidefines abilib 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"
|
|
|
|
)
|
2014-10-19 08:42:41 +08:00
|
|
|
set(LIBCXX_CXX_ABI_LIBRARY ${abilib})
|
2014-10-18 09:15:17 +08:00
|
|
|
set(LIBCXX_ABILIB_FILES ${abifiles})
|
|
|
|
|
2016-12-09 17:31:01 +08:00
|
|
|
# The place in the build tree where we store out-of-source headers.
|
|
|
|
set(LIBCXX_BUILD_HEADERS_ROOT "${CMAKE_BINARY_DIR}/include/c++-build")
|
|
|
|
file(MAKE_DIRECTORY "${LIBCXX_BUILD_HEADERS_ROOT}")
|
2014-10-18 09:15:17 +08:00
|
|
|
foreach(_d ${abidirs})
|
2016-12-09 17:31:01 +08:00
|
|
|
file(MAKE_DIRECTORY "${LIBCXX_BUILD_HEADERS_ROOT}/${_d}")
|
2014-10-18 09:15:17 +08:00
|
|
|
endforeach()
|
|
|
|
|
|
|
|
foreach(fpath ${LIBCXX_ABILIB_FILES})
|
|
|
|
set(found FALSE)
|
2015-03-20 04:59:45 +08:00
|
|
|
foreach(incpath ${LIBCXX_CXX_ABI_INCLUDE_PATHS})
|
2014-10-18 09:15:17 +08:00
|
|
|
if (EXISTS "${incpath}/${fpath}")
|
|
|
|
set(found TRUE)
|
|
|
|
get_filename_component(dstdir ${fpath} PATH)
|
|
|
|
get_filename_component(ifile ${fpath} NAME)
|
|
|
|
file(COPY "${incpath}/${fpath}"
|
2016-12-09 17:31:01 +08:00
|
|
|
DESTINATION "${LIBCXX_BUILD_HEADERS_ROOT}/${dstdir}"
|
2014-10-18 09:15:17 +08:00
|
|
|
)
|
2015-08-27 04:18:21 +08:00
|
|
|
if (LIBCXX_INSTALL_HEADERS)
|
2016-12-09 17:31:01 +08:00
|
|
|
install(FILES "${LIBCXX_BUILD_HEADERS_ROOT}/${fpath}"
|
2015-08-27 04:18:21 +08:00
|
|
|
DESTINATION include/c++/v1/${dstdir}
|
|
|
|
COMPONENT libcxx
|
|
|
|
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
|
|
|
|
)
|
|
|
|
endif()
|
2016-12-09 17:31:01 +08:00
|
|
|
list(APPEND abilib_headers "${LIBCXX_BUILD_HEADERS_ROOT}/${fpath}")
|
2014-10-18 09:15:17 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if (NOT found)
|
2015-02-11 02:46:57 +08:00
|
|
|
message(WARNING "Failed to find ${fpath}")
|
2014-10-18 09:15:17 +08:00
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
|
2016-12-09 17:31:01 +08:00
|
|
|
include_directories("${LIBCXX_BUILD_HEADERS_ROOT}")
|
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}"
|
|
|
|
"${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits"
|
|
|
|
)
|
|
|
|
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi")
|
|
|
|
if (LIBCXX_CXX_ABI_INTREE)
|
|
|
|
# Link against just-built "cxxabi" target.
|
2015-03-03 23:59:51 +08:00
|
|
|
if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY)
|
|
|
|
set(CXXABI_LIBNAME cxxabi_static)
|
|
|
|
else()
|
|
|
|
set(CXXABI_LIBNAME cxxabi_shared)
|
|
|
|
endif()
|
2015-02-21 10:26:24 +08:00
|
|
|
set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE)
|
2014-10-18 09:15:17 +08:00
|
|
|
else()
|
|
|
|
# Assume c++abi is installed in the system, rely on -lc++abi link flag.
|
|
|
|
set(CXXABI_LIBNAME "c++abi")
|
|
|
|
endif()
|
2015-05-20 11:15:01 +08:00
|
|
|
setup_abi_lib("-DLIBCXX_BUILDING_LIBCXXABI"
|
2015-02-06 07:56:33 +08:00
|
|
|
${CXXABI_LIBNAME} "cxxabi.h;__cxxabi_config.h" ""
|
2014-10-18 09:15:17 +08:00
|
|
|
)
|
|
|
|
elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
|
2015-03-20 04:59:45 +08:00
|
|
|
setup_abi_lib("-DLIBCXXRT"
|
2014-10-18 09:15:17 +08:00
|
|
|
"cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""
|
|
|
|
)
|
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")
|
|
|
|
# Nothing TODO
|
|
|
|
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 ()
|