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/dynamic_annotations.h"
19  "base/internal/endian.h"
20  "base/internal/errno_saver.h"
21  "base/internal/fast_type_id.h"
22  "base/internal/hide_ptr.h"
23  "base/internal/identity.h"
24  "base/internal/invoke.h"
25  "base/internal/inline_variable.h"
26  "base/internal/low_level_alloc.cc"
27  "base/internal/low_level_alloc.h"
28  "base/internal/low_level_scheduling.h"
29  "base/internal/per_thread_tls.h"
30  "base/internal/prefetch.h"
31  "base/internal/pretty_function.h"
32  "base/internal/raw_logging.cc"
33  "base/internal/raw_logging.h"
34  "base/internal/scheduling_mode.h"
35  "base/internal/scoped_set_env.cc"
36  "base/internal/scoped_set_env.h"
37  "base/internal/strerror.h"
38  "base/internal/strerror.cc"
39  "base/internal/spinlock.cc"
40  "base/internal/spinlock.h"
41  "base/internal/spinlock_wait.cc"
42  "base/internal/spinlock_wait.h"
43  "base/internal/sysinfo.cc"
44  "base/internal/sysinfo.h"
45  "base/internal/thread_annotations.h"
46  "base/internal/thread_identity.cc"
47  "base/internal/thread_identity.h"
48  "base/internal/throw_delegate.cc"
49  "base/internal/throw_delegate.h"
50  "base/internal/tsan_mutex_interface.h"
51  "base/internal/unaligned_access.h"
52  "base/internal/unscaledcycleclock.cc"
53  "base/internal/unscaledcycleclock.h"
54  "base/internal/unscaledcycleclock_config.h"
55  "base/log_severity.cc"
56  "base/log_severity.h"
57  "base/macros.h"
58  "base/optimization.h"
59  "base/options.h"
60  "base/policy_checks.h"
61  "base/port.h"
62  "base/thread_annotations.h"
63  "cleanup/cleanup.h"
64  "cleanup/internal/cleanup.h"
65  "container/btree_map.h"
66  "container/btree_set.h"
67  "container/fixed_array.h"
68  "container/flat_hash_map.h"
69  "container/flat_hash_set.h"
70  "container/inlined_vector.h"
71  "container/internal/btree.h"
72  "container/internal/btree_container.h"
73  "container/internal/common.h"
74  "container/internal/common_policy_traits.h"
75  "container/internal/compressed_tuple.h"
76  "container/internal/container_memory.h"
77  "container/internal/counting_allocator.h"
78  "container/internal/hash_function_defaults.h"
79  "container/internal/hash_policy_traits.h"
80  "container/internal/hashtable_debug.h"
81  "container/internal/hashtable_debug_hooks.h"
82  "container/internal/hashtablez_sampler.cc"
83  "container/internal/hashtablez_sampler.h"
84  "container/internal/hashtablez_sampler_force_weak_definition.cc"
85  "container/internal/inlined_vector.h"
86  "container/internal/layout.h"
87  "container/internal/node_slot_policy.h"
88  "container/internal/raw_hash_map.h"
89  "container/internal/raw_hash_set.cc"
90  "container/internal/raw_hash_set.h"
91  "container/internal/tracked.h"
92  "container/node_hash_map.h"
93  "container/node_hash_set.h"
94  "crc/crc32c.cc"
95  "crc/crc32c.h"
96  "crc/internal/cpu_detect.cc"
97  "crc/internal/cpu_detect.h"
98  "crc/internal/crc32c.h"
99  "crc/internal/crc32c_inline.h"
100  "crc/internal/crc32_x86_arm_combined_simd.h"
101  "crc/internal/crc.cc"
102  "crc/internal/crc.h"
103  "crc/internal/crc_cord_state.cc"
104  "crc/internal/crc_cord_state.h"
105  "crc/internal/crc_internal.h"
106  "crc/internal/crc_x86_arm_combined.cc"
107  "crc/internal/crc_memcpy_fallback.cc"
108  "crc/internal/crc_memcpy.h"
109  "crc/internal/crc_memcpy_x86_64.cc"
110  "crc/internal/crc_non_temporal_memcpy.cc"
111  "crc/internal/crc_x86_arm_combined.cc"
112  "crc/internal/non_temporal_arm_intrinsics.h"
113  "crc/internal/non_temporal_memcpy.h"
114  "debugging/failure_signal_handler.cc"
115  "debugging/failure_signal_handler.h"
116  "debugging/leak_check.h"
117  "debugging/stacktrace.cc"
118  "debugging/stacktrace.h"
119  "debugging/symbolize.cc"
120  "debugging/symbolize.h"
121  "debugging/internal/address_is_readable.cc"
122  "debugging/internal/address_is_readable.h"
123  "debugging/internal/demangle.cc"
124  "debugging/internal/demangle.h"
125  "debugging/internal/elf_mem_image.cc"
126  "debugging/internal/elf_mem_image.h"
127  "debugging/internal/examine_stack.cc"
128  "debugging/internal/examine_stack.h"
129  "debugging/internal/stack_consumption.cc"
130  "debugging/internal/stack_consumption.h"
131  "debugging/internal/stacktrace_config.h"
132  "debugging/internal/symbolize.h"
133  "debugging/internal/vdso_support.cc"
134  "debugging/internal/vdso_support.h"
135  "functional/any_invocable.h"
136  "functional/internal/front_binder.h"
137  "functional/bind_front.h"
138  "functional/function_ref.h"
139  "functional/internal/any_invocable.h"
140  "functional/internal/function_ref.h"
141  "hash/hash.h"
142  "hash/internal/city.h"
143  "hash/internal/city.cc"
144  "hash/internal/hash.h"
145  "hash/internal/hash.cc"
146  "hash/internal/spy_hash_state.h"
147  "hash/internal/low_level_hash.h"
148  "hash/internal/low_level_hash.cc"
149  "log/absl_check.h"
150  "log/absl_log.h"
151  "log/check.h"
152  "log/die_if_null.cc"
153  "log/die_if_null.h"
154  "log/globals.cc"
155  "log/globals.h"
156  "log/internal/append_truncated.h"
157  "log/internal/check_impl.h"
158  "log/internal/check_op.cc"
159  "log/internal/check_op.h"
160  "log/internal/conditions.cc"
161  "log/internal/conditions.h"
162  "log/internal/config.h"
163  "log/internal/globals.cc"
164  "log/internal/globals.h"
165  "log/internal/log_format.cc"
166  "log/internal/log_format.h"
167  "log/internal/log_impl.h"
168  "log/internal/log_message.cc"
169  "log/internal/log_message.h"
170  "log/internal/log_sink_set.cc"
171  "log/internal/log_sink_set.h"
172  "log/internal/nullguard.cc"
173  "log/internal/nullguard.h"
174  "log/internal/nullstream.h"
175  "log/internal/proto.h"
176  "log/internal/proto.cc"
177  "log/internal/strip.h"
178  "log/internal/structured.h"
179  "log/internal/voidify.h"
180  "log/initialize.cc"
181  "log/initialize.h"
182  "log/log.h"
183  "log/log_entry.cc"
184  "log/log_entry.h"
185  "log/log_sink.cc"
186  "log/log_sink.h"
187  "log/log_sink_registry.h"
188  "log/log_streamer.h"
189  "log/structured.h"
190  "memory/memory.h"
191  "meta/type_traits.h"
192  "numeric/bits.h"
193  "numeric/int128.cc"
194  "numeric/int128.h"
195  "numeric/internal/bits.h"
196  "numeric/internal/representation.h"
197  "profiling/internal/exponential_biased.cc"
198  "profiling/internal/exponential_biased.h"
199  "profiling/internal/periodic_sampler.cc"
200  "profiling/internal/periodic_sampler.h"
201  "profiling/internal/sample_recorder.h"
202  "random/bernoulli_distribution.h"
203  "random/beta_distribution.h"
204  "random/bit_gen_ref.h"
205  "random/discrete_distribution.cc"
206  "random/discrete_distribution.h"
207  "random/distributions.h"
208  "random/exponential_distribution.h"
209  "random/gaussian_distribution.cc"
210  "random/gaussian_distribution.h"
211  "random/internal/distribution_caller.h"
212  "random/internal/fastmath.h"
213  "random/internal/fast_uniform_bits.h"
214  "random/internal/generate_real.h"
215  "random/internal/iostream_state_saver.h"
216  "random/internal/nonsecure_base.h"
217  "random/internal/pcg_engine.h"
218  "random/internal/platform.h"
219  "random/internal/pool_urbg.cc"
220  "random/internal/pool_urbg.h"
221  "random/internal/randen.cc"
222  "random/internal/randen.h"
223  "random/internal/randen_detect.cc"
224  "random/internal/randen_detect.h"
225  "random/internal/randen_engine.h"
226  "random/internal/randen_hwaes.cc"
227  "random/internal/randen_hwaes.h"
228  "random/internal/randen_round_keys.cc"
229  "random/internal/randen_slow.cc"
230  "random/internal/randen_slow.h"
231  "random/internal/randen_traits.h"
232  "random/internal/salted_seed_seq.h"
233  "random/internal/seed_material.cc"
234  "random/internal/seed_material.h"
235  "random/internal/sequence_urbg.h"
236  "random/internal/traits.h"
237  "random/internal/uniform_helper.h"
238  "random/internal/wide_multiply.h"
239  "random/log_uniform_int_distribution.h"
240  "random/poisson_distribution.h"
241  "random/random.h"
242  "random/seed_gen_exception.cc"
243  "random/seed_gen_exception.h"
244  "random/seed_sequences.cc"
245  "random/seed_sequences.h"
246  "random/uniform_int_distribution.h"
247  "random/uniform_real_distribution.h"
248  "random/zipf_distribution.h"
249  "status/internal/status_internal.h"
250  "status/internal/statusor_internal.h"
251  "status/status.h"
252  "status/status.cc"
253  "status/statusor.h"
254  "status/statusor.cc"
255  "status/status_payload_printer.h"
256  "status/status_payload_printer.cc"
257  "strings/ascii.cc"
258  "strings/ascii.h"
259  "strings/charconv.cc"
260  "strings/charconv.h"
261  "strings/cord.cc"
262  "strings/cord.h"
263  "strings/cord_analysis.cc"
264  "strings/cord_analysis.h"
265  "strings/cord_buffer.cc"
266  "strings/cord_buffer.h"
267  "strings/escaping.cc"
268  "strings/escaping.h"
269  "strings/internal/charconv_bigint.cc"
270  "strings/internal/charconv_bigint.h"
271  "strings/internal/charconv_parse.cc"
272  "strings/internal/charconv_parse.h"
273  "strings/internal/cord_data_edge.h"
274  "strings/internal/cord_internal.cc"
275  "strings/internal/cord_internal.h"
276  "strings/internal/cord_rep_btree.cc"
277  "strings/internal/cord_rep_btree.h"
278  "strings/internal/cord_rep_btree_navigator.cc"
279  "strings/internal/cord_rep_btree_navigator.h"
280  "strings/internal/cord_rep_btree_reader.cc"
281  "strings/internal/cord_rep_btree_reader.h"
282  "strings/internal/cord_rep_crc.cc"
283  "strings/internal/cord_rep_crc.h"
284  "strings/internal/cord_rep_consume.h"
285  "strings/internal/cord_rep_consume.cc"
286  "strings/internal/cord_rep_flat.h"
287  "strings/internal/cord_rep_ring.cc"
288  "strings/internal/cord_rep_ring.h"
289  "strings/internal/cord_rep_ring_reader.h"
290  "strings/internal/cordz_functions.cc"
291  "strings/internal/cordz_functions.h"
292  "strings/internal/cordz_handle.cc"
293  "strings/internal/cordz_handle.h"
294  "strings/internal/cordz_info.cc"
295  "strings/internal/cordz_info.h"
296  "strings/internal/cordz_sample_token.cc"
297  "strings/internal/cordz_sample_token.h"
298  "strings/internal/cordz_statistics.h"
299  "strings/internal/cordz_update_scope.h"
300  "strings/internal/cordz_update_tracker.h"
301  "strings/internal/damerau_levenshtein_distance.h"
302  "strings/internal/damerau_levenshtein_distance.cc"
303  "strings/internal/stl_type_traits.h"
304  "strings/internal/string_constant.h"
305  "strings/internal/stringify_sink.h"
306  "strings/internal/stringify_sink.cc"
307  "strings/internal/has_absl_stringify.h"
308  "strings/match.cc"
309  "strings/match.h"
310  "strings/numbers.cc"
311  "strings/numbers.h"
312  "strings/str_format.h"
313  "strings/str_cat.cc"
314  "strings/str_cat.h"
315  "strings/str_join.h"
316  "strings/str_replace.cc"
317  "strings/str_replace.h"
318  "strings/str_split.cc"
319  "strings/str_split.h"
320  "strings/string_view.cc"
321  "strings/string_view.h"
322  "strings/strip.h"
323  "strings/substitute.cc"
324  "strings/substitute.h"
325  "strings/internal/char_map.h"
326  "strings/internal/escaping.h"
327  "strings/internal/escaping.cc"
328  "strings/internal/memutil.cc"
329  "strings/internal/memutil.h"
330  "strings/internal/ostringstream.cc"
331  "strings/internal/ostringstream.h"
332  "strings/internal/pow10_helper.cc"
333  "strings/internal/pow10_helper.h"
334  "strings/internal/resize_uninitialized.h"
335  "strings/internal/str_format/arg.cc"
336  "strings/internal/str_format/arg.h"
337  "strings/internal/str_format/bind.cc"
338  "strings/internal/str_format/bind.h"
339  "strings/internal/str_format/checker.h"
340  "strings/internal/str_format/constexpr_parser.h"
341  "strings/internal/str_format/extension.cc"
342  "strings/internal/str_format/extension.h"
343  "strings/internal/str_format/float_conversion.cc"
344  "strings/internal/str_format/float_conversion.h"
345  "strings/internal/str_format/output.cc"
346  "strings/internal/str_format/output.h"
347  "strings/internal/str_format/parser.cc"
348  "strings/internal/str_format/parser.h"
349  "strings/internal/str_join_internal.h"
350  "strings/internal/str_split_internal.h"
351  "strings/internal/utf8.cc"
352  "strings/internal/utf8.h"
353  "synchronization/barrier.cc"
354  "synchronization/barrier.h"
355  "synchronization/blocking_counter.cc"
356  "synchronization/blocking_counter.h"
357  "synchronization/mutex.cc"
358  "synchronization/mutex.h"
359  "synchronization/notification.cc"
360  "synchronization/notification.h"
361  "synchronization/internal/create_thread_identity.cc"
362  "synchronization/internal/create_thread_identity.h"
363  "synchronization/internal/futex.h"
364  "synchronization/internal/graphcycles.cc"
365  "synchronization/internal/graphcycles.h"
366  "synchronization/internal/kernel_timeout.h"
367  "synchronization/internal/per_thread_sem.cc"
368  "synchronization/internal/per_thread_sem.h"
369  "synchronization/internal/thread_pool.h"
370  "synchronization/internal/waiter.cc"
371  "synchronization/internal/waiter.h"
372  "time/civil_time.cc"
373  "time/civil_time.h"
374  "time/clock.cc"
375  "time/clock.h"
376  "time/duration.cc"
377  "time/format.cc"
378  "time/time.cc"
379  "time/time.h"
380  "time/internal/cctz/include/cctz/civil_time.h"
381  "time/internal/cctz/include/cctz/civil_time_detail.h"
382  "time/internal/cctz/include/cctz/time_zone.h"
383  "time/internal/cctz/include/cctz/zone_info_source.h"
384  "time/internal/cctz/src/civil_time_detail.cc"
385  "time/internal/cctz/src/time_zone_fixed.cc"
386  "time/internal/cctz/src/time_zone_fixed.h"
387  "time/internal/cctz/src/time_zone_format.cc"
388  "time/internal/cctz/src/time_zone_if.cc"
389  "time/internal/cctz/src/time_zone_if.h"
390  "time/internal/cctz/src/time_zone_impl.cc"
391  "time/internal/cctz/src/time_zone_impl.h"
392  "time/internal/cctz/src/time_zone_info.cc"
393  "time/internal/cctz/src/time_zone_info.h"
394  "time/internal/cctz/src/time_zone_libc.cc"
395  "time/internal/cctz/src/time_zone_libc.h"
396  "time/internal/cctz/src/time_zone_lookup.cc"
397  "time/internal/cctz/src/time_zone_posix.cc"
398  "time/internal/cctz/src/time_zone_posix.h"
399  "time/internal/cctz/src/tzfile.h"
400  "time/internal/cctz/src/zone_info_source.cc"
401  "types/any.h"
402  "types/bad_any_cast.cc"
403  "types/bad_any_cast.h"
404  "types/bad_optional_access.cc"
405  "types/bad_optional_access.h"
406  "types/bad_variant_access.cc"
407  "types/bad_variant_access.h"
408  "types/compare.h"
409  "types/internal/conformance_aliases.h"
410  "types/internal/conformance_archetype.h"
411  "types/internal/conformance_profile.h"
412  "types/internal/parentheses.h"
413  "types/internal/transform_args.h"
414  "types/internal/variant.h"
415  "types/optional.h"
416  "types/internal/optional.h"
417  "types/span.h"
418  "types/internal/span.h"
419  "types/variant.h"
420  "utility/utility.h"
421  "debugging/leak_check.cc"
422)
423
424set(ABSL_INTERNAL_DLL_TARGETS
425  "absl_check"
426  "absl_log"
427  "algorithm"
428  "algorithm_container"
429  "any"
430  "any_invocable"
431  "atomic_hook"
432  "bad_any_cast"
433  "bad_any_cast_impl"
434  "bad_optional_access"
435  "bad_variant_access"
436  "base"
437  "base_internal"
438  "bind_front"
439  "bits"
440  "btree"
441  "check"
442  "city"
443  "civil_time"
444  "compare"
445  "compressed_tuple"
446  "config"
447  "container"
448  "container_common"
449  "container_memory"
450  "cord"
451  "core_headers"
452  "counting_allocator"
453  "crc_cpu_detect"
454  "crc_internal"
455  "crc32c"
456  "debugging"
457  "debugging_internal"
458  "demangle_internal"
459  "die_if_null"
460  "dynamic_annotations"
461  "endian"
462  "examine_stack"
463  "exponential_biased"
464  "failure_signal_handler"
465  "fixed_array"
466  "flat_hash_map"
467  "flat_hash_set"
468  "function_ref"
469  "graphcycles_internal"
470  "hash"
471  "hash_function_defaults"
472  "hash_policy_traits"
473  "hashtable_debug"
474  "hashtable_debug_hooks"
475  "hashtablez_sampler"
476  "inlined_vector"
477  "inlined_vector_internal"
478  "int128"
479  "kernel_timeout_internal"
480  "layout"
481  "leak_check"
482  "log_internal_check_impl"
483  "log_internal_check_op"
484  "log_internal_conditions"
485  "log_internal_config"
486  "log_internal_format"
487  "log_internal_globals"
488  "log_internal_log_impl"
489  "log_internal_proto"
490  "log_internal_message"
491  "log_internal_log_sink_set"
492  "log_internal_nullguard"
493  "log_internal_nullstream"
494  "log_internal_strip"
495  "log_internal_voidify"
496  "log_internal_append_truncated"
497  "log_globals"
498  "log_initialize"
499  "log"
500  "log_entry"
501  "log_sink"
502  "log_sink_registry"
503  "log_streamer"
504  "log_internal_structured"
505  "log_severity"
506  "log_structured"
507  "malloc_internal"
508  "memory"
509  "meta"
510  "node_hash_map"
511  "node_hash_set"
512  "node_slot_policy"
513  "non_temporal_arm_intrinsics"
514  "non_temporal_memcpy"
515  "numeric"
516  "optional"
517  "periodic_sampler"
518  "pow10_helper"
519  "pretty_function"
520  "random_bit_gen_ref"
521  "random_distributions"
522  "random_internal_distribution_caller"
523  "random_internal_distributions"
524  "random_internal_explicit_seed_seq"
525  "random_internal_fastmath"
526  "random_internal_fast_uniform_bits"
527  "random_internal_generate_real"
528  "random_internal_iostream_state_saver"
529  "random_internal_nonsecure_base"
530  "random_internal_pcg_engine"
531  "random_internal_platform"
532  "random_internal_pool_urbg"
533  "random_internal_randen"
534  "random_internal_randen_engine"
535  "random_internal_randen_hwaes"
536  "random_internal_randen_hwaes_impl"
537  "random_internal_randen_slow"
538  "random_internal_salted_seed_seq"
539  "random_internal_seed_material"
540  "random_internal_sequence_urbg"
541  "random_internal_traits"
542  "random_internal_uniform_helper"
543  "random_internal_wide_multiply"
544  "random_random"
545  "random_seed_gen_exception"
546  "random_seed_sequences"
547  "raw_hash_map"
548  "raw_hash_set"
549  "raw_logging_internal"
550  "sample_recorder"
551  "scoped_set_env"
552  "span"
553  "spinlock_wait"
554  "spy_hash_state"
555  "stack_consumption"
556  "stacktrace"
557  "status"
558  "str_format"
559  "str_format_internal"
560  "strings"
561  "strings_internal"
562  "symbolize"
563  "synchronization"
564  "thread_pool"
565  "throw_delegate"
566  "time"
567  "time_zone"
568  "tracked"
569  "type_traits"
570  "utility"
571  "variant"
572)
573
574set(ABSL_INTERNAL_TEST_DLL_FILES
575  "hash/hash_testing.h"
576  "log/scoped_mock_log.cc"
577  "log/scoped_mock_log.h"
578  "random/internal/mock_helpers.h"
579  "random/internal/mock_overload_set.h"
580  "random/mocking_bit_gen.h"
581  "random/mock_distributions.h"
582  "strings/cordz_test_helpers.h"
583  "strings/cord_test_helpers.h"
584)
585
586set(ABSL_INTERNAL_TEST_DLL_TARGETS
587  "cord_test_helpers"
588  "cordz_test_helpers"
589  "hash_testing"
590  "random_mocking_bit_gen"
591  "random_internal_mock_overload_set"
592  "scoped_mock_log"
593)
594
595function(_absl_target_compile_features_if_available TARGET TYPE FEATURE)
596  if(FEATURE IN_LIST CMAKE_CXX_COMPILE_FEATURES)
597    target_compile_features(${TARGET} ${TYPE} ${FEATURE})
598  else()
599    message(WARNING "Feature ${FEATURE} is unknown for the CXX compiler")
600  endif()
601endfunction()
602
603include(CheckCXXSourceCompiles)
604
605check_cxx_source_compiles(
606  [==[
607#ifdef _MSC_VER
608#  if _MSVC_LANG < 201700L
609#    error "The compiler defaults or is configured for C++ < 17"
610#  endif
611#elif __cplusplus < 201700L
612#  error "The compiler defaults or is configured for C++ < 17"
613#endif
614int main() { return 0; }
615]==]
616  ABSL_INTERNAL_AT_LEAST_CXX17)
617
618if(ABSL_INTERNAL_AT_LEAST_CXX17)
619  set(ABSL_INTERNAL_CXX_STD_FEATURE cxx_std_17)
620else()
621  set(ABSL_INTERNAL_CXX_STD_FEATURE cxx_std_14)
622endif()
623
624function(absl_internal_dll_contains)
625  cmake_parse_arguments(ABSL_INTERNAL_DLL
626    ""
627    "OUTPUT;TARGET"
628    ""
629    ${ARGN}
630  )
631
632  STRING(REGEX REPLACE "^absl::" "" _target ${ABSL_INTERNAL_DLL_TARGET})
633
634  list(FIND
635    ABSL_INTERNAL_DLL_TARGETS
636    "${_target}"
637    _index)
638
639  if (${_index} GREATER -1)
640    set(${ABSL_INTERNAL_DLL_OUTPUT} 1 PARENT_SCOPE)
641  else()
642    set(${ABSL_INTERNAL_DLL_OUTPUT} 0 PARENT_SCOPE)
643  endif()
644endfunction()
645
646function(absl_internal_test_dll_contains)
647  cmake_parse_arguments(ABSL_INTERNAL_TEST_DLL
648    ""
649    "OUTPUT;TARGET"
650    ""
651    ${ARGN}
652  )
653
654  STRING(REGEX REPLACE "^absl::" "" _target ${ABSL_INTERNAL_TEST_DLL_TARGET})
655
656  list(FIND
657    ABSL_INTERNAL_TEST_DLL_TARGETS
658    "${_target}"
659    _index)
660
661  if (${_index} GREATER -1)
662    set(${ABSL_INTERNAL_TEST_DLL_OUTPUT} 1 PARENT_SCOPE)
663  else()
664    set(${ABSL_INTERNAL_TEST_DLL_OUTPUT} 0 PARENT_SCOPE)
665  endif()
666endfunction()
667
668function(absl_internal_dll_targets)
669  cmake_parse_arguments(ABSL_INTERNAL_DLL
670  ""
671  "OUTPUT"
672  "DEPS"
673  ${ARGN}
674  )
675
676  set(_deps "")
677  foreach(dep IN LISTS ABSL_INTERNAL_DLL_DEPS)
678    absl_internal_dll_contains(TARGET ${dep} OUTPUT _dll_contains)
679    absl_internal_test_dll_contains(TARGET ${dep} OUTPUT _test_dll_contains)
680    if (_dll_contains)
681      list(APPEND _deps abseil_dll)
682    elseif (_test_dll_contains)
683      list(APPEND _deps abseil_test_dll)
684    else()
685      list(APPEND _deps ${dep})
686    endif()
687  endforeach()
688
689  # Because we may have added the DLL multiple times
690  list(REMOVE_DUPLICATES _deps)
691  set(${ABSL_INTERNAL_DLL_OUTPUT} "${_deps}" PARENT_SCOPE)
692endfunction()
693
694function(absl_make_dll)
695  cmake_parse_arguments(ABSL_INTERNAL_MAKE_DLL
696  ""
697  "TEST"
698  ""
699  ${ARGN}
700  )
701
702  if (ABSL_INTERNAL_MAKE_DLL_TEST)
703    set(_dll "abseil_test_dll")
704    set(_dll_files ${ABSL_INTERNAL_TEST_DLL_FILES})
705    set(_dll_libs "abseil_dll" "GTest::gtest" "GTest::gmock")
706    set(_dll_compile_definitions "GTEST_LINKED_AS_SHARED_LIBRARY=1")
707    set(_dll_includes ${absl_gtest_src_dir}/googletest/include ${absl_gtest_src_dir}/googlemock/include)
708    set(_dll_consume "ABSL_CONSUME_TEST_DLL")
709    set(_dll_build "ABSL_BUILD_TEST_DLL")
710  else()
711    set(_dll "abseil_dll")
712    set(_dll_files ${ABSL_INTERNAL_DLL_FILES})
713    set(_dll_libs "")
714    set(_dll_compile_definitions "")
715    set(_dll_includes "")
716    set(_dll_consume "ABSL_CONSUME_DLL")
717    set(_dll_build "ABSL_BUILD_DLL")
718  endif()
719
720  add_library(
721    ${_dll}
722    SHARED
723      ${_dll_files}
724  )
725  target_link_libraries(
726    ${_dll}
727    PRIVATE
728      ${_dll_libs}
729      ${ABSL_DEFAULT_LINKOPTS}
730  )
731  set_property(TARGET ${_dll} PROPERTY LINKER_LANGUAGE "CXX")
732  target_include_directories(
733    ${_dll}
734    PUBLIC
735      "$<BUILD_INTERFACE:${ABSL_COMMON_INCLUDE_DIRS}>"
736      $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
737    PRIVATE
738      ${_dll_includes}
739  )
740
741  target_compile_options(
742    ${_dll}
743    PRIVATE
744      ${ABSL_DEFAULT_COPTS}
745  )
746
747  foreach(cflag ${ABSL_CC_LIB_COPTS})
748    if(${cflag} MATCHES "^(-Wno|/wd)")
749      # These flags are needed to suppress warnings that might fire in our headers.
750      set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
751    elseif(${cflag} MATCHES "^(-W|/w[1234eo])")
752      # Don't impose our warnings on others.
753    else()
754      set(PC_CFLAGS "${PC_CFLAGS} ${cflag}")
755    endif()
756  endforeach()
757  string(REPLACE ";" " " PC_LINKOPTS "${ABSL_CC_LIB_LINKOPTS}")
758
759  FILE(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/lib/pkgconfig/${_dll}.pc" CONTENT "\
760prefix=${CMAKE_INSTALL_PREFIX}\n\
761exec_prefix=\${prefix}\n\
762libdir=${CMAKE_INSTALL_FULL_LIBDIR}\n\
763includedir=${CMAKE_INSTALL_FULL_INCLUDEDIR}\n\
764\n\
765Name: ${_dll}\n\
766Description: Abseil DLL library\n\
767URL: https://abseil.io/\n\
768Version: ${absl_VERSION}\n\
769Libs: -L\${libdir} ${PC_LINKOPTS} $<$<NOT:$<BOOL:${ABSL_CC_LIB_IS_INTERFACE}>>:-l${_dll}>\n\
770Cflags: -I\${includedir}${PC_CFLAGS}\n")
771  INSTALL(FILES "${CMAKE_BINARY_DIR}/lib/pkgconfig/${_dll}.pc"
772    DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
773
774  target_compile_definitions(
775    ${_dll}
776    PUBLIC
777      ${_dll_compile_definitions}
778    PRIVATE
779      ${_dll_build}
780      NOMINMAX
781    INTERFACE
782      ${ABSL_CC_LIB_DEFINES}
783      ${_dll_consume}
784  )
785
786  if(ABSL_PROPAGATE_CXX_STD)
787    # Abseil libraries require C++14 as the current minimum standard. When
788    # compiled with C++17 (either because it is the compiler's default or
789    # explicitly requested), then Abseil requires C++17.
790    _absl_target_compile_features_if_available(${_NAME} PUBLIC ${ABSL_INTERNAL_CXX_STD_FEATURE})
791  else()
792    # Note: This is legacy (before CMake 3.8) behavior. Setting the
793    # target-level CXX_STANDARD property to ABSL_CXX_STANDARD (which is
794    # initialized by CMAKE_CXX_STANDARD) should have no real effect, since
795    # that is the default value anyway.
796    #
797    # CXX_STANDARD_REQUIRED does guard against the top-level CMake project
798    # not having enabled CMAKE_CXX_STANDARD_REQUIRED (which prevents
799    # "decaying" to an older standard if the requested one isn't available).
800    set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD ${ABSL_CXX_STANDARD})
801    set_property(TARGET ${_NAME} PROPERTY CXX_STANDARD_REQUIRED ON)
802  endif()
803
804  install(TARGETS ${_dll} EXPORT ${PROJECT_NAME}Targets
805        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
806        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
807        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
808  )
809endfunction()
810