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