-
Notifications
You must be signed in to change notification settings - Fork 88
Expand file tree
/
Copy pathtreadmill.patch
More file actions
10260 lines (10155 loc) · 330 KB
/
Copy pathtreadmill.patch
File metadata and controls
10260 lines (10155 loc) · 330 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/build.sh treadmill/build.sh
--- treadmill-src/build.sh 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/build.sh 2025-08-04 15:44:21.731476550 -0700
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+# Exit on error
+set -e
+
+# Set environment variables
+source ../config.sh
+
+# Parse arguments
+ENABLE_SLEEP=OFF
+INSTALL=false
+
+
+if command -v dnf >/dev/null 2>&1; then
+ sudo dnf install -y numactl-devel
+elif command -v apt-get >/dev/null 2>&1; then
+ sudo apt-get update
+ sudo apt-get install -y libnuma-dev numactl
+fi
+# Create build directory
+mkdir -p build
+cd build
+
+# Configure with CMake
+echo "Configuring with CMake..."
+echo "BUILD_TREADMILL_SLEEP=$ENABLE_SLEEP"
+
+cmake .. \
+ -DCMAKE_INSTALL_PREFIX=${ADSIM_STAGING_DIR} \
+ -DCMAKE_PREFIX_PATH=${ADSIM_STAGING_DIR} \
+ -DCMAKE_CXX_COMPILER=clang++ \
+ -DCMAKE_C_COMPILER=clang \
+ -DBUILD_TREADMILL_SLEEP=$ENABLE_SLEEP \
+ -DADSIM_STAGING_DIR=${ADSIM_STAGING_DIR}
+
+# Build
+echo "Building treadmill..."
+cmake --build . -j$(nproc)
+
+# Install (optional)
+if [ "$INSTALL" = true ]; then
+ echo "Installing treadmill to ${ADSIM_STAGING_DIR}..."
+ cmake --install .
+fi
+
+echo "Build completed successfully!"
+echo "Executables are located in: $(pwd)"
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FBCMakeParseArgs.cmake treadmill/CMake/FBCMakeParseArgs.cmake
--- treadmill-src/CMake/FBCMakeParseArgs.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FBCMakeParseArgs.cmake 2025-08-04 15:44:21.733051431 -0700
@@ -0,0 +1,141 @@
+#
+# Copyright (c) Facebook, Inc. and its affiliates.
+#
+# Helper function for parsing arguments to a CMake function.
+#
+# This function is very similar to CMake's built-in cmake_parse_arguments()
+# function, with some improvements:
+# - This function correctly handles empty arguments. (cmake_parse_arguments()
+# ignores empty arguments.)
+# - If a multi-value argument is specified more than once, the subsequent
+# arguments are appended to the original list rather than replacing it. e.g.
+# if "SOURCES" is a multi-value argument, and the argument list contains
+# "SOURCES a b c SOURCES x y z" then the resulting value for SOURCES will be
+# "a;b;c;x;y;z" rather than "x;y;z"
+# - This function errors out by default on unrecognized arguments. You can
+# pass in an extra "ALLOW_UNPARSED_ARGS" argument to make it behave like
+# cmake_parse_arguments(), and return the unparsed arguments in a
+# <prefix>_UNPARSED_ARGUMENTS variable instead.
+#
+# It does look like cmake_parse_arguments() handled empty arguments correctly
+# from CMake 3.0 through 3.3, but it seems like this was probably broken when
+# it was turned into a built-in function in CMake 3.4. Here is discussion and
+# patches that fixed this behavior prior to CMake 3.0:
+# https://cmake.org/pipermail/cmake-developers/2013-November/020607.html
+#
+# The one downside to this function over the built-in cmake_parse_arguments()
+# is that I don't think we can achieve the PARSE_ARGV behavior in a non-builtin
+# function, so we can't properly handle arguments that contain ";". CMake will
+# treat the ";" characters as list element separators, and treat it as multiple
+# separate arguments.
+#
+function(fb_cmake_parse_args PREFIX OPTIONS ONE_VALUE_ARGS MULTI_VALUE_ARGS ARGS)
+ foreach(option IN LISTS ARGN)
+ if ("${option}" STREQUAL "ALLOW_UNPARSED_ARGS")
+ set(ALLOW_UNPARSED_ARGS TRUE)
+ else()
+ message(
+ FATAL_ERROR
+ "unknown optional argument for fb_cmake_parse_args(): ${option}"
+ )
+ endif()
+ endforeach()
+
+ # Define all options as FALSE in the parent scope to start with
+ foreach(var_name IN LISTS OPTIONS)
+ set("${PREFIX}_${var_name}" "FALSE" PARENT_SCOPE)
+ endforeach()
+
+ # TODO: We aren't extremely strict about error checking for one-value
+ # arguments here. e.g., we don't complain if a one-value argument is
+ # followed by another option/one-value/multi-value name rather than an
+ # argument. We also don't complain if a one-value argument is the last
+ # argument and isn't followed by a value.
+
+ list(APPEND all_args ${ONE_VALUE_ARGS})
+ list(APPEND all_args ${MULTI_VALUE_ARGS})
+ set(current_variable)
+ set(unparsed_args)
+ foreach(arg IN LISTS ARGS)
+ list(FIND OPTIONS "${arg}" opt_index)
+ if("${opt_index}" EQUAL -1)
+ list(FIND all_args "${arg}" arg_index)
+ if("${arg_index}" EQUAL -1)
+ # This argument does not match an argument name,
+ # must be an argument value
+ if("${current_variable}" STREQUAL "")
+ list(APPEND unparsed_args "${arg}")
+ else()
+ # Ugh, CMake lists have a pretty fundamental flaw: they cannot
+ # distinguish between an empty list and a list with a single empty
+ # element. We track our own SEEN_VALUES_arg setting to help
+ # distinguish this and behave properly here.
+ if ("${SEEN_${current_variable}}" AND "${${current_variable}}" STREQUAL "")
+ set("${current_variable}" ";${arg}")
+ else()
+ list(APPEND "${current_variable}" "${arg}")
+ endif()
+ set("SEEN_${current_variable}" TRUE)
+ endif()
+ else()
+ # We found a single- or multi-value argument name
+ set(current_variable "VALUES_${arg}")
+ set("SEEN_${arg}" TRUE)
+ endif()
+ else()
+ # We found an option variable
+ set("${PREFIX}_${arg}" "TRUE" PARENT_SCOPE)
+ set(current_variable)
+ endif()
+ endforeach()
+
+ foreach(arg_name IN LISTS ONE_VALUE_ARGS)
+ if(NOT "${SEEN_${arg_name}}")
+ unset("${PREFIX}_${arg_name}" PARENT_SCOPE)
+ elseif(NOT "${SEEN_VALUES_${arg_name}}")
+ # If the argument was seen but a value wasn't specified, error out.
+ # We require exactly one value to be specified.
+ message(
+ FATAL_ERROR "argument ${arg_name} was specified without a value"
+ )
+ else()
+ list(LENGTH "VALUES_${arg_name}" num_args)
+ if("${num_args}" EQUAL 0)
+ # We know an argument was specified and that we called list(APPEND).
+ # If CMake thinks the list is empty that means there is really a single
+ # empty element in the list.
+ set("${PREFIX}_${arg_name}" "" PARENT_SCOPE)
+ elseif("${num_args}" EQUAL 1)
+ list(GET "VALUES_${arg_name}" 0 arg_value)
+ set("${PREFIX}_${arg_name}" "${arg_value}" PARENT_SCOPE)
+ else()
+ message(
+ FATAL_ERROR "too many arguments specified for ${arg_name}: "
+ "${VALUES_${arg_name}}"
+ )
+ endif()
+ endif()
+ endforeach()
+
+ foreach(arg_name IN LISTS MULTI_VALUE_ARGS)
+ # If this argument name was never seen, then unset the parent scope
+ if (NOT "${SEEN_${arg_name}}")
+ unset("${PREFIX}_${arg_name}" PARENT_SCOPE)
+ else()
+ # TODO: Our caller still won't be able to distinguish between an empty
+ # list and a list with a single empty element. We can tell which is
+ # which, but CMake lists don't make it easy to show this to our caller.
+ set("${PREFIX}_${arg_name}" "${VALUES_${arg_name}}" PARENT_SCOPE)
+ endif()
+ endforeach()
+
+ # By default we fatal out on unparsed arguments, but return them to the
+ # caller if ALLOW_UNPARSED_ARGS was specified.
+ if (DEFINED unparsed_args)
+ if ("${ALLOW_UNPARSED_ARGS}")
+ set("${PREFIX}_UNPARSED_ARGUMENTS" "${unparsed_args}" PARENT_SCOPE)
+ else()
+ message(FATAL_ERROR "unrecognized arguments: ${unparsed_args}")
+ endif()
+ endif()
+endfunction()
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FBThriftCppLibrary.cmake treadmill/CMake/FBThriftCppLibrary.cmake
--- treadmill-src/CMake/FBThriftCppLibrary.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FBThriftCppLibrary.cmake 2025-08-04 15:44:21.734044042 -0700
@@ -0,0 +1,194 @@
+# Copyright (c) Facebook, Inc. and its affiliates.
+
+include(FBCMakeParseArgs)
+
+# Generate a C++ library from a thrift file
+#
+# Parameters:
+# - SERVICES <svc1> [<svc2> ...]
+# The names of the services defined in the thrift file.
+# - DEPENDS <dep1> [<dep2> ...]
+# A list of other thrift C++ libraries that this library depends on.
+# - OPTIONS <opt1> [<opt2> ...]
+# A list of options to pass to the thrift compiler.
+# - INCLUDE_DIR <path>
+# The sub-directory where generated headers will be installed.
+# Defaults to "include" if not specified. The caller must still call
+# install() to install the thrift library if desired.
+# - THRIFT_INCLUDE_DIR <path>
+# The sub-directory where generated headers will be installed.
+# Defaults to "${INCLUDE_DIR}/thrift-files" if not specified.
+# The caller must still call install() to install the thrift library if
+# desired.
+function(add_fbthrift_cpp_library LIB_NAME THRIFT_FILE)
+ # Parse the arguments
+ set(one_value_args INCLUDE_DIR THRIFT_INCLUDE_DIR)
+ set(multi_value_args SERVICES DEPENDS OPTIONS)
+ fb_cmake_parse_args(
+ ARG "" "${one_value_args}" "${multi_value_args}" "${ARGN}"
+ )
+ if(NOT DEFINED ARG_INCLUDE_DIR)
+ set(ARG_INCLUDE_DIR "include")
+ endif()
+ if(NOT DEFINED ARG_THRIFT_INCLUDE_DIR)
+ set(ARG_THRIFT_INCLUDE_DIR "${ARG_INCLUDE_DIR}/thrift-files")
+ endif()
+
+ get_filename_component(base ${THRIFT_FILE} NAME_WE)
+ get_filename_component(
+ output_dir
+ ${CMAKE_CURRENT_BINARY_DIR}/${THRIFT_FILE}
+ DIRECTORY
+ )
+
+ # Generate relative paths in #includes
+ file(
+ RELATIVE_PATH include_prefix
+ "${CMAKE_SOURCE_DIR}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/${THRIFT_FILE}"
+ )
+ get_filename_component(include_prefix ${include_prefix} DIRECTORY)
+
+ if (NOT "${include_prefix}" STREQUAL "")
+ list(APPEND ARG_OPTIONS "include_prefix=${include_prefix}")
+ endif()
+ # CMake 3.12 is finally getting a list(JOIN) function, but until then
+ # treating the list as a string and replacing the semicolons is good enough.
+ string(REPLACE ";" "," GEN_ARG_STR "${ARG_OPTIONS}")
+
+ # Compute the list of generated files
+ list(APPEND generated_headers
+ "${output_dir}/gen-cpp2/${base}_constants.h"
+ "${output_dir}/gen-cpp2/${base}_types.h"
+ "${output_dir}/gen-cpp2/${base}_types.tcc"
+ "${output_dir}/gen-cpp2/${base}_types_custom_protocol.h"
+ "${output_dir}/gen-cpp2/${base}_metadata.h"
+ )
+ list(APPEND generated_sources
+ "${output_dir}/gen-cpp2/${base}_constants.cpp"
+ "${output_dir}/gen-cpp2/${base}_data.h"
+ "${output_dir}/gen-cpp2/${base}_data.cpp"
+ "${output_dir}/gen-cpp2/${base}_types.cpp"
+ "${output_dir}/gen-cpp2/${base}_metadata.cpp"
+ )
+ foreach(service IN LISTS ARG_SERVICES)
+ list(APPEND generated_headers
+ "${output_dir}/gen-cpp2/${service}.h"
+ "${output_dir}/gen-cpp2/${service}.tcc"
+ "${output_dir}/gen-cpp2/${service}AsyncClient.h"
+ "${output_dir}/gen-cpp2/${service}_custom_protocol.h"
+ )
+ list(APPEND generated_sources
+ "${output_dir}/gen-cpp2/${service}.cpp"
+ "${output_dir}/gen-cpp2/${service}AsyncClient.cpp"
+ "${output_dir}/gen-cpp2/${service}_processmap_binary.cpp"
+ "${output_dir}/gen-cpp2/${service}_processmap_compact.cpp"
+ )
+ endforeach()
+
+ # This generator expression gets the list of include directories required
+ # for all of our dependencies.
+ # It requires using COMMAND_EXPAND_LISTS in the add_custom_command() call
+ # below. COMMAND_EXPAND_LISTS is only available in CMake 3.8+
+ # If we really had to support older versions of CMake we would probably need
+ # to use a wrapper script around the thrift compiler that could take the
+ # include list as a single argument and split it up before invoking the
+ # thrift compiler.
+ if (NOT POLICY CMP0067)
+ message(FATAL_ERROR "add_fbthrift_cpp_library() requires CMake 3.8+")
+ endif()
+ set(
+ thrift_include_options
+ "-I;$<JOIN:$<TARGET_PROPERTY:${LIB_NAME}.thrift_includes,INTERFACE_INCLUDE_DIRECTORIES>,;-I;>"
+ )
+
+ # Emit the rule to run the thrift compiler
+ add_custom_command(
+ OUTPUT
+ ${generated_headers}
+ ${generated_sources}
+ COMMAND_EXPAND_LISTS
+ COMMAND
+ "${CMAKE_COMMAND}" -E make_directory "${output_dir}"
+ COMMAND
+ "${FBTHRIFT_COMPILER}"
+ --legacy-strict
+ --gen "mstch_cpp2:${GEN_ARG_STR}"
+ "${thrift_include_options}"
+ -o "${output_dir}"
+ "${CMAKE_CURRENT_SOURCE_DIR}/${THRIFT_FILE}"
+ WORKING_DIRECTORY
+ "${CMAKE_BINARY_DIR}"
+ MAIN_DEPENDENCY
+ "${THRIFT_FILE}"
+ DEPENDS
+ ${ARG_DEPENDS}
+ "${FBTHRIFT_COMPILER}"
+ )
+
+ # Now emit the library rule to compile the sources
+ if (BUILD_SHARED_LIBS)
+ set(LIB_TYPE SHARED)
+ else ()
+ set(LIB_TYPE STATIC)
+ endif ()
+
+ add_library(
+ "${LIB_NAME}" ${LIB_TYPE}
+ ${generated_sources}
+ )
+
+ target_include_directories(
+ "${LIB_NAME}"
+ PUBLIC
+ "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>"
+ "$<INSTALL_INTERFACE:${ARG_INCLUDE_DIR}>"
+ )
+ target_link_libraries(
+ "${LIB_NAME}"
+ PUBLIC
+ ${ARG_DEPENDS}
+ FBThrift::thriftcpp2
+ Folly::folly
+ )
+
+ # Add ${generated_headers} to the PUBLIC_HEADER property for ${LIB_NAME}
+ #
+ # This allows callers to install it using
+ # "install(TARGETS ${LIB_NAME} PUBLIC_HEADER)"
+ # However, note that CMake's PUBLIC_HEADER behavior is rather inflexible,
+ # and does have any way to preserve header directory structure. Callers
+ # must be careful to use the correct PUBLIC_HEADER DESTINATION parameter
+ # when doing this, to put the files the correct directory themselves.
+ # We define a HEADER_INSTALL_DIR property with the include directory prefix,
+ # so typically callers should specify the PUBLIC_HEADER DESTINATION as
+ # "$<TARGET_PROPERTY:${LIB_NAME},HEADER_INSTALL_DIR>"
+ set_property(
+ TARGET "${LIB_NAME}"
+ PROPERTY PUBLIC_HEADER ${generated_headers}
+ )
+
+ # Define a dummy interface library to help propagate the thrift include
+ # directories between dependencies.
+ add_library("${LIB_NAME}.thrift_includes" INTERFACE)
+ target_include_directories(
+ "${LIB_NAME}.thrift_includes"
+ INTERFACE
+ "$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}>"
+ "$<INSTALL_INTERFACE:${ARG_THRIFT_INCLUDE_DIR}>"
+ )
+ foreach(dep IN LISTS ARG_DEPENDS)
+ target_link_libraries(
+ "${LIB_NAME}.thrift_includes"
+ INTERFACE "${dep}.thrift_includes"
+ )
+ endforeach()
+
+ set_target_properties(
+ "${LIB_NAME}"
+ PROPERTIES
+ EXPORT_PROPERTIES "THRIFT_INSTALL_DIR"
+ THRIFT_INSTALL_DIR "${ARG_THRIFT_INCLUDE_DIR}/${include_prefix}"
+ HEADER_INSTALL_DIR "${ARG_INCLUDE_DIR}/${include_prefix}/gen-cpp2"
+ )
+endfunction()
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindCereal.cmake treadmill/CMake/FindCereal.cmake
--- treadmill-src/CMake/FindCereal.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindCereal.cmake 2025-08-04 15:44:21.734737942 -0700
@@ -0,0 +1,21 @@
+find_path(Cereal_INCLUDE_DIR
+ NAMES cereal/cereal.hpp
+ PATHS "${CMAKE_SOURCE_DIR}/third_party/cereal"
+ PATH_SUFFIXES
+ include)
+
+mark_as_advanced(Cereal_INCLUDE_DIR)
+
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Cereal
+ REQUIRED_VARS Cereal_INCLUDE_DIR
+)
+
+if(Cereal_FOUND AND NOT TARGET Cereal::Cereal)
+ add_library(Cereal::Cereal INTERFACE IMPORTED)
+
+ set_target_properties(Cereal::Cereal PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Cereal_INCLUDE_DIR}"
+ )
+endif()
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindDoubleConversion.cmake treadmill/CMake/FindDoubleConversion.cmake
--- treadmill-src/CMake/FindDoubleConversion.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindDoubleConversion.cmake 2025-08-04 15:44:21.735422076 -0700
@@ -0,0 +1,26 @@
+# Copyright (c) 2017-present, Facebook, Inc. and its affiliates.
+# All rights reserved.
+#
+# This source code is licensed under the BSD-style license found in the
+# LICENSE file in the root directory of this source tree.
+
+find_path(DOUBLE_CONVERSION_INCLUDE_DIR
+ NAMES
+ double-conversion.h
+ PATHS
+ /usr/include/double-conversion
+ /usr/local/include/double-conversion)
+find_library(DOUBLE_CONVERSION_LIBRARY NAMES double-conversion)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+ DoubleConversion DEFAULT_MSG
+ DOUBLE_CONVERSION_LIBRARY DOUBLE_CONVERSION_INCLUDE_DIR)
+
+if (NOT DOUBLE_CONVERSION_FOUND)
+ message(STATUS "Using third-party bundled double-conversion")
+else()
+ message(STATUS "Found double-conversion: ${DOUBLE_CONVERSION_LIBRARY}")
+endif ()
+
+mark_as_advanced(DOUBLE_CONVERSION_INCLUDE_DIR DOUBLE_CONVERSION_LIBRARY)
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindGflags.cmake treadmill/CMake/FindGflags.cmake
--- treadmill-src/CMake/FindGflags.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindGflags.cmake 2025-08-04 15:44:21.736158410 -0700
@@ -0,0 +1,105 @@
+# Copyright (c) Facebook, Inc. and its affiliates.
+# Find libgflags.
+# There's a lot of compatibility cruft going on in here, both
+# to deal with changes across the FB consumers of this and also
+# to deal with variances in behavior of cmake itself.
+#
+# Since this file is named FindGflags.cmake the cmake convention
+# is for the module to export both GFLAGS_FOUND and Gflags_FOUND.
+# The convention expected by consumers is that we export the
+# following variables, even though these do not match the cmake
+# conventions:
+#
+# LIBGFLAGS_INCLUDE_DIR - where to find gflags/gflags.h, etc.
+# LIBGFLAGS_LIBRARY - List of libraries when using libgflags.
+# LIBGFLAGS_FOUND - True if libgflags found.
+#
+# We need to be able to locate gflags both from an installed
+# cmake config file and just from the raw headers and libs, so
+# test for the former and then the latter, and then stick
+# the results together and export them into the variables
+# listed above.
+#
+# For forwards compatibility, we export the following variables:
+#
+# gflags_INCLUDE_DIR - where to find gflags/gflags.h, etc.
+# gflags_TARGET / GFLAGS_TARGET / gflags_LIBRARIES
+# - List of libraries when using libgflags.
+# gflags_FOUND - True if libgflags found.
+#
+
+IF (LIBGFLAGS_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(Gflags_FIND_QUIETLY TRUE)
+ENDIF ()
+
+find_package(gflags CONFIG QUIET)
+if (gflags_FOUND)
+ if (NOT Gflags_FIND_QUIETLY)
+ message(STATUS "Found gflags from package config ${gflags_CONFIG}")
+ endif()
+ # Re-export the config-specified libs with our local names
+ set(LIBGFLAGS_LIBRARY ${gflags_LIBRARIES})
+ set(LIBGFLAGS_INCLUDE_DIR ${gflags_INCLUDE_DIR})
+ if(NOT EXISTS "${gflags_INCLUDE_DIR}")
+ # The gflags-devel RPM on recent RedHat-based systems is somewhat broken.
+ # RedHat symlinks /lib64 to /usr/lib64, and this breaks some of the
+ # relative path computation performed in gflags-config.cmake. The package
+ # config file ends up being found via /lib64, but the relative path
+ # computation it does only works if it was found in /usr/lib64.
+ # If gflags_INCLUDE_DIR does not actually exist, simply default it to
+ # /usr/include on these systems.
+ set(LIBGFLAGS_INCLUDE_DIR "/usr/include")
+ endif()
+ set(LIBGFLAGS_FOUND ${gflags_FOUND})
+ # cmake module compat
+ set(GFLAGS_FOUND ${gflags_FOUND})
+ set(Gflags_FOUND ${gflags_FOUND})
+else()
+ FIND_PATH(LIBGFLAGS_INCLUDE_DIR gflags/gflags.h)
+
+ FIND_LIBRARY(LIBGFLAGS_LIBRARY_DEBUG NAMES gflagsd gflags_staticd)
+ FIND_LIBRARY(LIBGFLAGS_LIBRARY_RELEASE NAMES gflags gflags_static)
+
+ INCLUDE(SelectLibraryConfigurations)
+ SELECT_LIBRARY_CONFIGURATIONS(LIBGFLAGS)
+
+ # handle the QUIETLY and REQUIRED arguments and set LIBGFLAGS_FOUND to TRUE if
+ # all listed variables are TRUE
+ INCLUDE(FindPackageHandleStandardArgs)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(gflags DEFAULT_MSG LIBGFLAGS_LIBRARY LIBGFLAGS_INCLUDE_DIR)
+ # cmake module compat
+ set(Gflags_FOUND ${GFLAGS_FOUND})
+ # compat with some existing FindGflags consumers
+ set(LIBGFLAGS_FOUND ${GFLAGS_FOUND})
+
+ # Compat with the gflags CONFIG based detection
+ set(gflags_FOUND ${GFLAGS_FOUND})
+ set(gflags_INCLUDE_DIR ${LIBGFLAGS_INCLUDE_DIR})
+ set(gflags_LIBRARIES ${LIBGFLAGS_LIBRARY})
+ set(GFLAGS_TARGET ${LIBGFLAGS_LIBRARY})
+ set(gflags_TARGET ${LIBGFLAGS_LIBRARY})
+
+ MARK_AS_ADVANCED(LIBGFLAGS_LIBRARY LIBGFLAGS_INCLUDE_DIR)
+endif()
+
+# Compat with the gflags CONFIG based detection
+if (LIBGFLAGS_FOUND AND NOT TARGET gflags)
+ add_library(gflags UNKNOWN IMPORTED)
+ if(TARGET gflags-shared)
+ # If the installed gflags CMake package config defines a gflags-shared
+ # target but not gflags, just make the gflags target that we define
+ # depend on the gflags-shared target.
+ target_link_libraries(gflags INTERFACE gflags-shared)
+ # Export LIBGFLAGS_LIBRARY as the gflags-shared target in this case.
+ set(LIBGFLAGS_LIBRARY gflags-shared)
+ else()
+ set_target_properties(
+ gflags
+ PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${LIBGFLAGS_LIBRARY}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LIBGFLAGS_INCLUDE_DIR}"
+ )
+ endif()
+endif()
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindGlog.cmake treadmill/CMake/FindGlog.cmake
--- treadmill-src/CMake/FindGlog.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindGlog.cmake 2025-08-04 15:44:21.736813991 -0700
@@ -0,0 +1,37 @@
+# Copyright (c) Facebook, Inc. and its affiliates.
+# - Try to find Glog
+# Once done, this will define
+#
+# GLOG_FOUND - system has Glog
+# GLOG_INCLUDE_DIRS - the Glog include directories
+# GLOG_LIBRARIES - link these to use Glog
+
+include(FindPackageHandleStandardArgs)
+include(SelectLibraryConfigurations)
+
+find_library(GLOG_LIBRARY_RELEASE glog
+ PATHS ${GLOG_LIBRARYDIR})
+find_library(GLOG_LIBRARY_DEBUG glogd
+ PATHS ${GLOG_LIBRARYDIR})
+
+find_path(GLOG_INCLUDE_DIR glog/logging.h
+ PATHS ${GLOG_INCLUDEDIR})
+
+select_library_configurations(GLOG)
+
+find_package_handle_standard_args(glog DEFAULT_MSG
+ GLOG_LIBRARY
+ GLOG_INCLUDE_DIR)
+
+mark_as_advanced(
+ GLOG_LIBRARY
+ GLOG_INCLUDE_DIR)
+
+set(GLOG_LIBRARIES ${GLOG_LIBRARY})
+set(GLOG_INCLUDE_DIRS ${GLOG_INCLUDE_DIR})
+
+if (NOT TARGET glog::glog)
+ add_library(glog::glog UNKNOWN IMPORTED)
+ set_target_properties(glog::glog PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${GLOG_INCLUDE_DIRS}")
+ set_target_properties(glog::glog PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${GLOG_LIBRARIES}")
+endif()
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindGMock.cmake treadmill/CMake/FindGMock.cmake
--- treadmill-src/CMake/FindGMock.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindGMock.cmake 2025-08-04 15:44:21.737281097 -0700
@@ -0,0 +1,80 @@
+# Copyright (c) Facebook, Inc. and its affiliates.
+# Find libgmock
+#
+# LIBGMOCK_DEFINES - List of defines when using libgmock.
+# LIBGMOCK_INCLUDE_DIR - where to find gmock/gmock.h, etc.
+# LIBGMOCK_LIBRARIES - List of libraries when using libgmock.
+# LIBGMOCK_FOUND - True if libgmock found.
+
+IF (LIBGMOCK_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(LIBGMOCK_FIND_QUIETLY TRUE)
+ENDIF ()
+
+find_package(GTest CONFIG QUIET)
+if (TARGET GTest::gmock)
+ get_target_property(LIBGMOCK_DEFINES GTest::gtest INTERFACE_COMPILE_DEFINITIONS)
+ if (NOT ${LIBGMOCK_DEFINES})
+ # Explicitly set to empty string if not found to avoid it being
+ # set to NOTFOUND and breaking compilation
+ set(LIBGMOCK_DEFINES "")
+ endif()
+ get_target_property(LIBGMOCK_INCLUDE_DIR GTest::gtest INTERFACE_INCLUDE_DIRECTORIES)
+ set(LIBGMOCK_LIBRARIES GTest::gmock_main GTest::gmock GTest::gtest)
+ set(LIBGMOCK_FOUND ON)
+ message(STATUS "Found gmock via config, defines=${LIBGMOCK_DEFINES}, include=${LIBGMOCK_INCLUDE_DIR}, libs=${LIBGMOCK_LIBRARIES}")
+else()
+
+ FIND_PATH(LIBGMOCK_INCLUDE_DIR gmock/gmock.h)
+
+ FIND_LIBRARY(LIBGMOCK_MAIN_LIBRARY_DEBUG NAMES gmock_maind)
+ FIND_LIBRARY(LIBGMOCK_MAIN_LIBRARY_RELEASE NAMES gmock_main)
+ FIND_LIBRARY(LIBGMOCK_LIBRARY_DEBUG NAMES gmockd)
+ FIND_LIBRARY(LIBGMOCK_LIBRARY_RELEASE NAMES gmock)
+ FIND_LIBRARY(LIBGTEST_LIBRARY_DEBUG NAMES gtestd)
+ FIND_LIBRARY(LIBGTEST_LIBRARY_RELEASE NAMES gtest)
+
+ find_package(Threads REQUIRED)
+ INCLUDE(SelectLibraryConfigurations)
+ SELECT_LIBRARY_CONFIGURATIONS(LIBGMOCK_MAIN)
+ SELECT_LIBRARY_CONFIGURATIONS(LIBGMOCK)
+ SELECT_LIBRARY_CONFIGURATIONS(LIBGTEST)
+
+ set(LIBGMOCK_LIBRARIES
+ ${LIBGMOCK_MAIN_LIBRARY}
+ ${LIBGMOCK_LIBRARY}
+ ${LIBGTEST_LIBRARY}
+ Threads::Threads
+ )
+
+ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ # The GTEST_LINKED_AS_SHARED_LIBRARY macro must be set properly on Windows.
+ #
+ # There isn't currently an easy way to determine if a library was compiled as
+ # a shared library on Windows, so just assume we've been built against a
+ # shared build of gmock for now.
+ SET(LIBGMOCK_DEFINES "GTEST_LINKED_AS_SHARED_LIBRARY=1" CACHE STRING "")
+ endif()
+
+ # handle the QUIETLY and REQUIRED arguments and set LIBGMOCK_FOUND to TRUE if
+ # all listed variables are TRUE
+ INCLUDE(FindPackageHandleStandardArgs)
+ FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+ GMock
+ DEFAULT_MSG
+ LIBGMOCK_MAIN_LIBRARY
+ LIBGMOCK_LIBRARY
+ LIBGTEST_LIBRARY
+ LIBGMOCK_LIBRARIES
+ LIBGMOCK_INCLUDE_DIR
+ )
+
+ MARK_AS_ADVANCED(
+ LIBGMOCK_DEFINES
+ LIBGMOCK_MAIN_LIBRARY
+ LIBGMOCK_LIBRARY
+ LIBGTEST_LIBRARY
+ LIBGMOCK_LIBRARIES
+ LIBGMOCK_INCLUDE_DIR
+ )
+endif()
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindLibEvent.cmake treadmill/CMake/FindLibEvent.cmake
--- treadmill-src/CMake/FindLibEvent.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindLibEvent.cmake 2025-08-04 15:44:21.737884690 -0700
@@ -0,0 +1,38 @@
+# - Find LibEvent (a cross event library)
+# This module defines
+# LIBEVENT_INCLUDE_DIR, where to find LibEvent headers
+# LIBEVENT_LIB, LibEvent libraries
+# LibEvent_FOUND, If false, do not try to use libevent
+
+set(LibEvent_EXTRA_PREFIXES /usr/local /opt/local "$ENV{HOME}")
+foreach(prefix ${LibEvent_EXTRA_PREFIXES})
+ list(APPEND LibEvent_INCLUDE_PATHS "${prefix}/include")
+ list(APPEND LibEvent_LIB_PATHS "${prefix}/lib")
+endforeach()
+
+find_path(LIBEVENT_INCLUDE_DIR event.h PATHS ${LibEvent_INCLUDE_PATHS})
+find_library(LIBEVENT_LIB NAMES event PATHS ${LibEvent_LIB_PATHS})
+find_library(LIBEVENT_PTHREAD_LIB NAMES event_pthreads PATHS ${LibEvent_LIB_PATHS})
+
+if (LIBEVENT_LIB AND LIBEVENT_INCLUDE_DIR AND LIBEVENT_PTHREAD_LIB)
+ set(LibEvent_FOUND TRUE)
+ set(LIBEVENT_LIB ${LIBEVENT_LIB} ${LIBEVENT_PTHREAD_LIB})
+else ()
+ set(LibEvent_FOUND FALSE)
+endif ()
+
+if (LibEvent_FOUND)
+ if (NOT LibEvent_FIND_QUIETLY)
+ message(STATUS "Found libevent: ${LIBEVENT_LIB}")
+ endif ()
+else ()
+ if (LibEvent_FIND_REQUIRED)
+ message(FATAL_ERROR "Could NOT find libevent and libevent_pthread.")
+ endif ()
+ message(STATUS "libevent and libevent_pthread NOT found.")
+endif ()
+
+mark_as_advanced(
+ LIBEVENT_LIB
+ LIBEVENT_INCLUDE_DIR
+ )
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindLibIberty.cmake treadmill/CMake/FindLibIberty.cmake
--- treadmill-src/CMake/FindLibIberty.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindLibIberty.cmake 2025-08-04 15:44:21.738594913 -0700
@@ -0,0 +1,25 @@
+# Copyright (c) 2017-present, Facebook, Inc. and its affiliates.
+# All rights reserved.
+#
+# This source code is licensed under the BSD-style license found in the
+# LICENSE file in the root directory of this source tree.
+
+FIND_LIBRARY(IBERTY_LIBRARIES
+ NAMES iberty_pic iberty)
+
+IF (IBERTY_LIBRARIES)
+
+ # show which libiberty was found only if not quiet
+ MESSAGE( STATUS "Found libiberty: ${IBERTY_LIBRARIES}")
+
+ SET(IBERTY_FOUND TRUE)
+
+ELSE (IBERTY_LIBRARIES)
+
+ IF ( IBERTY_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "Could not find libiberty. Try to install binutil-devel?")
+ ELSE()
+ MESSAGE(STATUS "Could not find libiberty; downloading binutils and building PIC libiberty.")
+ ENDIF (IBERTY_FIND_REQUIRED)
+
+ENDIF (IBERTY_LIBRARIES)
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindLZ4.cmake treadmill/CMake/FindLZ4.cmake
--- treadmill-src/CMake/FindLZ4.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindLZ4.cmake 2025-08-04 15:44:21.739204906 -0700
@@ -0,0 +1,21 @@
+# Copyright (c) 2017-present, Facebook, Inc. and its affiliates.
+# All rights reserved.
+#
+# This source code is licensed under the BSD-style license found in the
+# LICENSE file in the root directory of this source tree.
+
+find_path(LZ4_INCLUDE_DIR NAMES lz4.h)
+find_library(LZ4_LIBRARY NAMES lz4)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+ LZ4 DEFAULT_MSG
+ LZ4_LIBRARY LZ4_INCLUDE_DIR)
+
+if (NOT LZ4_FOUND)
+ message(STATUS "Using third-party bundled LZ4")
+else()
+ message(STATUS "Found LZ4: ${LZ4_LIBRARY}")
+endif (NOT LZ4_FOUND)
+
+mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY)
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindSnappy.cmake treadmill/CMake/FindSnappy.cmake
--- treadmill-src/CMake/FindSnappy.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindSnappy.cmake 2025-08-04 15:44:21.739902771 -0700
@@ -0,0 +1,21 @@
+# Copyright (c) 2017-present, Facebook, Inc. and its affiliates.
+# All rights reserved.
+#
+# This source code is licensed under the BSD-style license found in the
+# LICENSE file in the root directory of this source tree.
+
+find_path(SNAPPY_INCLUDE_DIR NAMES snappy.h)
+find_library(SNAPPY_LIBRARY NAMES snappy)
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(
+ Snappy DEFAULT_MSG
+ SNAPPY_LIBRARY SNAPPY_INCLUDE_DIR)
+
+if (NOT SNAPPY_FOUND)
+ message(STATUS "Using third-party bundled Snappy")
+else()
+ message(STATUS "Found Snappy: ${SNAPPY_LIBRARY}")
+endif (NOT SNAPPY_FOUND)
+
+mark_as_advanced(SNAPPY_INCLUDE_DIR SNAPPY_LIBRARY)
diff -wbBdu -ruN '--exclude=.git' '--exclude=*.rej' '--exclude=*.orig' '--exclude=gen-cpp2' '--exclude=build' '--exclude=third_party' treadmill-src/CMake/FindSodium.cmake treadmill/CMake/FindSodium.cmake
--- treadmill-src/CMake/FindSodium.cmake 1969-12-31 16:00:00.000000000 -0800
+++ treadmill/CMake/FindSodium.cmake 2025-08-04 15:44:21.740726787 -0700
@@ -0,0 +1,297 @@
+# Written in 2016 by Henrik Steffen Gaßmann <henrik@gassmann.onl>
+#
+# To the extent possible under law, the author(s) have dedicated all
+# copyright and related and neighboring rights to this software to the
+# public domain worldwide. This software is distributed without any warranty.
+#
+# You should have received a copy of the CC0 Public Domain Dedication
+# along with this software. If not, see
+#
+# http://creativecommons.org/publicdomain/zero/1.0/
+#
+########################################################################
+# Tries to find the local libsodium installation.
+#
+# On Windows the sodium_DIR environment variable is used as a default
+# hint which can be overridden by setting the corresponding cmake variable.
+#
+# Once done the following variables will be defined:
+#
+# sodium_FOUND
+# sodium_INCLUDE_DIR
+# sodium_LIBRARY_DEBUG
+# sodium_LIBRARY_RELEASE
+#
+#
+# Furthermore an imported "sodium" target is created.
+#
+
+if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
+ OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
+ set(_GCC_COMPATIBLE 1)
+endif()
+
+# static library option
+if (NOT DEFINED sodium_USE_STATIC_LIBS)
+ option(sodium_USE_STATIC_LIBS "enable to statically link against sodium" OFF)
+endif()
+if(NOT (sodium_USE_STATIC_LIBS EQUAL sodium_USE_STATIC_LIBS_LAST))
+ unset(sodium_LIBRARY CACHE)
+ unset(sodium_LIBRARY_DEBUG CACHE)
+ unset(sodium_LIBRARY_RELEASE CACHE)
+ unset(sodium_DLL_DEBUG CACHE)
+ unset(sodium_DLL_RELEASE CACHE)
+ set(sodium_USE_STATIC_LIBS_LAST ${sodium_USE_STATIC_LIBS} CACHE INTERNAL "internal change tracking variable")
+endif()
+
+
+########################################################################
+# UNIX
+if (UNIX)
+ # import pkg-config
+ find_package(PkgConfig QUIET)
+ if (PKG_CONFIG_FOUND)
+ pkg_check_modules(sodium_PKG QUIET libsodium)
+ endif()
+
+ if(sodium_USE_STATIC_LIBS)
+ foreach(_libname ${sodium_PKG_STATIC_LIBRARIES})
+ if (NOT _libname MATCHES "^lib.*\\.a$") # ignore strings already ending with .a
+ list(INSERT sodium_PKG_STATIC_LIBRARIES 0 "lib${_libname}.a")
+ endif()
+ endforeach()
+ list(REMOVE_DUPLICATES sodium_PKG_STATIC_LIBRARIES)
+
+ # if pkgconfig for libsodium doesn't provide
+ # static lib info, then override PKG_STATIC here..
+ if (NOT sodium_PKG_STATIC_FOUND)
+ set(sodium_PKG_STATIC_LIBRARIES libsodium.a)
+ endif()
+
+ set(XPREFIX sodium_PKG_STATIC)
+ else()
+ if (NOT sodium_PKG_FOUND)
+ set(sodium_PKG_LIBRARIES sodium)
+ endif()
+
+ set(XPREFIX sodium_PKG)
+ endif()
+
+ find_path(sodium_INCLUDE_DIR sodium.h
+ HINTS ${${XPREFIX}_INCLUDE_DIRS}
+ )
+ find_library(sodium_LIBRARY_DEBUG NAMES ${${XPREFIX}_LIBRARIES}
+ HINTS ${${XPREFIX}_LIBRARY_DIRS}
+ )
+ find_library(sodium_LIBRARY_RELEASE NAMES ${${XPREFIX}_LIBRARIES}
+ HINTS ${${XPREFIX}_LIBRARY_DIRS}
+ )
+
+
+########################################################################
+# Windows
+elseif (WIN32)
+ set(sodium_DIR "$ENV{sodium_DIR}" CACHE FILEPATH "sodium install directory")
+ mark_as_advanced(sodium_DIR)
+
+ find_path(sodium_INCLUDE_DIR sodium.h
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES include
+ )
+
+ if (MSVC)
+ # detect target architecture
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp" [=[
+ #if defined _M_IX86
+ #error ARCH_VALUE x86_32
+ #elif defined _M_X64
+ #error ARCH_VALUE x86_64
+ #endif
+ #error ARCH_VALUE unknown
+ ]=])
+ try_compile(_UNUSED_VAR "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/arch.cpp"
+ OUTPUT_VARIABLE _COMPILATION_LOG
+ )
+ string(REGEX REPLACE ".*ARCH_VALUE ([a-zA-Z0-9_]+).*" "\\1" _TARGET_ARCH "${_COMPILATION_LOG}")
+
+ # construct library path
+ if (_TARGET_ARCH STREQUAL "x86_32")
+ string(APPEND _PLATFORM_PATH "Win32")
+ elseif(_TARGET_ARCH STREQUAL "x86_64")
+ string(APPEND _PLATFORM_PATH "x64")
+ else()
+ message(FATAL_ERROR "the ${_TARGET_ARCH} architecture is not supported by Findsodium.cmake.")
+ endif()
+ string(APPEND _PLATFORM_PATH "/$$CONFIG$$")
+
+ if (MSVC_VERSION LESS 1900)
+ math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 60")
+ else()
+ math(EXPR _VS_VERSION "${MSVC_VERSION} / 10 - 50")
+ endif()
+ string(APPEND _PLATFORM_PATH "/v${_VS_VERSION}")
+
+ if (sodium_USE_STATIC_LIBS)
+ string(APPEND _PLATFORM_PATH "/static")
+ else()
+ string(APPEND _PLATFORM_PATH "/dynamic")
+ endif()
+
+ string(REPLACE "$$CONFIG$$" "Debug" _DEBUG_PATH_SUFFIX "${_PLATFORM_PATH}")
+ string(REPLACE "$$CONFIG$$" "Release" _RELEASE_PATH_SUFFIX "${_PLATFORM_PATH}")
+
+ find_library(sodium_LIBRARY_DEBUG libsodium.lib
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
+ )
+ find_library(sodium_LIBRARY_RELEASE libsodium.lib
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
+ )
+ if (NOT sodium_USE_STATIC_LIBS)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES_BCK ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ".dll")
+ find_library(sodium_DLL_DEBUG libsodium
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES ${_DEBUG_PATH_SUFFIX}
+ )
+ find_library(sodium_DLL_RELEASE libsodium
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES ${_RELEASE_PATH_SUFFIX}
+ )
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES_BCK})
+ endif()
+
+ elseif(_GCC_COMPATIBLE)
+ if (sodium_USE_STATIC_LIBS)
+ find_library(sodium_LIBRARY_DEBUG libsodium.a
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES lib
+ )
+ find_library(sodium_LIBRARY_RELEASE libsodium.a
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES lib
+ )
+ else()
+ find_library(sodium_LIBRARY_DEBUG libsodium.dll.a
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES lib
+ )
+ find_library(sodium_LIBRARY_RELEASE libsodium.dll.a
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES lib
+ )
+
+ file(GLOB _DLL
+ LIST_DIRECTORIES false
+ RELATIVE "${sodium_DIR}/bin"
+ "${sodium_DIR}/bin/libsodium*.dll"
+ )
+ find_library(sodium_DLL_DEBUG ${_DLL} libsodium
+ HINTS ${sodium_DIR}
+ PATH_SUFFIXES bin