Eric Fiselier | 9071bc0 | 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 | cb7e32c | 2014-10-19 00:42:41 +0000 | [diff] [blame] | 11 | # abilib : The ABI library to link against. |
Eric Fiselier | 9071bc0 | 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 | 02c24c1 | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 18 | macro(setup_abi_lib abidefines abilib abifiles abidirs) |
Eric Fiselier | 9a1468f | 2014-11-15 17:25:23 +0000 | [diff] [blame] | 19 | list(APPEND LIBCXX_COMPILE_FLAGS ${abidefines}) |
Eric Fiselier | 02c24c1 | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 20 | set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${LIBCXX_CXX_ABI_INCLUDE_PATHS}" |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 21 | CACHE PATH |
| 22 | "Paths to C++ ABI header directories separated by ';'." FORCE |
| 23 | ) |
| 24 | |
Eric Fiselier | cb7e32c | 2014-10-19 00:42:41 +0000 | [diff] [blame] | 25 | set(LIBCXX_CXX_ABI_LIBRARY ${abilib}) |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 26 | |
| 27 | set(LIBCXX_ABILIB_FILES ${abifiles}) |
| 28 | |
| 29 | file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include") |
| 30 | foreach(_d ${abidirs}) |
| 31 | file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/include/${_d}") |
| 32 | endforeach() |
| 33 | |
| 34 | foreach(fpath ${LIBCXX_ABILIB_FILES}) |
| 35 | set(found FALSE) |
Eric Fiselier | 02c24c1 | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 36 | foreach(incpath ${LIBCXX_CXX_ABI_INCLUDE_PATHS}) |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 37 | if (EXISTS "${incpath}/${fpath}") |
| 38 | set(found TRUE) |
| 39 | get_filename_component(dstdir ${fpath} PATH) |
| 40 | get_filename_component(ifile ${fpath} NAME) |
| 41 | file(COPY "${incpath}/${fpath}" |
| 42 | DESTINATION "${CMAKE_BINARY_DIR}/include/${dstdir}" |
| 43 | ) |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 44 | install(FILES "${CMAKE_BINARY_DIR}/include/${fpath}" |
| 45 | DESTINATION include/c++/v1/${dstdir} |
| 46 | PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ |
| 47 | ) |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 48 | list(APPEND abilib_headers "${CMAKE_BINARY_DIR}/include/${fpath}") |
| 49 | endif() |
| 50 | endforeach() |
| 51 | if (NOT found) |
Dan Albert | f42a8e6 | 2015-02-10 18:46:57 +0000 | [diff] [blame] | 52 | message(WARNING "Failed to find ${fpath}") |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 53 | endif() |
| 54 | endforeach() |
| 55 | |
| 56 | add_custom_target(LIBCXX_CXX_ABI_DEPS DEPENDS ${abilib_headers}) |
| 57 | include_directories("${CMAKE_BINARY_DIR}/include") |
| 58 | |
| 59 | endmacro() |
| 60 | |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 61 | # Setup the default options if LIBCXX_CXX_ABI is not specified. |
| 62 | if (NOT LIBCXX_CXX_ABI) |
| 63 | if (NOT DEFINED LIBCXX_BUILT_STANDALONE AND |
| 64 | IS_DIRECTORY "${CMAKE_SOURCE_DIR}/projects/libcxxabi") |
| 65 | set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi") |
| 66 | set(LIBCXX_CXX_ABI_INCLUDE_PATHS "${CMAKE_SOURCE_DIR}/projects/libcxxabi/include") |
| 67 | set(LIBCXX_CXX_ABI_INTREE 1) |
| 68 | else () |
| 69 | set(LIBCXX_CXX_ABI_LIBNAME "none") |
| 70 | endif () |
| 71 | else () |
| 72 | set(LIBCXX_CXX_ABI_LIBNAME "${LIBCXX_CXX_ABI}") |
| 73 | endif () |
Eric Fiselier | eb6e2ea | 2015-07-30 22:30:34 +0000 | [diff] [blame] | 74 | |
| 75 | # Configure based on the selected ABI library. |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 76 | if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++" OR |
| 77 | "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libsupc++") |
| 78 | set(_LIBSUPCXX_INCLUDE_FILES |
| 79 | cxxabi.h bits/c++config.h bits/os_defines.h bits/cpu_defines.h |
| 80 | bits/cxxabi_tweaks.h bits/cxxabi_forced.h |
| 81 | ) |
| 82 | if ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libstdc++") |
| 83 | set(_LIBSUPCXX_DEFINES "-DLIBSTDCXX") |
| 84 | set(_LIBSUPCXX_LIBNAME stdc++) |
| 85 | else() |
| 86 | set(_LIBSUPCXX_DEFINES "") |
| 87 | set(_LIBSUPCXX_LIBNAME supc++) |
| 88 | endif() |
Eric Fiselier | 02c24c1 | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 89 | setup_abi_lib( |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 90 | "-D__GLIBCXX__ ${_LIBSUPCXX_DEFINES}" |
| 91 | "${_LIBSUPCXX_LIBNAME}" "${_LIBSUPCXX_INCLUDE_FILES}" "bits" |
| 92 | ) |
| 93 | elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxabi") |
| 94 | if (LIBCXX_CXX_ABI_INTREE) |
| 95 | # Link against just-built "cxxabi" target. |
Eric Fiselier | c0b166e | 2015-03-03 15:59:51 +0000 | [diff] [blame] | 96 | if (LIBCXX_ENABLE_STATIC_ABI_LIBRARY) |
| 97 | set(CXXABI_LIBNAME cxxabi_static) |
| 98 | else() |
| 99 | set(CXXABI_LIBNAME cxxabi_shared) |
| 100 | endif() |
Eric Fiselier | 45969ec | 2015-02-21 02:26:24 +0000 | [diff] [blame] | 101 | set(LIBCXX_LIBCPPABI_VERSION "2" PARENT_SCOPE) |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 102 | else() |
| 103 | # Assume c++abi is installed in the system, rely on -lc++abi link flag. |
| 104 | set(CXXABI_LIBNAME "c++abi") |
| 105 | endif() |
Eric Fiselier | bae11ad | 2015-05-20 03:15:01 +0000 | [diff] [blame] | 106 | setup_abi_lib("-DLIBCXX_BUILDING_LIBCXXABI" |
Dan Albert | 062d0a6 | 2015-02-05 23:56:33 +0000 | [diff] [blame] | 107 | ${CXXABI_LIBNAME} "cxxabi.h;__cxxabi_config.h" "" |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 108 | ) |
| 109 | elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt") |
Eric Fiselier | 02c24c1 | 2015-03-19 20:59:45 +0000 | [diff] [blame] | 110 | setup_abi_lib("-DLIBCXXRT" |
Eric Fiselier | 9071bc0 | 2014-10-18 01:15:17 +0000 | [diff] [blame] | 111 | "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" "" |
| 112 | ) |
| 113 | elseif (NOT "${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "none") |
| 114 | message(FATAL_ERROR |
| 115 | "Currently libstdc++, libsupc++, libcxxabi, libcxxrt and none are " |
| 116 | "supported for c++ abi." |
| 117 | ) |
Dan Albert | 062d0a6 | 2015-02-05 23:56:33 +0000 | [diff] [blame] | 118 | endif () |