Michael J. Spencer | f5799be | 2010-12-10 19:47:54 | [diff] [blame] | 1 | # Get sources |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 2 | set(LIBCXX_SOURCES |
| 3 | algorithm.cpp |
| 4 | any.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 5 | bind.cpp |
Louis Dionne | cf7d4f5 | 2023-11-06 00:08:24 | [diff] [blame] | 6 | call_once.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 7 | charconv.cpp |
| 8 | chrono.cpp |
Chris Bowler | fbdf684 | 2022-06-10 14:04:07 | [diff] [blame] | 9 | error_category.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 10 | exception.cpp |
Louis Dionne | 22629bb | 2024-04-16 14:54:28 | [diff] [blame] | 11 | expected.cpp |
Louis Dionne | c352fa7 | 2023-06-05 19:53:42 | [diff] [blame] | 12 | filesystem/filesystem_clock.cpp |
| 13 | filesystem/filesystem_error.cpp |
| 14 | filesystem/path_parser.h |
| 15 | filesystem/path.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 16 | functional.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 17 | hash.cpp |
| 18 | include/apple_availability.h |
| 19 | include/atomic_support.h |
| 20 | include/config_elast.h |
| 21 | include/refstring.h |
Mark de Wever | abb5dd6e | 2021-02-09 16:52:41 | [diff] [blame] | 22 | include/ryu/common.h |
| 23 | include/ryu/d2fixed.h |
| 24 | include/ryu/d2fixed_full_table.h |
| 25 | include/ryu/d2s.h |
| 26 | include/ryu/d2s_full_table.h |
| 27 | include/ryu/d2s_intrinsics.h |
| 28 | include/ryu/digit_table.h |
| 29 | include/ryu/f2s.h |
| 30 | include/ryu/ryu.h |
| 31 | include/to_chars_floating_point.h |
Michael Jones | 6c4267f | 2024-10-21 22:04:06 | [diff] [blame] | 32 | include/from_chars_floating_point.h |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 33 | memory.cpp |
Arthur O'Dwyer | 243da90 | 2022-10-06 20:53:30 | [diff] [blame] | 34 | memory_resource.cpp |
Louis Dionne | 80e4cca | 2023-06-14 20:37:57 | [diff] [blame] | 35 | new_handler.cpp |
Louis Dionne | 3956a34 | 2023-06-14 22:36:37 | [diff] [blame] | 36 | new_helpers.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 37 | optional.cpp |
Mark de Wever | 3f65f718 | 2023-04-21 06:09:06 | [diff] [blame] | 38 | print.cpp |
Louis Dionne | ce6153a | 2020-06-30 16:42:44 | [diff] [blame] | 39 | random_shuffle.cpp |
Mark de Wever | abb5dd6e | 2021-02-09 16:52:41 | [diff] [blame] | 40 | ryu/d2fixed.cpp |
| 41 | ryu/d2s.cpp |
| 42 | ryu/f2s.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 43 | stdexcept.cpp |
| 44 | string.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 45 | support/runtime/exception_fallback.ipp |
| 46 | support/runtime/exception_glibcxx.ipp |
| 47 | support/runtime/exception_libcxxabi.ipp |
| 48 | support/runtime/exception_libcxxrt.ipp |
| 49 | support/runtime/exception_msvc.ipp |
| 50 | support/runtime/exception_pointer_cxxabi.ipp |
| 51 | support/runtime/exception_pointer_glibcxx.ipp |
| 52 | support/runtime/exception_pointer_msvc.ipp |
| 53 | support/runtime/exception_pointer_unimplemented.ipp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 54 | support/runtime/stdexcept_default.ipp |
| 55 | support/runtime/stdexcept_vcruntime.ipp |
| 56 | system_error.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 57 | typeinfo.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 58 | valarray.cpp |
| 59 | variant.cpp |
| 60 | vector.cpp |
Louis Dionne | 507125a | 2022-07-25 17:43:47 | [diff] [blame] | 61 | verbose_abort.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 62 | ) |
| 63 | |
Louis Dionne | cf7d4f5 | 2023-11-06 00:08:24 | [diff] [blame] | 64 | if (LIBCXX_ENABLE_THREADS) |
| 65 | list(APPEND LIBCXX_SOURCES |
| 66 | atomic.cpp |
| 67 | barrier.cpp |
| 68 | condition_variable_destructor.cpp |
| 69 | condition_variable.cpp |
| 70 | future.cpp |
| 71 | mutex_destructor.cpp |
| 72 | mutex.cpp |
| 73 | shared_mutex.cpp |
| 74 | thread.cpp |
| 75 | ) |
| 76 | endif() |
| 77 | |
Louis Dionne | e0d0129 | 2020-10-15 14:32:09 | [diff] [blame] | 78 | if (LIBCXX_ENABLE_RANDOM_DEVICE) |
| 79 | list(APPEND LIBCXX_SOURCES |
| 80 | random.cpp |
| 81 | ) |
| 82 | endif() |
| 83 | |
Louis Dionne | 88ffc72 | 2020-10-09 19:31:05 | [diff] [blame] | 84 | if (LIBCXX_ENABLE_LOCALIZATION) |
| 85 | list(APPEND LIBCXX_SOURCES |
Hristo Hristov | 92e2431 | 2024-01-07 16:01:03 | [diff] [blame] | 86 | fstream.cpp |
Arthur O'Dwyer | 0b10bb7 | 2021-04-26 13:56:50 | [diff] [blame] | 87 | include/sso_allocator.h |
Louis Dionne | 88ffc72 | 2020-10-09 19:31:05 | [diff] [blame] | 88 | ios.cpp |
Louis Dionne | c6eaa14 | 2020-11-02 15:30:29 | [diff] [blame] | 89 | ios.instantiations.cpp |
Louis Dionne | 88ffc72 | 2020-10-09 19:31:05 | [diff] [blame] | 90 | iostream.cpp |
| 91 | locale.cpp |
Mark de Wever | 2fd4084 | 2023-12-19 18:32:17 | [diff] [blame] | 92 | ostream.cpp |
Louis Dionne | 88ffc72 | 2020-10-09 19:31:05 | [diff] [blame] | 93 | regex.cpp |
| 94 | strstream.cpp |
| 95 | ) |
| 96 | endif() |
| 97 | |
Howard Hinnant | 3c78ca0 | 2011-09-22 19:10:18 | [diff] [blame] | 98 | if(WIN32) |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 99 | list(APPEND LIBCXX_SOURCES |
Nikolas Klauser | 5aacf93 | 2024-07-05 09:25:59 | [diff] [blame] | 100 | support/win32/compiler_rt_shims.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 101 | support/win32/locale_win32.cpp |
| 102 | support/win32/support.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 103 | ) |
Colin Finck | 0f5020a | 2021-02-16 15:03:04 | [diff] [blame] | 104 | |
| 105 | if (NOT LIBCXX_HAS_PTHREAD_API) |
| 106 | list(APPEND LIBCXX_SOURCES |
| 107 | support/win32/thread_win32.cpp |
| 108 | ) |
| 109 | endif() |
Muiez Ahmed | ebe6161 | 2021-03-08 19:20:22 | [diff] [blame] | 110 | elseif(ZOS) |
| 111 | list(APPEND LIBCXX_SOURCES |
Muiez Ahmed | 4247381 | 2021-09-13 13:43:21 | [diff] [blame] | 112 | support/ibm/mbsnrtowcs.cpp |
| 113 | support/ibm/wcsnrtombs.cpp |
Muiez Ahmed | ebe6161 | 2021-03-08 19:20:22 | [diff] [blame] | 114 | support/ibm/xlocale_zos.cpp |
| 115 | ) |
Howard Hinnant | 3c78ca0 | 2011-09-22 19:10:18 | [diff] [blame] | 116 | endif() |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 | [diff] [blame] | 117 | |
Eric Fiselier | f1d87f8 | 2019-03-21 00:04:31 | [diff] [blame] | 118 | if (LIBCXX_ENABLE_FILESYSTEM) |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 119 | list(APPEND LIBCXX_SOURCES |
Louis Dionne | c7d3c84 | 2023-06-12 17:43:55 | [diff] [blame] | 120 | filesystem/directory_entry.cpp |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 121 | filesystem/directory_iterator.cpp |
Louis Dionne | c7d3c84 | 2023-06-12 17:43:55 | [diff] [blame] | 122 | filesystem/file_descriptor.h |
Louis Dionne | c7d3c84 | 2023-06-12 17:43:55 | [diff] [blame] | 123 | filesystem/operations.cpp |
Martin Storsjö | 2ff8662 | 2020-11-04 14:59:07 | [diff] [blame] | 124 | filesystem/posix_compat.h |
Louis Dionne | c7d3c84 | 2023-06-12 17:43:55 | [diff] [blame] | 125 | filesystem/time_utils.h |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 126 | ) |
Eric Fiselier | f1d87f8 | 2019-03-21 00:04:31 | [diff] [blame] | 127 | # Filesystem uses __int128_t, which requires a definition of __muloi4 when |
| 128 | # compiled with UBSAN. This definition is not provided by libgcc_s, but is |
| 129 | # provided by compiler-rt. So we need to disable it to avoid having multiple |
| 130 | # definitions. See filesystem/int128_builtins.cpp. |
| 131 | if (NOT LIBCXX_USE_COMPILER_RT) |
Petr Hosek | f80c4b6 | 2019-05-01 06:40:36 | [diff] [blame] | 132 | list(APPEND LIBCXX_SOURCES |
| 133 | filesystem/int128_builtins.cpp |
| 134 | ) |
Eric Fiselier | f1d87f8 | 2019-03-21 00:04:31 | [diff] [blame] | 135 | endif() |
Louis Dionne | cc37af7 | 2019-03-19 20:56:13 | [diff] [blame] | 136 | endif() |
| 137 | |
Louis Dionne | afc5cca | 2023-06-14 22:31:20 | [diff] [blame] | 138 | if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) |
| 139 | list(APPEND LIBCXX_SOURCES |
| 140 | new.cpp |
| 141 | ) |
| 142 | endif() |
| 143 | |
Eric Fiselier | d1bac4c | 2015-07-22 00:33:36 | [diff] [blame] | 144 | if (APPLE AND LLVM_USE_SANITIZER) |
Kuba Brecka | 50bc34ca31 | 2016-09-15 11:04:53 | [diff] [blame] | 145 | if (("${LLVM_USE_SANITIZER}" STREQUAL "Address") OR |
| 146 | ("${LLVM_USE_SANITIZER}" STREQUAL "Address;Undefined") OR |
| 147 | ("${LLVM_USE_SANITIZER}" STREQUAL "Undefined;Address")) |
Eric Fiselier | d1bac4c | 2015-07-22 00:33:36 | [diff] [blame] | 148 | set(LIBFILE "libclang_rt.asan_osx_dynamic.dylib") |
| 149 | elseif("${LLVM_USE_SANITIZER}" STREQUAL "Undefined") |
| 150 | set(LIBFILE "libclang_rt.ubsan_osx_dynamic.dylib") |
Kuba Brecka | d634df5 | 2016-09-14 14:12:50 | [diff] [blame] | 151 | elseif("${LLVM_USE_SANITIZER}" STREQUAL "Thread") |
| 152 | set(LIBFILE "libclang_rt.tsan_osx_dynamic.dylib") |
Eric Fiselier | d1bac4c | 2015-07-22 00:33:36 | [diff] [blame] | 153 | else() |
| 154 | message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not supported on OS X") |
| 155 | endif() |
| 156 | if (LIBFILE) |
Petr Hosek | 22acda4 | 2020-09-29 00:37:20 | [diff] [blame] | 157 | find_compiler_rt_library(builtins LIBCXX_BUILTINS_LIBRARY) |
| 158 | get_filename_component(LIBDIR "${LIBCXX_BUILTINS_LIBRARY}" DIRECTORY) |
Eric Fiselier | d1bac4c | 2015-07-22 00:33:36 | [diff] [blame] | 159 | if (NOT IS_DIRECTORY "${LIBDIR}") |
| 160 | message(FATAL_ERROR "Cannot find compiler-rt directory on OS X required for LLVM_USE_SANITIZER") |
| 161 | endif() |
| 162 | set(LIBCXX_SANITIZER_LIBRARY "${LIBDIR}/${LIBFILE}") |
| 163 | set(LIBCXX_SANITIZER_LIBRARY "${LIBCXX_SANITIZER_LIBRARY}" PARENT_SCOPE) |
| 164 | message(STATUS "Manually linking compiler-rt library: ${LIBCXX_SANITIZER_LIBRARY}") |
Eric Fiselier | 10ed6c3 | 2015-07-30 22:30:34 | [diff] [blame] | 165 | add_library_flags("${LIBCXX_SANITIZER_LIBRARY}") |
| 166 | add_link_flags("-Wl,-rpath,${LIBDIR}") |
Eric Fiselier | d1bac4c | 2015-07-22 00:33:36 | [diff] [blame] | 167 | endif() |
| 168 | endif() |
| 169 | |
Louis Dionne | 989eca6 | 2019-03-14 14:19:08 | [diff] [blame] | 170 | split_list(LIBCXX_COMPILE_FLAGS) |
| 171 | split_list(LIBCXX_LINK_FLAGS) |
Petr Hosek | 9e49a33 | 2016-08-08 22:57:25 | [diff] [blame] | 172 | |
Michael Jones | 6c4267f | 2024-10-21 22:04:06 | [diff] [blame] | 173 | include(FindLibcCommonUtils) |
| 174 | |
Petr Hosek | 9e49a33 | 2016-08-08 22:57:25 | [diff] [blame] | 175 | # Build the shared library. |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 176 | add_library(cxx_shared SHARED ${LIBCXX_SOURCES} ${LIBCXX_HEADERS}) |
| 177 | target_include_directories(cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) |
| 178 | target_link_libraries(cxx_shared PUBLIC cxx-headers libcxx-libc-shared |
Michael Jones | 6c4267f | 2024-10-21 22:04:06 | [diff] [blame] | 179 | PRIVATE ${LIBCXX_LIBRARIES} |
| 180 | PRIVATE llvm-libc-common-utilities) |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 181 | set_target_properties(cxx_shared |
| 182 | PROPERTIES |
| 183 | EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBCXX_ENABLE_SHARED}>,FALSE,TRUE>" |
| 184 | COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" |
| 185 | LINK_FLAGS "${LIBCXX_LINK_FLAGS}" |
| 186 | OUTPUT_NAME "${LIBCXX_SHARED_OUTPUT_NAME}" |
| 187 | VERSION "${LIBCXX_LIBRARY_VERSION}" |
| 188 | SOVERSION "${LIBCXX_ABI_VERSION}" |
| 189 | DEFINE_SYMBOL "" |
| 190 | ) |
| 191 | cxx_add_common_build_flags(cxx_shared) |
| 192 | |
| 193 | if(ZOS) |
| 194 | add_custom_command(TARGET cxx_shared POST_BUILD |
| 195 | COMMAND |
| 196 | ${LIBCXX_SOURCE_DIR}/utils/zos_rename_dll_side_deck.sh |
| 197 | $<TARGET_LINKER_FILE_NAME:cxx_shared> $<TARGET_FILE_NAME:cxx_shared> "${LIBCXX_DLL_NAME}" |
| 198 | COMMENT "Rename dll name inside the side deck file" |
| 199 | WORKING_DIRECTORY $<TARGET_FILE_DIR:cxx_shared> |
Michael J. Spencer | f5799be | 2010-12-10 19:47:54 | [diff] [blame] | 200 | ) |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 201 | endif() |
Louis Dionne | 989eca6 | 2019-03-14 14:19:08 | [diff] [blame] | 202 | |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 203 | # Link against libc++abi |
| 204 | if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) |
| 205 | target_link_libraries(cxx_shared PRIVATE libcxx-abi-shared-objects) |
| 206 | else() |
| 207 | target_link_libraries(cxx_shared PUBLIC libcxx-abi-shared) |
| 208 | endif() |
Louis Dionne | 6e68a79 | 2019-04-05 20:29:54 | [diff] [blame] | 209 | |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 210 | # Maybe force some symbols to be weak, not weak or not exported. |
| 211 | # TODO: This shouldn't depend on the platform, and ideally it should be done in the sources. |
| 212 | if (APPLE AND LIBCXX_CXX_ABI MATCHES "libcxxabi$" |
| 213 | AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY) |
| 214 | target_link_libraries(cxx_shared PRIVATE |
| 215 | "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/notweak.exp" |
| 216 | "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR}/../lib/weak.exp") |
| 217 | endif() |
Louis Dionne | 79ee034 | 2022-09-19 20:17:02 | [diff] [blame] | 218 | |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 219 | # Generate a linker script in place of a libc++.so symlink. |
| 220 | if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
| 221 | set(link_libraries) |
Haowei Wu | a353909 | 2022-10-12 19:54:48 | [diff] [blame] | 222 | |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 223 | set(imported_libname "$<TARGET_PROPERTY:libcxx-abi-shared,IMPORTED_LIBNAME>") |
| 224 | set(output_name "$<TARGET_PROPERTY:libcxx-abi-shared,OUTPUT_NAME>") |
| 225 | string(APPEND link_libraries "${CMAKE_LINK_LIBRARY_FLAG}$<IF:$<BOOL:${imported_libname}>,${imported_libname},${output_name}>") |
Haowei Wu | a353909 | 2022-10-12 19:54:48 | [diff] [blame] | 226 | |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 227 | # TODO: Move to the same approach as above for the unwind library |
| 228 | if (LIBCXXABI_USE_LLVM_UNWINDER) |
| 229 | if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY) |
| 230 | # libunwind is already included in libc++abi |
| 231 | elseif (TARGET unwind_shared OR HAVE_LIBUNWIND) |
| 232 | string(APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG}$<TARGET_PROPERTY:unwind_shared,OUTPUT_NAME>") |
| 233 | else() |
| 234 | string(APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG}unwind") |
Haowei Wu | a353909 | 2022-10-12 19:54:48 | [diff] [blame] | 235 | endif() |
Haowei Wu | a353909 | 2022-10-12 19:54:48 | [diff] [blame] | 236 | endif() |
| 237 | |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 238 | set(linker_script "INPUT($<TARGET_SONAME_FILE_NAME:cxx_shared> ${link_libraries})") |
| 239 | add_custom_command(TARGET cxx_shared POST_BUILD |
| 240 | COMMAND "${CMAKE_COMMAND}" -E remove "$<TARGET_LINKER_FILE:cxx_shared>" |
| 241 | COMMAND "${CMAKE_COMMAND}" -E echo "${linker_script}" > "$<TARGET_LINKER_FILE:cxx_shared>" |
| 242 | COMMENT "Generating linker script: '${linker_script}' as file $<TARGET_LINKER_FILE:cxx_shared>" |
| 243 | VERBATIM |
| 244 | ) |
| 245 | endif() |
| 246 | |
Louis Dionne | 917ada3 | 2024-10-10 12:00:01 | [diff] [blame] | 247 | if (LIBCXX_ENABLE_SHARED) |
Petr Hosek | 4a1e14e | 2018-07-24 23:27:51 | [diff] [blame] | 248 | list(APPEND LIBCXX_BUILD_TARGETS "cxx_shared") |
Louis Dionne | 917ada3 | 2024-10-10 12:00:01 | [diff] [blame] | 249 | endif() |
| 250 | |
Martin Storsjö | b87fdd9 | 2025-01-14 11:43:10 | [diff] [blame] | 251 | if(WIN32 AND NOT MINGW AND NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") |
| 252 | # Since we most likely do not have a mt.exe replacement, disable the |
| 253 | # manifest bundling. This allows a normal cmake invocation to pass which |
| 254 | # will attempt to use the manifest tool to generate the bundled manifest |
| 255 | if (${CMAKE_CXX_COMPILER_FRONTEND_VARIANT} STREQUAL "MSVC") |
| 256 | set_target_properties(cxx_shared PROPERTIES |
| 257 | APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO") |
| 258 | else() |
| 259 | set_target_properties(cxx_shared PROPERTIES |
| 260 | APPEND_STRING PROPERTY LINK_FLAGS " -Xlinker /MANIFEST:NO") |
Haowei Wu | a353909 | 2022-10-12 19:54:48 | [diff] [blame] | 261 | endif() |
Martin Storsjö | b87fdd9 | 2025-01-14 11:43:10 | [diff] [blame] | 262 | endif() |
Petr Hosek | 9e49a33 | 2016-08-08 22:57:25 | [diff] [blame] | 263 | |
Martin Storsjö | 7a804c0 | 2021-03-23 11:23:16 | [diff] [blame] | 264 | set(CMAKE_STATIC_LIBRARY_PREFIX "lib") |
| 265 | |
Petr Hosek | 9e49a33 | 2016-08-08 22:57:25 | [diff] [blame] | 266 | # Build the static library. |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 267 | add_library(cxx_static STATIC ${LIBCXX_SOURCES} ${LIBCXX_HEADERS}) |
| 268 | target_include_directories(cxx_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) |
| 269 | target_link_libraries(cxx_static PUBLIC cxx-headers libcxx-libc-static |
| 270 | PRIVATE ${LIBCXX_LIBRARIES} |
Michael Jones | 6c4267f | 2024-10-21 22:04:06 | [diff] [blame] | 271 | PRIVATE libcxx-abi-static |
| 272 | PRIVATE llvm-libc-common-utilities) |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 273 | set_target_properties(cxx_static |
| 274 | PROPERTIES |
| 275 | EXCLUDE_FROM_ALL "$<IF:$<BOOL:${LIBCXX_ENABLE_STATIC}>,FALSE,TRUE>" |
| 276 | COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" |
| 277 | LINK_FLAGS "${LIBCXX_LINK_FLAGS}" |
| 278 | OUTPUT_NAME "${LIBCXX_STATIC_OUTPUT_NAME}" |
| 279 | ) |
| 280 | cxx_add_common_build_flags(cxx_static) |
Haowei Wu | a353909 | 2022-10-12 19:54:48 | [diff] [blame] | 281 | |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 282 | if (LIBCXX_HERMETIC_STATIC_LIBRARY) |
| 283 | # If the hermetic library doesn't define the operator new/delete functions |
| 284 | # then its code shouldn't declare them with hidden visibility. They might |
| 285 | # actually be provided by a shared library at link time. |
| 286 | if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS) |
| 287 | append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete=force-hidden) |
| 288 | if (NOT CXX_SUPPORTS_FVISIBILITY_GLOBAL_NEW_DELETE_EQ_FORCE_HIDDEN_FLAG) |
| 289 | append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global-new-delete-hidden) |
Haowei Wu | a353909 | 2022-10-12 19:54:48 | [diff] [blame] | 290 | endif() |
Haowei Wu | a353909 | 2022-10-12 19:54:48 | [diff] [blame] | 291 | endif() |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 292 | target_compile_options(cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS}) |
| 293 | # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site |
| 294 | # too. Define it in the same way here, to avoid redefinition conflicts. |
| 295 | target_compile_definitions(cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=) |
| 296 | endif() |
Haowei Wu | a353909 | 2022-10-12 19:54:48 | [diff] [blame] | 297 | |
Louis Dionne | 43ba97e | 2024-10-10 17:13:17 | [diff] [blame] | 298 | if (LIBCXX_ENABLE_STATIC) |
| 299 | list(APPEND LIBCXX_BUILD_TARGETS "cxx_static") |
| 300 | endif() |
| 301 | # Attempt to merge the libc++.a archive and the ABI library archive into one. |
| 302 | if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY) |
| 303 | target_link_libraries(cxx_static PRIVATE libcxx-abi-static-objects) |
| 304 | endif() |
Petr Hosek | 9e49a33 | 2016-08-08 22:57:25 | [diff] [blame] | 305 | |
Eric Fiselier | 67ea02b | 2018-07-27 03:47:46 | [diff] [blame] | 306 | # Add a meta-target for both libraries. |
Louis Dionne | efa40eb | 2020-06-26 20:05:55 | [diff] [blame] | 307 | add_custom_target(cxx DEPENDS ${LIBCXX_BUILD_TARGETS}) |
Eric Fiselier | 67ea02b | 2018-07-27 03:47:46 | [diff] [blame] | 308 | |
Louis Dionne | 917ada3 | 2024-10-10 12:00:01 | [diff] [blame] | 309 | # Build the experimental static library |
Louis Dionne | 7300a65 | 2022-07-19 14:44:06 | [diff] [blame] | 310 | set(LIBCXX_EXPERIMENTAL_SOURCES |
Louis Dionne | 12bb291 | 2023-11-27 15:54:35 | [diff] [blame] | 311 | experimental/keep.cpp |
Eric Fiselier | 27cb2f1 | 2016-05-03 21:30:18 | [diff] [blame] | 312 | ) |
Martin Storsjö | 0d7de7a | 2022-07-07 06:49:25 | [diff] [blame] | 313 | |
Louis Dionne | d423d80 | 2024-04-17 17:36:53 | [diff] [blame] | 314 | if (LIBCXX_PSTL_BACKEND STREQUAL "libdispatch") |
Nico Weber | 7a9b8a8 | 2023-07-13 12:35:06 | [diff] [blame] | 315 | list(APPEND LIBCXX_EXPERIMENTAL_SOURCES |
| 316 | pstl/libdispatch.cpp |
| 317 | ) |
Nikolas Klauser | 2b2e7f6 | 2023-07-12 20:24:57 | [diff] [blame] | 318 | endif() |
| 319 | |
Mark de Wever | f78f93b | 2022-09-23 16:33:20 | [diff] [blame] | 320 | if (LIBCXX_ENABLE_LOCALIZATION AND LIBCXX_ENABLE_FILESYSTEM AND LIBCXX_ENABLE_TIME_ZONE_DATABASE) |
| 321 | list(APPEND LIBCXX_EXPERIMENTAL_SOURCES |
Mark de Wever | 9d6b68b | 2024-07-07 09:17:34 | [diff] [blame] | 322 | experimental/include/tzdb/time_zone_private.h |
| 323 | experimental/include/tzdb/types_private.h |
| 324 | experimental/include/tzdb/tzdb_list_private.h |
| 325 | experimental/include/tzdb/tzdb_private.h |
Mark de Wever | 77116bd | 2024-06-09 22:33:39 | [diff] [blame] | 326 | # TODO TZDB The exception could be moved in chrono once the TZDB library |
| 327 | # is no longer experimental. |
Mark de Wever | 9d6b68b | 2024-07-07 09:17:34 | [diff] [blame] | 328 | experimental/chrono_exception.cpp |
| 329 | experimental/time_zone.cpp |
| 330 | experimental/tzdb.cpp |
| 331 | experimental/tzdb_list.cpp |
Mark de Wever | f78f93b | 2022-09-23 16:33:20 | [diff] [blame] | 332 | ) |
| 333 | endif() |
| 334 | |
Louis Dionne | 7300a65 | 2022-07-19 14:44:06 | [diff] [blame] | 335 | add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES}) |
| 336 | target_link_libraries(cxx_experimental PUBLIC cxx-headers) |
| 337 | if (LIBCXX_ENABLE_SHARED) |
| 338 | target_link_libraries(cxx_experimental PRIVATE cxx_shared) |
| 339 | else() |
| 340 | target_link_libraries(cxx_experimental PRIVATE cxx_static) |
Eric Fiselier | 27cb2f1 | 2016-05-03 21:30:18 | [diff] [blame] | 341 | endif() |
Louis Dionne | fadc84a | 2019-10-04 22:50:23 | [diff] [blame] | 342 | |
Louis Dionne | 7300a65 | 2022-07-19 14:44:06 | [diff] [blame] | 343 | if (LIBCXX_HERMETIC_STATIC_LIBRARY) |
| 344 | # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site |
| 345 | # too. Define it in the same way here, to avoid redefinition conflicts. |
| 346 | target_compile_definitions(cxx_experimental PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=) |
| 347 | endif() |
| 348 | |
| 349 | set_target_properties(cxx_experimental |
| 350 | PROPERTIES |
| 351 | COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}" |
| 352 | OUTPUT_NAME "c++experimental" |
| 353 | ) |
| 354 | cxx_add_common_build_flags(cxx_experimental) |
Louis Dionne | 8711fca | 2022-06-30 15:57:52 | [diff] [blame] | 355 | target_compile_options(cxx_experimental PUBLIC -D_LIBCPP_ENABLE_EXPERIMENTAL) |
Louis Dionne | 7300a65 | 2022-07-19 14:44:06 | [diff] [blame] | 356 | |
Louis Dionne | 4bd3d16 | 2020-10-09 19:04:12 | [diff] [blame] | 357 | if (LIBCXX_INSTALL_SHARED_LIBRARY) |
| 358 | install(TARGETS cxx_shared |
Petr Hosek | 96d8c6b | 2021-04-01 00:34:05 | [diff] [blame] | 359 | ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx |
| 360 | LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx |
Martin Storsjö | c4e8a21 | 2021-08-11 10:44:06 | [diff] [blame] | 361 | RUNTIME DESTINATION ${LIBCXX_INSTALL_RUNTIME_DIR} COMPONENT cxx) |
Eric Fiselier | d77135f | 2015-08-26 20:18:21 | [diff] [blame] | 362 | endif() |
Eric Fiselier | 7cb813f | 2015-08-19 17:41:53 | [diff] [blame] | 363 | |
Louis Dionne | 4bd3d16 | 2020-10-09 19:04:12 | [diff] [blame] | 364 | if (LIBCXX_INSTALL_STATIC_LIBRARY) |
| 365 | install(TARGETS cxx_static |
Petr Hosek | 96d8c6b | 2021-04-01 00:34:05 | [diff] [blame] | 366 | ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx |
| 367 | LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx |
Martin Storsjö | c4e8a21 | 2021-08-11 10:44:06 | [diff] [blame] | 368 | RUNTIME DESTINATION ${LIBCXX_INSTALL_RUNTIME_DIR} COMPONENT cxx) |
Louis Dionne | 4bd3d16 | 2020-10-09 19:04:12 | [diff] [blame] | 369 | endif() |
| 370 | |
Louis Dionne | 7300a65 | 2022-07-19 14:44:06 | [diff] [blame] | 371 | if (LIBCXX_INSTALL_LIBRARY) |
Louis Dionne | 4bd3d16 | 2020-10-09 19:04:12 | [diff] [blame] | 372 | install(TARGETS cxx_experimental |
Petr Hosek | 96d8c6b | 2021-04-01 00:34:05 | [diff] [blame] | 373 | LIBRARY DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx |
| 374 | ARCHIVE DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} COMPONENT cxx |
Martin Storsjö | c4e8a21 | 2021-08-11 10:44:06 | [diff] [blame] | 375 | RUNTIME DESTINATION ${LIBCXX_INSTALL_RUNTIME_DIR} COMPONENT cxx) |
Louis Dionne | 4bd3d16 | 2020-10-09 19:04:12 | [diff] [blame] | 376 | endif() |
| 377 | |
| 378 | # NOTE: This install command must go after the cxx install command otherwise |
| 379 | # it will not be executed after the library symlinks are installed. |
| 380 | if (LIBCXX_ENABLE_SHARED AND LIBCXX_ENABLE_ABI_LINKER_SCRIPT) |
Louis Dionne | 5034d71 | 2021-02-23 23:26:15 | [diff] [blame] | 381 | install(FILES "$<TARGET_LINKER_FILE:cxx_shared>" |
Petr Hosek | 96d8c6b | 2021-04-01 00:34:05 | [diff] [blame] | 382 | DESTINATION ${LIBCXX_INSTALL_LIBRARY_DIR} |
Louis Dionne | 4bd3d16 | 2020-10-09 19:04:12 | [diff] [blame] | 383 | COMPONENT libcxx) |
| 384 | endif() |
| 385 | |
| 386 | if (NOT CMAKE_CONFIGURATION_TYPES) |
Chris Bieneman | a1b79ae | 2015-12-03 18:52:54 | [diff] [blame] | 387 | if(LIBCXX_INSTALL_LIBRARY) |
Louis Dionne | 7300a65 | 2022-07-19 14:44:06 | [diff] [blame] | 388 | set(lib_install_target "cxx;cxx_experimental") |
Eric Fiselier | 27cb2f1 | 2016-05-03 21:30:18 | [diff] [blame] | 389 | endif() |
Chris Bieneman | 4497e3a | 2016-04-29 22:17:15 | [diff] [blame] | 390 | if(LIBCXX_INSTALL_HEADERS) |
Chris Bieneman | f17227a | 2016-08-24 22:17:06 | [diff] [blame] | 391 | set(header_install_target install-cxx-headers) |
Chris Bieneman | 4497e3a | 2016-04-29 22:17:15 | [diff] [blame] | 392 | endif() |
Mark de Wever | ae8d699 | 2024-01-21 11:27:21 | [diff] [blame] | 393 | if(LIBCXX_INSTALL_MODULES) |
Mark de Wever | 8b47bb6 | 2024-01-21 11:16:22 | [diff] [blame] | 394 | set(module_install_target install-cxx-modules) |
| 395 | endif() |
Chris Bieneman | f17227a | 2016-08-24 22:17:06 | [diff] [blame] | 396 | add_custom_target(install-cxx |
Eric Fiselier | 27cb2f1 | 2016-05-03 21:30:18 | [diff] [blame] | 397 | DEPENDS ${lib_install_target} |
Louis Dionne | 7300a65 | 2022-07-19 14:44:06 | [diff] [blame] | 398 | cxx_experimental |
Eric Fiselier | 27cb2f1 | 2016-05-03 21:30:18 | [diff] [blame] | 399 | ${header_install_target} |
Mark de Wever | 8b47bb6 | 2024-01-21 11:16:22 | [diff] [blame] | 400 | ${module_install_target} |
Eric Fiselier | d77135f | 2015-08-26 20:18:21 | [diff] [blame] | 401 | COMMAND "${CMAKE_COMMAND}" |
Chris Bieneman | f17227a | 2016-08-24 22:17:06 | [diff] [blame] | 402 | -DCMAKE_INSTALL_COMPONENT=cxx |
Eric Fiselier | d77135f | 2015-08-26 20:18:21 | [diff] [blame] | 403 | -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake") |
Shoaib Meenai | f7c7944 | 2017-12-06 21:03:42 | [diff] [blame] | 404 | add_custom_target(install-cxx-stripped |
| 405 | DEPENDS ${lib_install_target} |
Louis Dionne | 7300a65 | 2022-07-19 14:44:06 | [diff] [blame] | 406 | cxx_experimental |
Shoaib Meenai | f7c7944 | 2017-12-06 21:03:42 | [diff] [blame] | 407 | ${header_install_target} |
Mark de Wever | 8b47bb6 | 2024-01-21 11:16:22 | [diff] [blame] | 408 | ${module_install_target} |
Shoaib Meenai | f7c7944 | 2017-12-06 21:03:42 | [diff] [blame] | 409 | COMMAND "${CMAKE_COMMAND}" |
| 410 | -DCMAKE_INSTALL_COMPONENT=cxx |
| 411 | -DCMAKE_INSTALL_DO_STRIP=1 |
| 412 | -P "${LIBCXX_BINARY_DIR}/cmake_install.cmake") |
Eric Fiselier | 7cb813f | 2015-08-19 17:41:53 | [diff] [blame] | 413 | endif() |