@@ -147,6 +147,10 @@ if (LIBCXX_CONFIGURE_IDE)
147
147
endif ()
148
148
endif ()
149
149
150
+ if (NOT LIBCXX_INSTALL_LIBRARY)
151
+ set (exclude_from_all EXCLUDE_FROM_ALL )
152
+ endif ()
153
+
150
154
if (LIBCXX_GENERATE_COVERAGE AND NOT LIBCXX_COVERAGE_LIBRARY)
151
155
find_compiler_rt_library(profile LIBCXX_COVERAGE_LIBRARY)
152
156
endif ()
@@ -191,146 +195,139 @@ endfunction()
191
195
split_list(LIBCXX_COMPILE_FLAGS)
192
196
split_list(LIBCXX_LINK_FLAGS)
193
197
194
- #
195
198
# Build the shared library.
196
- #
197
- add_library (cxx_shared SHARED $<$<NOT :$<BOOL :LIBCXX_ENABLE_SHARED>>:EXCLUDE_FROM_ALL > ${LIBCXX_SOURCES} ${LIBCXX_HEADERS} )
198
- target_include_directories (cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} )
199
- target_link_libraries (cxx_shared PUBLIC cxx-headers
200
- PRIVATE ${LIBCXX_LIBRARIES} )
201
- set_target_properties (cxx_shared
202
- PROPERTIES
203
- COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS} "
204
- LINK_FLAGS "${LIBCXX_LINK_FLAGS} "
205
- OUTPUT_NAME "${LIBCXX_SHARED_OUTPUT_NAME} "
206
- VERSION "${LIBCXX_LIBRARY_VERSION} "
207
- SOVERSION "${LIBCXX_ABI_VERSION} "
208
- DEFINE_SYMBOL ""
209
- )
210
- cxx_add_common_build_flags(cxx_shared)
211
- cxx_set_common_defines(cxx_shared)
212
-
213
- if (ZOS)
214
- add_custom_command (TARGET cxx_shared POST_BUILD
215
- COMMAND
216
- ${LIBCXX_SOURCE_DIR} /utils/zos_rename_dll_side_deck.sh
217
- $<TARGET_LINKER_FILE_NAME:cxx_shared> $<TARGET_FILE_NAME:cxx_shared> "${LIBCXX_DLL_NAME} "
218
- COMMENT "Rename dll name inside the side deck file"
219
- WORKING_DIRECTORY $<TARGET_FILE_DIR:cxx_shared>
199
+ if (LIBCXX_ENABLE_SHARED)
200
+ add_library (cxx_shared SHARED ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS} )
201
+ target_include_directories (cxx_shared PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} )
202
+ target_link_libraries (cxx_shared PUBLIC cxx-headers
203
+ PRIVATE ${LIBCXX_LIBRARIES} )
204
+ set_target_properties (cxx_shared
205
+ PROPERTIES
206
+ COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS} "
207
+ LINK_FLAGS "${LIBCXX_LINK_FLAGS} "
208
+ OUTPUT_NAME "${LIBCXX_SHARED_OUTPUT_NAME} "
209
+ VERSION "${LIBCXX_LIBRARY_VERSION} "
210
+ SOVERSION "${LIBCXX_ABI_VERSION} "
211
+ DEFINE_SYMBOL ""
220
212
)
221
- endif ()
213
+ cxx_add_common_build_flags(cxx_shared)
214
+ cxx_set_common_defines(cxx_shared)
215
+
216
+ if (ZOS)
217
+ add_custom_command (TARGET cxx_shared POST_BUILD
218
+ COMMAND
219
+ ${LIBCXX_SOURCE_DIR} /utils/zos_rename_dll_side_deck.sh
220
+ $<TARGET_LINKER_FILE_NAME:cxx_shared> $<TARGET_FILE_NAME:cxx_shared> "${LIBCXX_DLL_NAME} "
221
+ COMMENT "Rename dll name inside the side deck file"
222
+ WORKING_DIRECTORY $<TARGET_FILE_DIR:cxx_shared>
223
+ )
224
+ endif ()
222
225
223
- # Link against libc++abi
224
- if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
225
- target_link_libraries (cxx_shared PRIVATE libcxx-abi-shared-objects)
226
- else ()
227
- target_link_libraries (cxx_shared PUBLIC libcxx-abi-shared)
228
- endif ()
226
+ # Link against libc++abi
227
+ if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
228
+ target_link_libraries (cxx_shared PRIVATE libcxx-abi-shared-objects)
229
+ else ()
230
+ target_link_libraries (cxx_shared PUBLIC libcxx-abi-shared)
231
+ endif ()
229
232
230
- # Maybe re-export symbols from libc++abi
231
- # In particular, we don't re-export the symbols if libc++abi is merged statically
232
- # into libc++ because in that case there's no dylib to re-export from.
233
- if (APPLE AND LIBCXX_CXX_ABI STREQUAL "libcxxabi"
234
- AND NOT DEFINED LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS
235
- AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
236
- set (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS ON )
237
- endif ()
233
+ # Maybe re-export symbols from libc++abi
234
+ # In particular, we don't re-export the symbols if libc++abi is merged statically
235
+ # into libc++ because in that case there's no dylib to re-export from.
236
+ if (APPLE AND LIBCXX_CXX_ABI STREQUAL "libcxxabi"
237
+ AND NOT DEFINED LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS
238
+ AND NOT LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
239
+ set (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS ON )
240
+ endif ()
238
241
239
- if (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
240
- target_link_libraries (cxx_shared PRIVATE
241
- "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR} /../lib/libc++unexp.exp"
242
- "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR} /../lib/libc++abi.exp"
243
- "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR} /../lib/notweak.exp"
244
- "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR} /../lib/weak.exp" )
242
+ if (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
243
+ target_link_libraries (cxx_shared PRIVATE
244
+ "-Wl,-unexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR} /../lib/libc++unexp.exp"
245
+ "-Wl,-reexported_symbols_list,${CMAKE_CURRENT_SOURCE_DIR} /../lib/libc++abi.exp"
246
+ "-Wl,-force_symbols_not_weak_list,${CMAKE_CURRENT_SOURCE_DIR} /../lib/notweak.exp"
247
+ "-Wl,-force_symbols_weak_list,${CMAKE_CURRENT_SOURCE_DIR} /../lib/weak.exp" )
245
248
246
- target_link_libraries (cxx_shared PRIVATE $<TARGET_NAME_IF_EXISTS:cxxabi-reexports>)
247
- endif ()
249
+ target_link_libraries (cxx_shared PRIVATE $<TARGET_NAME_IF_EXISTS:cxxabi-reexports>)
250
+ endif ()
248
251
249
- # Generate a linker script in place of a libc++.so symlink.
250
- if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
251
- set (link_libraries )
252
-
253
- set (imported_libname "$<TARGET_PROPERTY:libcxx-abi-shared,IMPORTED_LIBNAME>" )
254
- set (output_name "$<TARGET_PROPERTY:libcxx-abi-shared,OUTPUT_NAME>" )
255
- string (APPEND link_libraries "${CMAKE_LINK_LIBRARY_FLAG} $<IF:$<BOOL:${imported_libname} >,${imported_libname} ,${output_name} >" )
256
-
257
- # TODO: Move to the same approach as above for the unwind library
258
- if (LIBCXXABI_USE_LLVM_UNWINDER)
259
- if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
260
- # libunwind is already included in libc++abi
261
- elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
262
- string (APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG} $<TARGET_PROPERTY:unwind_shared,OUTPUT_NAME>" )
263
- else ()
264
- string (APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG} unwind" )
252
+ # Generate a linker script in place of a libc++.so symlink.
253
+ if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
254
+ set (link_libraries )
255
+
256
+ set (imported_libname "$<TARGET_PROPERTY:libcxx-abi-shared,IMPORTED_LIBNAME>" )
257
+ set (output_name "$<TARGET_PROPERTY:libcxx-abi-shared,OUTPUT_NAME>" )
258
+ string (APPEND link_libraries "${CMAKE_LINK_LIBRARY_FLAG} $<IF:$<BOOL:${imported_libname} >,${imported_libname} ,${output_name} >" )
259
+
260
+ # TODO: Move to the same approach as above for the unwind library
261
+ if (LIBCXXABI_USE_LLVM_UNWINDER)
262
+ if (LIBCXXABI_STATICALLY_LINK_UNWINDER_IN_SHARED_LIBRARY)
263
+ # libunwind is already included in libc++abi
264
+ elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
265
+ string (APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG} $<TARGET_PROPERTY:unwind_shared,OUTPUT_NAME>" )
266
+ else ()
267
+ string (APPEND link_libraries " ${CMAKE_LINK_LIBRARY_FLAG} unwind" )
268
+ endif ()
265
269
endif ()
266
- endif ()
267
270
268
- set (linker_script "INPUT($<TARGET_SONAME_FILE_NAME:cxx_shared> ${link_libraries} )" )
269
- add_custom_command (TARGET cxx_shared POST_BUILD
270
- COMMAND "${CMAKE_COMMAND} " -E remove "$<TARGET_LINKER_FILE:cxx_shared>"
271
- COMMAND "${CMAKE_COMMAND} " -E echo "${linker_script} " > "$<TARGET_LINKER_FILE:cxx_shared>"
272
- COMMENT "Generating linker script: '${linker_script} ' as file $<TARGET_LINKER_FILE:cxx_shared>"
273
- VERBATIM
274
- )
275
- endif ()
271
+ set (linker_script "INPUT($<TARGET_SONAME_FILE_NAME:cxx_shared> ${link_libraries} )" )
272
+ add_custom_command (TARGET cxx_shared POST_BUILD
273
+ COMMAND "${CMAKE_COMMAND} " -E remove "$<TARGET_LINKER_FILE:cxx_shared>"
274
+ COMMAND "${CMAKE_COMMAND} " -E echo "${linker_script} " > "$<TARGET_LINKER_FILE:cxx_shared>"
275
+ COMMENT "Generating linker script: '${linker_script} ' as file $<TARGET_LINKER_FILE:cxx_shared>"
276
+ VERBATIM
277
+ )
278
+ endif ()
276
279
277
- if (LIBCXX_ENABLE_SHARED)
278
280
list (APPEND LIBCXX_BUILD_TARGETS "cxx_shared" )
279
- endif ( )
280
- if ( WIN32 AND NOT MINGW AND NOT " ${CMAKE_HOST_SYSTEM_NAME} " STREQUAL "Windows" )
281
- # Since we most likely do not have a mt.exe replacement, disable the
282
- # manifest bundling. This allows a normal cmake invocation to pass which
283
- # will attempt to use the manifest tool to generate the bundled manifest
284
- set_target_properties (cxx_shared PROPERTIES
285
- APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO" )
281
+ if ( WIN32 AND NOT MINGW AND NOT " ${CMAKE_HOST_SYSTEM_NAME} " STREQUAL "Windows" )
282
+ # Since we most likely do not have a mt.exe replacement, disable the
283
+ # manifest bundling. This allows a normal cmake invocation to pass which
284
+ # will attempt to use the manifest tool to generate the bundled manifest
285
+ set_target_properties (cxx_shared PROPERTIES
286
+ APPEND_STRING PROPERTY LINK_FLAGS " /MANIFEST:NO" )
287
+ endif ( )
286
288
endif ()
287
289
288
290
set (CMAKE_STATIC_LIBRARY_PREFIX "lib" )
289
291
290
- #
291
292
# Build the static library.
292
- #
293
- add_library (cxx_static STATIC $<$<NOT :$<BOOL :LIBCXX_ENABLE_STATIC>>:EXCLUDE_FROM_ALL > ${LIBCXX_SOURCES} ${LIBCXX_HEADERS} )
294
- target_include_directories (cxx_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} )
295
- target_link_libraries (cxx_static PUBLIC cxx-headers
296
- PRIVATE ${LIBCXX_LIBRARIES}
297
- PRIVATE libcxx-abi-static )
298
- set_target_properties (cxx_static
299
- PROPERTIES
300
- COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS} "
301
- LINK_FLAGS "${LIBCXX_LINK_FLAGS} "
302
- OUTPUT_NAME "${LIBCXX_STATIC_OUTPUT_NAME} "
303
- )
304
- cxx_add_common_build_flags(cxx_static)
305
- cxx_set_common_defines(cxx_static)
306
-
307
- if (LIBCXX_HERMETIC_STATIC_LIBRARY)
308
- # If the hermetic library doesn't define the operator new/delete functions
309
- # then its code shouldn't declare them with hidden visibility. They might
310
- # actually be provided by a shared library at link time.
311
- if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
312
- append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global -new-delete-hidden)
293
+ if (LIBCXX_ENABLE_STATIC)
294
+ add_library (cxx_static STATIC ${exclude_from_all} ${LIBCXX_SOURCES} ${LIBCXX_HEADERS} )
295
+ target_include_directories (cxx_static PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} )
296
+ target_link_libraries (cxx_static PUBLIC cxx-headers
297
+ PRIVATE ${LIBCXX_LIBRARIES}
298
+ PRIVATE libcxx-abi-static )
299
+ set_target_properties (cxx_static
300
+ PROPERTIES
301
+ COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS} "
302
+ LINK_FLAGS "${LIBCXX_LINK_FLAGS} "
303
+ OUTPUT_NAME "${LIBCXX_STATIC_OUTPUT_NAME} "
304
+ )
305
+ cxx_add_common_build_flags(cxx_static)
306
+ cxx_set_common_defines(cxx_static)
307
+
308
+ if (LIBCXX_HERMETIC_STATIC_LIBRARY)
309
+ # If the hermetic library doesn't define the operator new/delete functions
310
+ # then its code shouldn't declare them with hidden visibility. They might
311
+ # actually be provided by a shared library at link time.
312
+ if (LIBCXX_ENABLE_NEW_DELETE_DEFINITIONS)
313
+ append_flags_if_supported(CXX_STATIC_LIBRARY_FLAGS -fvisibility-global -new-delete-hidden)
314
+ endif ()
315
+ target_compile_options (cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS} )
316
+ # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site
317
+ # too. Define it in the same way here, to avoid redefinition conflicts.
318
+ target_compile_definitions (cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=)
313
319
endif ()
314
- target_compile_options (cxx_static PRIVATE ${CXX_STATIC_LIBRARY_FLAGS} )
315
- # _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS can be defined in __config_site
316
- # too. Define it in the same way here, to avoid redefinition conflicts.
317
- target_compile_definitions (cxx_static PRIVATE _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS=)
318
- endif ()
319
320
320
- if (LIBCXX_ENABLE_STATIC)
321
321
list (APPEND LIBCXX_BUILD_TARGETS "cxx_static" )
322
- endif ()
323
- # Attempt to merge the libc++.a archive and the ABI library archive into one.
324
- if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY )
325
- target_link_libraries (cxx_static PRIVATE libcxx-abi- static -objects )
322
+ # Attempt to merge the libc++.a archive and the ABI library archive into one.
323
+ if (LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY)
324
+ target_link_libraries (cxx_static PRIVATE libcxx-abi- static -objects )
325
+ endif ( )
326
326
endif ()
327
327
328
328
# Add a meta-target for both libraries.
329
329
add_custom_target (cxx DEPENDS ${LIBCXX_BUILD_TARGETS} )
330
330
331
- #
332
- # Build the experimental static library
333
- #
334
331
set (LIBCXX_EXPERIMENTAL_SOURCES
335
332
experimental/memory_resource.cpp
336
333
format.cpp
0 commit comments