Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 1 | # Get sources |
| 2 | set(LIBCXXABI_SOURCES |
| 3 | abort_message.cpp |
| 4 | cxa_aux_runtime.cpp |
| 5 | cxa_default_handlers.cpp |
| 6 | cxa_demangle.cpp |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 7 | cxa_exception_storage.cpp |
| 8 | cxa_guard.cpp |
| 9 | cxa_handlers.cpp |
| 10 | cxa_new_delete.cpp |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 11 | cxa_unexpected.cpp |
| 12 | cxa_vector.cpp |
| 13 | cxa_virtual.cpp |
| 14 | exception.cpp |
| 15 | private_typeinfo.cpp |
| 16 | stdexcept.cpp |
| 17 | typeinfo.cpp |
| 18 | ) |
| 19 | |
Asiri Rathnayake | 4174e8b | 2016-05-31 12:01:32 +0000 | [diff] [blame] | 20 | if (LIBCXXABI_ENABLE_EXCEPTIONS) |
| 21 | list(APPEND LIBCXXABI_SOURCES cxa_exception.cpp) |
| 22 | list(APPEND LIBCXXABI_SOURCES cxa_personality.cpp) |
| 23 | else() |
| 24 | list(APPEND LIBCXXABI_SOURCES cxa_noexception.cpp) |
| 25 | endif() |
| 26 | |
Dan Albert | efa37d1 | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 27 | if (UNIX AND NOT (APPLE OR CYGWIN)) |
| 28 | list(APPEND LIBCXXABI_SOURCES cxa_thread_atexit.cpp) |
| 29 | endif() |
| 30 | |
Dan Albert | 000b3c9 | 2014-07-11 15:36:02 +0000 | [diff] [blame] | 31 | set(LIBCXXABI_HEADERS ../include/cxxabi.h) |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 32 | |
| 33 | # Add all the headers to the project for IDEs. |
| 34 | if (MSVC_IDE OR XCODE) |
| 35 | # Force them all into the headers dir on MSVC, otherwise they end up at |
| 36 | # project scope because they don't have extensions. |
| 37 | if (MSVC_IDE) |
| 38 | source_group("Header Files" FILES ${LIBCXXABI_HEADERS}) |
| 39 | endif() |
| 40 | endif() |
| 41 | |
Dan Albert | fd961bd | 2014-07-10 02:20:11 +0000 | [diff] [blame] | 42 | include_directories("${LIBCXXABI_LIBCXX_INCLUDES}") |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 43 | |
Dan Albert | efa37d1 | 2014-12-18 00:03:57 +0000 | [diff] [blame] | 44 | if (LIBCXXABI_HAS_CXA_THREAD_ATEXIT_IMPL) |
| 45 | add_definitions(-DHAVE___CXA_THREAD_ATEXIT_IMPL) |
| 46 | endif() |
| 47 | |
Eric Fiselier | f84ec31 | 2015-12-14 22:20:04 +0000 | [diff] [blame] | 48 | # Generate library list |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 49 | set(libraries ${LIBCXXABI_CXX_ABI_LIBRARIES}) |
Eric Fiselier | f84ec31 | 2015-12-14 22:20:04 +0000 | [diff] [blame] | 50 | |
Eric Fiselier | d872a69 | 2014-11-24 22:42:03 +0000 | [diff] [blame] | 51 | if (LIBCXXABI_ENABLE_THREADS) |
| 52 | append_if(libraries LIBCXXABI_HAS_PTHREAD_LIB pthread) |
| 53 | endif() |
Dan Albert | db8f335 | 2014-07-14 17:00:29 +0000 | [diff] [blame] | 54 | |
Eric Fiselier | f84ec31 | 2015-12-14 22:20:04 +0000 | [diff] [blame] | 55 | append_if(libraries LIBCXXABI_HAS_C_LIB c) |
| 56 | |
Dan Albert | db8f335 | 2014-07-14 17:00:29 +0000 | [diff] [blame] | 57 | if (LIBCXXABI_USE_LLVM_UNWINDER) |
Petr Hosek | 3f7e85b | 2016-08-09 00:27:19 +0000 | [diff] [blame] | 58 | if (NOT LIBCXXABI_BUILT_STANDALONE) |
Petr Hosek | e1b2d05 | 2016-08-09 21:28:52 +0000 | [diff] [blame^] | 59 | if (LIBUNWIND_ENABLE_SHARED) |
| 60 | list(APPEND libraries unwind_shared) |
| 61 | else() |
| 62 | list(APPEND libraries unwind_static) |
| 63 | endif() |
| 64 | else() |
| 65 | list(APPEND libraries unwind) |
Petr Hosek | 3f7e85b | 2016-08-09 00:27:19 +0000 | [diff] [blame] | 66 | endif() |
Dan Albert | db8f335 | 2014-07-14 17:00:29 +0000 | [diff] [blame] | 67 | else() |
Eric Fiselier | f84ec31 | 2015-12-14 22:20:04 +0000 | [diff] [blame] | 68 | append_if(libraries LIBCXXABI_HAS_GCC_S_LIB gcc_s) |
Dan Albert | db8f335 | 2014-07-14 17:00:29 +0000 | [diff] [blame] | 69 | endif() |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 70 | |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 71 | # Setup flags. |
Eric Fiselier | c365bb5 | 2014-11-18 20:37:53 +0000 | [diff] [blame] | 72 | append_if(LIBCXXABI_COMPILE_FLAGS LIBCXXABI_HAS_FPIC_FLAG -fPIC) |
| 73 | append_if(LIBCXXABI_LINK_FLAGS LIBCXXABI_HAS_NODEFAULTLIBS_FLAG -nodefaultlibs) |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 74 | |
Eric Fiselier | d95080e | 2015-03-03 15:59:09 +0000 | [diff] [blame] | 75 | set(LIBCXXABI_SHARED_LINK_FLAGS) |
| 76 | |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 77 | if ( APPLE ) |
| 78 | if ( CMAKE_OSX_DEPLOYMENT_TARGET STREQUAL "10.6" ) |
Eric Fiselier | c365bb5 | 2014-11-18 20:37:53 +0000 | [diff] [blame] | 79 | list(APPEND LIBCXXABI_COMPILE_FLAGS "-U__STRICT_ANSI__") |
Eric Fiselier | d95080e | 2015-03-03 15:59:09 +0000 | [diff] [blame] | 80 | list(APPEND LIBCXXABI_SHARED_LINK_FLAGS |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 81 | "-compatibility_version 1" |
Hans Wennborg | 95272d2 | 2014-08-12 18:18:07 +0000 | [diff] [blame] | 82 | "-current_version 1" |
Eric Fiselier | d95080e | 2015-03-03 15:59:09 +0000 | [diff] [blame] | 83 | "-install_name /usr/lib/libc++abi.1.dylib") |
Eric Fiselier | c365bb5 | 2014-11-18 20:37:53 +0000 | [diff] [blame] | 84 | list(APPEND LIBCXXABI_LINK_FLAGS |
Eric Fiselier | d95080e | 2015-03-03 15:59:09 +0000 | [diff] [blame] | 85 | "/usr/lib/libSystem.B.dylib") |
| 86 | else() |
| 87 | list(APPEND LIBCXXABI_SHARED_LINK_FLAGS |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 88 | "-compatibility_version 1" |
| 89 | "-install_name /usr/lib/libc++abi.1.dylib") |
| 90 | endif() |
| 91 | endif() |
| 92 | |
Eric Fiselier | c365bb5 | 2014-11-18 20:37:53 +0000 | [diff] [blame] | 93 | string(REPLACE ";" " " LIBCXXABI_COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}") |
| 94 | string(REPLACE ";" " " LIBCXXABI_LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}") |
Eric Fiselier | d95080e | 2015-03-03 15:59:09 +0000 | [diff] [blame] | 95 | string(REPLACE ";" " " LIBCXXABI_SHARED_LINK_FLAGS "${LIBCXXABI_SHARED_LINK_FLAGS}") |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 96 | |
Eric Fiselier | d95080e | 2015-03-03 15:59:09 +0000 | [diff] [blame] | 97 | # Add a object library that contains the compiled source files. |
| 98 | add_library(cxxabi_objects OBJECT ${LIBCXXABI_SOURCES} ${LIBCXXABI_HEADERS}) |
| 99 | |
| 100 | set_target_properties(cxxabi_objects |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 101 | PROPERTIES |
Eric Fiselier | c365bb5 | 2014-11-18 20:37:53 +0000 | [diff] [blame] | 102 | COMPILE_FLAGS "${LIBCXXABI_COMPILE_FLAGS}" |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 103 | ) |
| 104 | |
Eric Fiselier | d95080e | 2015-03-03 15:59:09 +0000 | [diff] [blame] | 105 | set(LIBCXXABI_TARGETS) |
| 106 | |
| 107 | # Build the shared library. |
| 108 | if (LIBCXXABI_ENABLE_SHARED) |
| 109 | add_library(cxxabi_shared SHARED $<TARGET_OBJECTS:cxxabi_objects>) |
| 110 | target_link_libraries(cxxabi_shared ${libraries}) |
| 111 | set_target_properties(cxxabi_shared |
| 112 | PROPERTIES |
| 113 | LINK_FLAGS "${LIBCXXABI_LINK_FLAGS} ${LIBCXXABI_SHARED_LINK_FLAGS}" |
| 114 | OUTPUT_NAME "c++abi" |
| 115 | VERSION "1.0" |
| 116 | SOVERSION "1" |
| 117 | ) |
| 118 | list(APPEND LIBCXXABI_TARGETS "cxxabi_shared") |
| 119 | endif() |
| 120 | |
| 121 | # Build the static library. |
| 122 | if (LIBCXXABI_ENABLE_STATIC) |
| 123 | add_library(cxxabi_static STATIC $<TARGET_OBJECTS:cxxabi_objects>) |
| 124 | target_link_libraries(cxxabi_static ${libraries}) |
| 125 | set_target_properties(cxxabi_static |
| 126 | PROPERTIES |
| 127 | LINK_FLAGS "${LIBCXXABI_LINK_FLAGS}" |
| 128 | OUTPUT_NAME "c++abi" |
| 129 | ) |
| 130 | list(APPEND LIBCXXABI_TARGETS "cxxabi_static") |
| 131 | endif() |
| 132 | |
| 133 | # Add a meta-target for both libraries. |
| 134 | add_custom_target(cxxabi DEPENDS ${LIBCXXABI_TARGETS}) |
| 135 | |
| 136 | install(TARGETS ${LIBCXXABI_TARGETS} |
Eric Fiselier | 147e19b | 2015-08-19 17:17:21 +0000 | [diff] [blame] | 137 | LIBRARY DESTINATION lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT libcxxabi |
| 138 | ARCHIVE DESTINATION lib${LIBCXXABI_LIBDIR_SUFFIX} COMPONENT libcxxabi |
Dan Albert | e11c1a7 | 2014-07-03 19:35:48 +0000 | [diff] [blame] | 139 | ) |
Eric Fiselier | 147e19b | 2015-08-19 17:17:21 +0000 | [diff] [blame] | 140 | |
| 141 | if (NOT CMAKE_CONFIGURATION_TYPES) |
| 142 | add_custom_target(install-libcxxabi |
| 143 | DEPENDS cxxabi |
| 144 | COMMAND "${CMAKE_COMMAND}" |
| 145 | -DCMAKE_INSTALL_COMPONENT=libcxxabi |
| 146 | -P "${LIBCXXABI_BINARY_DIR}/cmake_install.cmake") |
| 147 | endif() |