Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 1 | |
| 2 | #=============================================================================== |
| 3 | # Add an ABI library if appropriate |
| 4 | #=============================================================================== |
| 5 | |
| 6 | # |
| 7 | # _setup_abi: Set up the build to use an ABI library |
| 8 | # |
| 9 | # Parameters: |
| 10 | # abidefines: A list of defines needed to compile libc++ with the ABI library |
Eric Fiselier | a63c149 | 2014-10-19 00:42:41 +0000 | [diff] [blame] | 11 | # abilib : The ABI library to link against. |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 12 | # abifiles : A list of files (which may be relative paths) to copy into the |
| 13 | # libc++ build tree for the build. These files will also be |
| 14 | # installed alongside the libc++ headers. |
| 15 | # abidirs : A list of relative paths to create under an include directory |
| 16 | # in the libc++ build directory. |
| 17 | # |
Eric Fiselier | 237b6ed | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 18 | macro(setup_abi_lib abidefines abilib abifiles abidirs) |
Eric Fiselier | 382338d | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 19 | list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines}) |
Eric Fiselier | 237b6ed | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 20 | set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}" |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 21 | CACHE PATH |
| 22 | "Paths to C++ ABI header directories separated by ';'." FORCE |
| 23 | ) |
Eric Fiselier | 72a819e | 2016-05-27 23:05:37 +0000 | [diff] [blame] | 24 | set(LIBCXX_CXX_ABI_LIBRARY_PATH "${LIBCXX_CXX_ABI_LIBRARY_PATH}" |
| 25 | CACHE PATH |
| 26 | "Paths to C++ ABI library directory" |
| 27 | ) |
Eric Fiselier | a63c149 | 2014-10-19 00:42:41 +0000 | [diff] [blame] | 28 | set(LIBCXX_CXX_ABI_LIBRARY ${abilib}) |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 29 | set(LIBCXX_ABILIB_FILES ${abifiles}) |
| 30 | |
Eric Fiselier | 0ef3b1b | 2016-12-09 09:31:01 +0000 | [diff] [blame] | 31 | # The place in the build tree where we store out-of-source headers. |
| 32 | set(LIBCXX_BUILD_HEADERS_ROOT "${CMAKE_BINARY_DIR}/include/c++-build") |
| 33 | file(MAKE_DIRECTORY "${LIBCXX_BUILD_HEADERS_ROOT}") |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 34 | foreach(_d ${abidirs}) |
Eric Fiselier | 0ef3b1b | 2016-12-09 09:31:01 +0000 | [diff] [blame] | 35 | file(MAKE_DIRECTORY "${LIBCXX_BUILD_HEADERS_ROOT}/${_d}") |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 36 | endforeach() |
| 37 | |
| 38 | foreach(fpath ${LIBCXX_ABILIB_FILES}) |
| 39 | set(found FALSE) |
Eric Fiselier | 237b6ed | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 40 | foreach(incpath ${LIBCXX_CXX_ABI_INCLUDE_PATHS}) |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 41 | if (EXISTS "${incpath}/${fpath}") |
| 42 | set(found TRUE) |
| 43 | get_filename_component(dstdir ${fpath} PATH) |
| 44 | get_filename_component(ifile ${fpath} NAME) |
| 45 | file(COPY "${incpath}/${fpath}" |
Eric Fiselier | 0ef3b1b | 2016-12-09 09:31:01 +0000 | [diff] [blame] | 46 | DESTINATION "${LIBCXX_BUILD_HEADERS_ROOT}/${dstdir}" |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 47 | ) |
Eric Fiselier | d77135f | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 48 | if (LIBCXX_INSTALL_HEADERS) |
Eric Fiselier | 0ef3b1b | 2016-12-09 09:31:01 +0000 | [diff] [blame] | 49 | install(FILES "${LIBCXX_BUILD_HEADERS_ROOT}/${fpath}" |
Eric Fiselier | d77135f | 2015-08-26 20:18:21 +0000 | [diff] [blame] | 50 | DESTINATION include/c++/v1/${dstdir} |
| 51 | COMPONENT libcxx |
| 52 | PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ |
| 53 | ) |
| 54 | endif() |
Eric Fiselier | 0ef3b1b | 2016-12-09 09:31:01 +0000 | [diff] [blame] | 55 | list(APPEND abilib_headers "${LIBCXX_BUILD_HEADERS_ROOT}/${fpath}") |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 56 | endif() |
| 57 | endforeach() |
| 58 | if (NOT found) |
Dan Albert | 86cc60e | 2015-02-10 18:46:57 +0000 | [diff] [blame] | 59 | message(WARNING "Failed to find ${fpath}") |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 60 | endif() |
| 61 | endforeach() |
| 62 | |
Eric Fiselier | 0ef3b1b | 2016-12-09 09:31:01 +0000 | [diff] [blame] | 63 | include_directories("${LIBCXX_BUILD_HEADERS_ROOT}") |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 64 | endmacro() |
| 65 | |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 66 | |
| 67 | # Configure based on the selected ABI library. |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 68 | if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR |
| 69 | "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libsupc++") |
| 70 | set(_LIBSUPCXX_INCLUDE_FILES |
| 71 | cxxabi.h bits/c++config.h bits/os_defines.h bits/cpu_defines.h |
| 72 | bits/cxxabi_tweaks.h bits/cxxabi_forced.h |
| 73 | ) |
| 74 | if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++") |
| 75 | set(_LIBSUPCXX_DEFINES "-DLIBSTDCXX") |
| 76 | set(_LIBSUPCXX_LIBNAME stdc++) |
| 77 | else() |
| 78 | set(_LIBSUPCXX_DEFINES "") |
| 79 | set(_LIBSUPCXX_LIBNAME supc++) |
| 80 | endif() |
Eric Fiselier | 237b6ed | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 81 | setup_abi_lib( |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 82 | "-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}" |
| 83 | "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits" |
| 84 | ) |
| 85 | elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi") |
| 86 | if (LIBCXX_CXX_ABI_INTREE) |
| 87 | # Link against just-built "cxxabi" target. |
Eric Fiselier | 0357171 | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 88 | if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) |
| 89 | set(CXXABI_LIBNAME cxxabi_static) |
| 90 | else() |
| 91 | set(CXXABI_LIBNAME cxxabi_shared) |
| 92 | endif() |
Eric Fiselier | d2852b6 | 2015-02-21 02:26:24 +0000 | [diff] [blame] | 93 | set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE) |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 94 | else() |
| 95 | # Assume c++abi is installed in the system, rely on -lc++abi link flag. |
| 96 | set(CXXABI_LIBNAME "c++abi") |
| 97 | endif() |
Eric Fiselier | 1f294fd | 2015-05-20 03:15:01 +0000 | [diff] [blame] | 98 | setup_abi_lib("-DLIBCXX_BUILDING_LIBCXXABI" |
Dan Albert | 271e264 | 2015-02-05 23:56:33 +0000 | [diff] [blame] | 99 | ${CXXABI_LIBNAME} "cxxabi.h;__cxxabi_config.h" "" |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 100 | ) |
| 101 | elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt") |
Eric Fiselier | 237b6ed | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 102 | setup_abi_lib("-DLIBCXXRT" |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 103 | "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" "" |
| 104 | ) |
Eric Fiselier | 1285e4d | 2017-01-03 01:18:48 +0000 | [diff] [blame^] | 105 | elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none") |
| 106 | list(APPEND LIBCXX_COMPILE_FLAGS "-D_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY") |
| 107 | elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "default") |
| 108 | # Nothing TODO |
| 109 | else() |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 110 | message(FATAL_ERROR |
Eric Fiselier | 1285e4d | 2017-01-03 01:18:48 +0000 | [diff] [blame^] | 111 | "Unsupported c++ abi: '${LIBCXX_CXX_ABI_LIBNAME}'. \ |
| 112 | Currently libstdc++, libsupc++, libcxxabi, libcxxrt, default and none are |
| 113 | supported for c++ abi." |
Eric Fiselier | 6f9da55 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 114 | ) |
Dan Albert | 271e264 | 2015-02-05 23:56:33 +0000 | [diff] [blame] | 115 | endif () |