xref: /aosp_15_r20/external/webrtc/third_party/abseil-cpp/CMake/AbseilDll.cmake (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1include(CMakeParseArguments)
2include(GNUInstallDirs)
3
4set(ABSL_INTERNAL_DLL_FILES
5  "algorithm/algorithm.h"
6  "algorithm/container.h"
7  "base/attributes.h"
8  "base/call_once.h"
9  "base/casts.h"
10  "base/config.h"
11  "base/const_init.h"
12  "base/dynamic_annotations.h"
13  "base/internal/atomic_hook.h"
14  "base/internal/cycleclock.cc"
15  "base/internal/cycleclock.h"
16  "base/internal/cycleclock_config.h"
17  "base/internal/direct_mmap.h"
18  "base/internal/endian.h"
19  "base/internal/errno_saver.h"
20  "base/internal/fast_type_id.h"
21  "base/internal/hide_ptr.h"
22  "base/internal/identity.h"
23  "base/internal/invoke.h"
24  "base/internal/inline_variable.h"
25  "base/internal/low_level_alloc.cc"
26  "base/internal/low_level_alloc.h"
27  "base/internal/low_level_scheduling.h"
28  "base/internal/per_thread_tls.h"
29  "base/internal/prefetch.h"
30  "base/internal/pretty_function.h"
31  "base/internal/raw_logging.cc"
32  "base/internal/raw_logging.h"
33  "base/internal/scheduling_mode.h"
34  "base/internal/scoped_set_env.cc"
35  "base/internal/scoped_set_env.h"
36  "base/internal/strerror.h"
37  "base/internal/strerror.cc"
38  "base/internal/spinlock.cc"
39  "base/internal/spinlock.h"
40  "base/internal/spinlock_wait.cc"
41  "base/internal/spinlock_wait.h"
42  "base/internal/sysinfo.cc"
43  "base/internal/sysinfo.h"
44  "base/internal/thread_identity.cc"
45  "base/internal/thread_identity.h"
46  "base/internal/throw_delegate.cc"
47  "base/internal/throw_delegate.h"
48  "base/internal/tsan_mutex_interface.h"
49  "base/internal/unaligned_access.h"
50  "base/internal/unscaledcycleclock.cc"
51  "base/internal/unscaledcycleclock.h"
52  "base/internal/unscaledcycleclock_config.h"
53  "base/log_severity.cc"
54  "base/log_severity.h"
55  "base/macros.h"
56  "base/optimization.h"
57  "base/options.h"
58  "base/policy_checks.h"
59  "base/port.h"
60  "base/thread_annotations.h"
61  "cleanup/cleanup.h"
62  "cleanup/internal/cleanup.h"
63  "container/btree_map.h"
64  "container/btree_set.h"
65  "container/fixed_array.h"
66  "container/flat_hash_map.h"
67  "container/flat_hash_set.h"
68  "container/inlined_vector.h"
69  "container/internal/btree.h"
70  "container/internal/btree_container.h"
71  "container/internal/common.h"
72  "container/internal/common_policy_traits.h"
73  "container/internal/compressed_tuple.h"
74  "container/internal/container_memory.h"
75  "container/internal/counting_allocator.h"
76  "container/internal/hash_function_defaults.h"
77  "container/internal/hash_policy_traits.h"
78  "container/internal/hashtable_debug.h"
79  "container/internal/hashtable_debug_hooks.h"
80  "container/internal/hashtablez_sampler.cc"
81  "container/internal/hashtablez_sampler.h"
82  "container/internal/hashtablez_sampler_force_weak_definition.cc"
83  "container/internal/inlined_vector.h"
84  "container/internal/layout.h"
85  "container/internal/node_slot_policy.h"
86  "container/internal/raw_hash_map.h"
87  "container/internal/raw_hash_set.cc"
88  "container/internal/raw_hash_set.h"
89  "container/internal/tracked.h"
90  "container/node_hash_map.h"
91  "container/node_hash_set.h"
92  "debugging/failure_signal_handler.cc"
93  "debugging/failure_signal_handler.h"
94  "debugging/leak_check.h"
95  "debugging/stacktrace.cc"
96  "debugging/stacktrace.h"
97  "debugging/symbolize.cc"
98  "debugging/symbolize.h"
99  "debugging/internal/address_is_readable.cc"
100  "debugging/internal/address_is_readable.h"
101  "debugging/internal/demangle.cc"
102  "debugging/internal/demangle.h"
103  "debugging/internal/elf_mem_image.cc"
104  "debugging/internal/elf_mem_image.h"
105  "debugging/internal/examine_stack.cc"
106  "debugging/internal/examine_stack.h"
107  "debugging/internal/stack_consumption.cc"
108  "debugging/internal/stack_consumption.h"
109  "debugging/internal/stacktrace_config.h"
110  "debugging/internal/symbolize.h"
111  "debugging/internal/vdso_support.cc"
112  "debugging/internal/vdso_support.h"
113  "functional/any_invocable.h"
114  "functional/internal/front_binder.h"
115  "functional/bind_front.h"
116  "functional/function_ref.h"
117  "functional/internal/any_invocable.h"
118  "functional/internal/function_ref.h"
119  "hash/hash.h"
120  "hash/internal/city.h"
121  "hash/internal/city.cc"
122  "hash/internal/hash.h"
123  "hash/internal/hash.cc"
124  "hash/internal/spy_hash_state.h"
125  "hash/internal/low_level_hash.h"
126  "hash/internal/low_level_hash.cc"
127  "memory/memory.h"
128  "meta/type_traits.h"
129  "numeric/bits.h"
130  "numeric/int128.cc"
131  "numeric/int128.h"
132  "numeric/internal/bits.h"
133  "numeric/internal/representation.h"
134  "profiling/internal/exponential_biased.cc"
135  "profiling/internal/exponential_biased.h"
136  "profiling/internal/periodic_sampler.cc"
137  "profiling/internal/periodic_sampler.h"
138  "profiling/internal/sample_recorder.h"
139  "random/bernoulli_distribution.h"
140  "random/beta_distribution.h"
141  "random/bit_gen_ref.h"
142  "random/discrete_distribution.cc"
143  "random/discrete_distribution.h"
144  "random/distributions.h"
145  "random/exponential_distribution.h"
146  "random/gaussian_distribution.cc"
147  "random/gaussian_distribution.h"
148  "random/internal/distribution_caller.h"
149  "random/internal/fastmath.h"
150  "random/internal/fast_uniform_bits.h"
151  "random/internal/generate_real.h"
152  "random/internal/iostream_state_saver.h"
153  "random/internal/mock_helpers.h"
154  "random/internal/nonsecure_base.h"
155  "random/internal/pcg_engine.h"
156  "random/internal/platform.h"
157  "random/internal/pool_urbg.cc"
158  "random/internal/pool_urbg.h"
159  "random/internal/randen.cc"
160  "random/internal/randen.h"
161  "random/internal/randen_detect.cc"
162  "random/internal/randen_detect.h"
163  "random/internal/randen_engine.h"
164  "random/internal/randen_hwaes.cc"
165  "random/internal/randen_hwaes.h"
166  "random/internal/randen_round_keys.cc"
167  "random/internal/randen_slow.cc"
168  "random/internal/randen_slow.h"
169  "random/internal/randen_traits.h"
170  "random/internal/salted_seed_seq.h"
171  "random/internal/seed_material.cc"
172  "random/internal/seed_material.h"
173  "random/internal/sequence_urbg.h"
174  "random/internal/traits.h"
175  "random/internal/uniform_helper.h"
176  "random/internal/wide_multiply.h"
177  "random/log_uniform_int_distribution.h"
178  "random/poisson_distribution.h"
179  "random/random.h"
180  "random/seed_gen_exception.cc"
181  "random/seed_gen_exception.h"
182  "random/seed_sequences.cc"
183  "random/seed_sequences.h"
184  "random/uniform_int_distribution.h"
185  "random/uniform_real_distribution.h"
186  "random/zipf_distribution.h"
187  "status/internal/status_internal.h"
188  "status/internal/statusor_internal.h"
189  "status/status.h"
190  "status/status.cc"
191  "status/statusor.h"
192  "status/statusor.cc"
193  "status/status_payload_printer.h"
194  "status/status_payload_printer.cc"
195  "strings/ascii.cc"
196  "strings/ascii.h"
197  "strings/charconv.cc"
198  "strings/charconv.h"
199  "strings/cord.cc"
200  "strings/cord.h"
201  "strings/cord_analysis.cc"
202  "strings/cord_analysis.h"
203  "strings/cord_buffer.cc"
204  "strings/cord_buffer.h"
205  "strings/escaping.cc"
206  "strings/escaping.h"
207  "strings/internal/charconv_bigint.cc"
208  "strings/internal/charconv_bigint.h"
209  "strings/internal/charconv_parse.cc"
210  "strings/internal/charconv_parse.h"
211  "strings/internal/cord_data_edge.h"
212  "strings/internal/cord_internal.cc"
213  "strings/internal/cord_internal.h"
214  "strings/internal/cord_rep_btree.cc"
215  "strings/internal/cord_rep_btree.h"
216  "strings/internal/cord_rep_btree_navigator.cc"
217  "strings/internal/cord_rep_btree_navigator.h"
218  "strings/internal/cord_rep_btree_reader.cc"
219  "strings/internal/cord_rep_btree_reader.h"
220  "strings/internal/cord_rep_crc.cc"
221  "strings/internal/cord_rep_crc.h"
222  "strings/internal/cord_rep_consume.h"
223  "strings/internal/cord_rep_consume.cc"
224  "strings/internal/cord_rep_flat.h"
225  "strings/internal/cord_rep_ring.cc"
226  "strings/internal/cord_rep_ring.h"
227  "strings/internal/cord_rep_ring_reader.h"
228  "strings/internal/cordz_functions.cc"
229  "strings/internal/cordz_functions.h"
230  "strings/internal/cordz_handle.cc"
231  "strings/internal/cordz_handle.h"
232  "strings/internal/cordz_info.cc"
233  "strings/internal/cordz_info.h"
234  "strings/internal/cordz_sample_token.cc"
235  "strings/internal/cordz_sample_token.h"
236  "strings/internal/cordz_statistics.h"
237  "strings/internal/cordz_update_scope.h"
238  "strings/internal/cordz_update_tracker.h"
239  "strings/internal/damerau_levenshtein_distance.h"
240  "strings/internal/damerau_levenshtein_distance.cc"
241  "strings/internal/stl_type_traits.h"
242  "strings/internal/string_constant.h"
243  "strings/internal/stringify_sink.h"
244  "strings/internal/stringify_sink.cc"
245  "strings/match.cc"
246  "strings/match.h"
247  "strings/numbers.cc"
248  "strings/numbers.h"
249  "strings/str_format.h"
250  "strings/str_cat.cc"
251  "strings/str_cat.h"
252  "strings/str_join.h"
253  "strings/str_replace.cc"
254  "strings/str_replace.h"
255  "strings/str_split.cc"
256  "strings/str_split.h"
257  "strings/string_view.cc"
258  "strings/string_view.h"
259  "strings/strip.h"
260  "strings/substitute.cc"
261  "strings/substitute.h"
262  "strings/internal/char_map.h"
263  "strings/internal/escaping.h"
264  "strings/internal/escaping.cc"
265  "strings/internal/memutil.cc"
266  "strings/internal/memutil.h"
267  "strings/internal/ostringstream.cc"
268  "strings/internal/ostringstream.h"
269  "strings/internal/pow10_helper.cc"
270  "strings/internal/pow10_helper.h"
271  "strings/internal/resize_uninitialized.h"
272  "strings/internal/str_format/arg.cc"
273  "strings/internal/str_format/arg.h"
274  "strings/internal/str_format/bind.cc"
275  "strings/internal/str_format/bind.h"
276  "strings/internal/str_format/checker.h"
277  "strings/internal/str_format/extension.cc"
278  "strings/internal/str_format/extension.h"
279  "strings/internal/str_format/float_conversion.cc"
280  "strings/internal/str_format/float_conversion.h"
281  "strings/internal/str_format/output.cc"
282  "strings/internal/str_format/output.h"
283  "strings/internal/str_format/parser.cc"
284  "strings/internal/str_format/parser.h"
285  "strings/internal/str_join_internal.h"
286  "strings/internal/str_split_internal.h"
287  "strings/internal/utf8.cc"
288  "strings/internal/utf8.h"
289  "synchronization/barrier.cc"
290  "synchronization/barrier.h"
291  "synchronization/blocking_counter.cc"
292  "synchronization/blocking_counter.h"
293  "synchronization/mutex.cc"
294  "synchronization/mutex.h"
295  "synchronization/notification.cc"
296  "synchronization/notification.h"
297  "synchronization/internal/create_thread_identity.cc"
298  "synchronization/internal/create_thread_identity.h"
299  "synchronization/internal/futex.h"
300  "synchronization/internal/graphcycles.cc"
301  "synchronization/internal/graphcycles.h"
302  "synchronization/internal/kernel_timeout.h"
303  "synchronization/internal/per_thread_sem.cc"
304  "synchronization/internal/per_thread_sem.h"
305  "synchronization/internal/thread_pool.h"
306  "synchronization/internal/waiter.cc"
307  "synchronization/internal/waiter.h"
308  "time/civil_time.cc"
309  "time/civil_time.h"
310  "time/clock.cc"
311  "time/clock.h"
312  "time/duration.cc"
313  "time/format.cc"
314  "time/time.cc"
315  "time/time.h"
316  "time/internal/cctz/include/cctz/civil_time.h"
317  "time/internal/cctz/include/cctz/civil_time_detail.h"
318  "time/internal/cctz/include/cctz/time_zone.h"
319  "time/internal/cctz/include/cctz/zone_info_source.h"
320  "time/internal/cctz/src/civil_time_detail.cc"
321  "time/internal/cctz/src/time_zone_fixed.cc"
322  "time/internal/cctz/src/time_zone_fixed.h"
323  "time/internal/cctz/src/time_zone_format.cc"
324  "time/internal/cctz/src/time_zone_if.cc"
325  "time/internal/cctz/src/time_zone_if.h"
326  "time/internal/cctz/src/time_zone_impl.cc"
327  "time/internal/cctz/src/time_zone_impl.h"
328  "time/internal/cctz/src/time_zone_info.cc"
329  "time/internal/cctz/src/time_zone_info.h"
330  "time/internal/cctz/src/time_zone_libc.cc"
331  "time/internal/cctz/src/time_zone_libc.h"
332  "time/internal/cctz/src/time_zone_lookup.cc"
333  "time/internal/cctz/src/time_zone_posix.cc"
334  "time/internal/cctz/src/time_zone_posix.h"
335  "time/internal/cctz/src/tzfile.h"
336  "time/internal/cctz/src/zone_info_source.cc"
337  "types/any.h"
338  "types/bad_any_cast.cc"
339  "types/bad_any_cast.h"
340  "types/bad_optional_access.cc"
341  "types/bad_optional_access.h"
342  "types/bad_variant_access.cc"
343  "types/bad_variant_access.h"
344  "types/compare.h"
345  "types/internal/conformance_aliases.h"
346  "types/internal/conformance_archetype.h"
347  "types/internal/conformance_profile.h"
348  "types/internal/parentheses.h"
349  "types/internal/transform_args.h"
350  "types/internal/variant.h"
351  "types/optional.h"
352  "types/internal/optional.h"
353  "types/span.h"
354  "types/internal/span.h"
355  "types/variant.h"
356  "utility/utility.h"
357  "debugging/leak_check.cc"
358)
359
360set(ABSL_INTERNAL_DLL_TARGETS
361  "algorithm"
362  "algorithm_container"
363  "any"
364  "any_invocable"
365  "atomic_hook"
366  "bad_any_cast"
367  "bad_any_cast_impl"
368  "bad_optional_access"
369  "bad_variant_access"
370  "base"
371  "base_internal"
372  "bind_front"
373  "bits"
374  "btree"
375  "city"
376  "civil_time"
377  "compare"
378  "compressed_tuple"
379  "config"
380  "container"
381  "container_common"
382  "container_memory"
383  "cord"
384  "core_headers"
385  "counting_allocator"
386  "debugging"
387  "debugging_internal"
388  "demangle_internal"
389  "dynamic_annotations"
390  "endian"
391  "examine_stack"
392  "exponential_biased"
393  "failure_signal_handler"
394  "fixed_array"
395  "flat_hash_map"
396  "flat_hash_set"
397  "function_ref"
398  "graphcycles_internal"
399  "hash"
400  "hash_function_defaults"
401  "hash_policy_traits"
402  "hashtable_debug"
403  "hashtable_debug_hooks"
404  "hashtablez_sampler"
405  "inlined_vector"
406  "inlined_vector_internal"
407  "int128"
408  "kernel_timeout_internal"
409  "layout"
410  "leak_check"
411  "log_severity"
412  "malloc_internal"
413  "memory"
414  "meta"
415  "node_hash_map"
416  "node_hash_set"
417  "node_slot_policy"
418  "numeric"
419  "optional"
420  "periodic_sampler"
421  "pow10_helper"
422  "pretty_function"
423  "random_bit_gen_ref"
424  "random_distributions"
425  "random_internal_distribution_caller"
426  "random_internal_distributions"
427  "random_internal_explicit_seed_seq"
428  "random_internal_fastmath"
429  "random_internal_fast_uniform_bits"
430  "random_internal_generate_real"
431  "random_internal_iostream_state_saver"
432  "random_internal_nonsecure_base"
433  "random_internal_pcg_engine"
434  "random_internal_platform"
435  "random_internal_pool_urbg"
436  "random_internal_randen"
437  "random_internal_randen_engine"
438  "random_internal_randen_hwaes"
439  "random_internal_randen_hwaes_impl"
440  "random_internal_randen_slow"
441  "random_internal_salted_seed_seq"
442  "random_internal_seed_material"
443  "random_internal_sequence_urbg"
444  "random_internal_traits"
445  "random_internal_uniform_helper"
446  "random_internal_wide_multiply"
447  "random_random"
448  "random_seed_gen_exception"
449  "random_seed_sequences"
450  "raw_hash_map"
451  "raw_hash_set"
452  "raw_logging_internal"
453  "sample_recorder"
454  "scoped_set_env"
455  "span"
456  "spinlock_wait"
457  "spy_hash_state"
458  "stack_consumption"
459  "stacktrace"
460  "status"
461  "str_format"
462  "str_format_internal"
463  "strings"
464  "strings_internal"
465  "symbolize"
466  "synchronization"
467  "thread_pool"
468  "throw_delegate"
469  "time"
470  "time_zone"
471  "tracked"
472  "type_traits"
473  "utility"
474  "variant"
475)
476
477function(_absl_target_compile_features_if_available TARGET TYPE FEATURE)
478  if(FEATURE IN_LIST CMAKE_CXX_COMPILE_FEATURES)
479    target_compile_features(${TARGET} ${TYPE} ${FEATURE})
480  else()
481    message(WARNING "Feature ${FEATURE} is unknown for the CXX compiler")
482  endif()
483endfunction()
484
485include(CheckCXXSourceCompiles)
486
487check_cxx_source_compiles(
488  [==[
489#ifdef _MSC_VER
490#  if _MSVC_LANG < 201700L
491#    error "The compiler defaults or is configured for C++ < 17"
492#  endif
493#elif __cplusplus < 201700L
494#  error "The compiler defaults or is configured for C++ < 17"
495#endif
496int main() { return 0; }
497]==]
498  ABSL_INTERNAL_AT_LEAST_CXX17)
499
500if(ABSL_INTERNAL_AT_LEAST_CXX17)
501  set(ABSL_INTERNAL_CXX_STD_FEATURE cxx_std_17)
502else()
503  set(ABSL_INTERNAL_CXX_STD_FEATURE cxx_std_14)
504endif()
505
506function(absl_internal_dll_contains)
507  cmake_parse_arguments(ABSL_INTERNAL_DLL
508    ""
509    "OUTPUT;TARGET"
510    ""
511    ${ARGN}
512  )
513
514  STRING(REGEX REPLACE "^absl::" "" _target ${ABSL_INTERNAL_DLL_TARGET})
515
516  list(FIND
517    ABSL_INTERNAL_DLL_TARGETS
518    "${_target}"
519    _index)
520
521  if (${_index} GREATER -1)
522    set(${ABSL_INTERNAL_DLL_OUTPUT} 1 PARENT_SCOPE)
523  else()
524    set(${ABSL_INTERNAL_DLL_OUTPUT} 0 PARENT_SCOPE)
525  endif()
526endfunction()
527
528function(absl_internal_dll_targets)
529  cmake_parse_arguments(ABSL_INTERNAL_DLL
530  ""
531  "OUTPUT"
532  "DEPS"
533  ${ARGN}
534  )
535
536  set(_deps "")
537  foreach(dep IN LISTS ABSL_INTERNAL_DLL_DEPS)
538    absl_internal_dll_contains(TARGET ${dep} OUTPUT _contains)
539    if (_contains)
540      list(APPEND _deps abseil_dll)
541    else()
542      list(APPEND _deps ${dep})
543    endif()
544  endforeach()
545
546  # Because we may have added the DLL multiple times
547  list(REMOVE_DUPLICATES _deps)
548  set(${ABSL_INTERNAL_DLL_OUTPUT} "${_deps}" PARENT_SCOPE)
549endfunction()
550
551function(absl_make_dll)
552  add_library(
553    abseil_dll
554    SHARED
555      "${ABSL_INTERNAL_DLL_FILES}"
556  )
557  target_link_libraries(
558    abseil_dll
559    PRIVATE
560      ${ABSL_DEFAULT_LINKOPTS}
561  )
562  set_property(TARGET abseil_dll PROPERTY LINKER_LANGUAGE "CXX")
563  target_include_directories(
564    abseil_dll
565    PUBLIC
566      "$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
567      $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
568  )
569
570  target_compile_options(
571    abseil_dll
572    PRIVATE
573      ${ABSL_DEFAULT_COPTS}
574  )
575
576  target_compile_definitions(
577    abseil_dll
578    PRIVATE
579      ABSL_BUILD_DLL
580      NOMINMAX
581    INTERFACE
582      ${ABSL_CC_LIB_DEFINES}
583      ABSL_CONSUME_DLL
584  )
585
586  if(ABSL_PROPAGATE_CXX_STD)
587    # Abseil libraries require C++14 as the current minimum standard. When
588    # compiled with C++17 (either because it is the compiler's default or
589    # explicitly requested), then Abseil requires C++17.
590    _absl_target_compile_features_if_available(${_NAME} PUBLIC ${ABSL_INTERNAL_CXX_STD_FEATURE})
591  else()
592    # Note: This is legacy (before CMake 3.8) behavior. Setting the
593    # target-level CXX_STANDARD property to ABSL_CXX_STANDARD (which is
594    # initialized by CMAKE_CXX_STANDARD) should have no real effect, since
595    # that is the default value anyway.
596    #
597    # CXX_STANDARD_REQUIRED does guard against the top-level CMake project
598    # not having enabled CMAKE_CXX_STANDARD_REQUIRED (which prevents
599    # "decaying" to an older standard if the requested one isn't available).
600    set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD})
601    set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
602  endif()
603
604  install(TARGETS abseil_dll EXPORT ${PROJECT_NAME}Targets
605        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
606        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
607        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
608  )
609endfunction()
610