forked from mongodb/mongo-c-driver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
1192 lines (1050 loc) · 42.6 KB
/
CMakeLists.txt
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
cmake_minimum_required (VERSION 3.1)
# Used in MaintainerFlags.cmake to silence errors while testing configs.
set (MESSAGES_ENABLED 1)
function (message)
list (GET ARGV 0 MessageType)
if (MESSAGES_ENABLED)
list (REMOVE_AT ARGV 0)
_message (${MessageType} "${ARGV}")
endif ()
endfunction ()
set (ENABLE_SSL AUTO CACHE STRING
"Enable TLS connections and SCRAM-SHA-1 authentication. Options are
\"DARWIN\" to use Apple's Secure Transport, \"WINDOWS\" to use Windows
Secure Channel, \"OPENSSL\", \"LIBRESSL\", \"AUTO\",\ or \"OFF\". These options are
case-sensitive. The default is \"AUTO\". Note\ that SCRAM-SHA-1 is
required for authenticating to MongoDB 3.0 and later.")
set (ENABLE_SASL AUTO CACHE STRING
"Enable SASL authentication (Kerberos). Options are \"CYRUS\" to use Cyrus
SASL, \"SSPI\" to use Windows Native SSPI, \"GSSAPI\" to use macOS Native GSS,
\"AUTO\",\ or \"OFF\". These options are case-sensitive.")
set (ENABLE_STATIC AUTO CACHE STRING "Build static libmongoc. Set to ON/AUTO/OFF, default AUTO.")
option (ENABLE_TESTS "Build MongoDB C Driver tests." ON)
option (ENABLE_EXAMPLES "Build MongoDB C Driver examples." ON)
set (ENABLE_SRV AUTO CACHE STRING "Support mongodb+srv URIs. Set to ON/AUTO/OFF, default AUTO.")
option (ENABLE_MAINTAINER_FLAGS "Use strict compiler checks" OFF)
option (ENABLE_AUTOMATIC_INIT_AND_CLEANUP "Enable automatic init and cleanup (GCC only)" ON)
option (ENABLE_CRYPTO_SYSTEM_PROFILE "Use system crypto profile (OpenSSL only)" OFF)
option (ENABLE_TRACING "Turn on verbose debug output" OFF)
option (ENABLE_COVERAGE "Turn on compile options for lcov" OFF)
set (ENABLE_SHM_COUNTERS AUTO CACHE STRING "Enable memory performance counters that use shared memory on Linux. Set to ON/AUTO/OFF, default AUTO.")
set (ENABLE_BSON AUTO CACHE STRING "Where to find libbson. Set to BUNDLED/SYSTEM/AUTO/ONLY, default AUTO.")
set (ENABLE_SNAPPY AUTO CACHE STRING "Enable snappy support. Set to ON/AUTO/OFF, default AUTO.")
set (ENABLE_ZLIB AUTO CACHE STRING "Enable zlib support")
option (ENABLE_MAN_PAGES "Build MongoDB C Driver manual pages." OFF)
option (ENABLE_HTML_DOCS "Build MongoDB C Driver HTML documentation." OFF)
option (ENABLE_EXTRA_ALIGNMENT
"Turn on extra alignment of libbson types. Set to ON/OFF, default ON.\
Required for the 1.0 ABI but better disabled."
ON
)
option (ENABLE_RDTSCP
"Fast performance counters on Intel using the RDTSCP instruction"
OFF
)
project (libmongoc C)
set (CMAKE_MODULE_PATH
${CMAKE_MODULE_PATH}
${PROJECT_SOURCE_DIR}/build/cmake
${PROJECT_SOURCE_DIR}/build/cmake/make_dist
)
include (InstallRequiredSystemLibraries)
include (GNUInstallDirs)
# Set MONGOC_MAJOR_VERSION, MONGOC_MINOR_VERSION, etc.
include (LoadVersion)
LoadVersion (${PROJECT_SOURCE_DIR}/VERSION_CURRENT MONGOC)
LoadVersion (${PROJECT_SOURCE_DIR}/VERSION_RELEASED MONGOC_RELEASED)
message ("libmongoc version (from VERSION_CURRENT file): ${MONGOC_VERSION}")
if (NOT ${MONGOC_VERSION} STREQUAL ${MONGOC_RELEASED_VERSION})
message ("libmongoc previous release (from VERSION_RELEASED file): ${MONGOC_RELEASED_VERSION}")
endif ()
include (MaintainerFlags)
if ( (ENABLE_BUILD_DEPENDECIES STREQUAL OFF) AND (NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) )
set (ENABLE_BUILD_DEPENDECIES ON)
endif ()
if (ENABLE_EXTRA_ALIGNMENT STREQUAL ON)
set (BSON_EXTRA_ALIGN 1)
else ()
set (BSON_EXTRA_ALIGN 0)
endif ()
if (ENABLE_RDTSCP)
set (MONGOC_ENABLE_RDTSCP 1)
else ()
set (MONGOC_ENABLE_RDTSCP 0)
endif ()
if (NOT ENABLE_BSON MATCHES "SYSTEM|AUTO|BUNDLED|ONLY")
message (FATAL_ERROR "ENABLE_BSON option must be SYSTEM, BUNDLED, or AUTO")
endif ()
if (NOT ENABLE_BSON STREQUAL BUNDLED)
# The input variable BSON_ROOT_DIR is respected for backwards compatibility,
# but you should use the standard CMAKE_PREFIX_PATH instead.
message (STATUS "Searching for libbson CMake packages")
find_package (libbson-1.0
"${MONGOC_MAJOR_VERSION}.${MONGOC_MINOR_VERSION}.${MONGOC_MICRO_VERSION}"
HINTS
${BSON_ROOT_DIR})
if (ENABLE_BSON STREQUAL SYSTEM AND NOT BSON_LIBRARIES)
message (FATAL_ERROR "System libbson not found")
endif ()
if (BSON_LIBRARIES)
message ("-- libbson found version \"${BSON_VERSION}\"")
message ("-- libbson include path \"${BSON_INCLUDE_DIRS}\"")
message ("-- libbson libraries \"${BSON_LIBRARIES}\"")
if (ENABLE_STATIC MATCHES "ON|AUTO")
find_package (libbson-static-1.0
"${MONGOC_MAJOR_VERSION}.${MONGOC_MINOR_VERSION}.${MONGOC_MICRO_VERSION}"
HINTS
${BSON_ROOT_DIR})
if (ENABLE_STATIC STREQUAL ON AND NOT BSON_STATIC_LIBRARY)
message (FATAL_ERROR "Static libbson not found. Pass -DENABLE_STATIC=OFF")
endif ()
if (BSON_STATIC_LIBRARY)
set (MONGOC_ENABLE_STATIC ON)
endif ()
message ("-- libbson-static found version \"${BSON_STATIC_VERSION}\"")
message ("-- libbson-static include path \"${BSON_STATIC_INCLUDE_DIRS}\"")
message ("-- libbson-static libraries \"${BSON_STATIC_LIBRARIES}\"")
endif ()
endif ()
endif ()
unset (dist_generated CACHE)
unset (dist_generated_depends CACHE)
set (BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
include (MakeDistFiles)
if (NOT BSON_LIBRARIES)
message (" -- Using bundled libbson")
if (ENABLE_STATIC MATCHES "ON|AUTO")
set (MONGOC_ENABLE_STATIC ON)
endif ()
add_subdirectory (src/libbson)
# Defined in src/libbson/CMakeLists.txt
set (BSON_STATIC_LIBRARIES bson_static)
set (BSON_LIBRARIES bson_shared)
set (BSON_STATIC_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/libbson/src/bson" "${PROJECT_BINARY_DIR}/src/libbson/src/bson")
set (BSON_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/src/libbson/src/bson" "${PROJECT_BINARY_DIR}/src/libbson/src/bson")
set (BSON_STATIC_DEFINITIONS "BSON_STATIC")
endif ()
# This allows skipping all the non-bson components
if (ENABLE_BSON STREQUAL ONLY)
return ()
endif ()
if (ENABLE_TESTS AND NOT MONGOC_ENABLE_STATIC)
message (FATAL_ERROR "ENABLE_TESTS requires ENABLE_STATIC")
endif ()
if (NOT ENABLE_SSL MATCHES "DARWIN|WINDOWS|OPENSSL|LIBRESSL|AUTO|OFF")
message (FATAL_ERROR
"ENABLE_SSL option must be DARWIN, WINDOWS, OPENSSL, LIBRESSL, AUTO, or OFF")
endif ()
if (NOT ENABLE_SSL STREQUAL OFF)
# Try OpenSSL automatically everywhere but Mac and Windows.
if (ENABLE_SSL STREQUAL "OPENSSL"
OR (NOT APPLE AND NOT WIN32 AND ENABLE_SSL STREQUAL "AUTO"))
# Sets OPENSSL_FOUND on success.
include (FindOpenSSL)
endif ()
if (ENABLE_SSL STREQUAL LIBRESSL)
include (FindPkgConfig)
message ("-- Searching for LibreSSL/libtls")
pkg_check_modules (LIBRESSL libtls)
if (LIBRESSL_FOUND)
message ("-- Found ${LIBRESSL_LIBRARIES}")
set (SSL_LIBRARIES ${LIBRESSL_LIBRARIES})
include_directories ("${LIBRESSL_INCLUDE_DIRS}")
link_directories ("${LIBRESSL_LIBRARY_DIRS}")
set (LIBRESSL 1)
else ()
message ("-- Not found")
endif ()
endif ()
if (ENABLE_SSL STREQUAL DARWIN OR (APPLE AND ENABLE_SSL STREQUAL "AUTO"))
if (APPLE)
set (SECURE_TRANSPORT 1)
else ()
message (FATAL_ERROR "ENABLE_SSL=DARWIN only supported on Mac OS X")
endif ()
endif ()
if (ENABLE_SSL STREQUAL WINDOWS OR (WIN32 AND ENABLE_SSL STREQUAL "AUTO"))
if (WIN32)
set (SECURE_CHANNEL 1)
else ()
message (FATAL_ERROR "ENABLE_SSL=WINDOWS only supported on Windows")
endif ()
endif ()
if (NOT OPENSSL_FOUND AND NOT SECURE_TRANSPORT AND NOT SECURE_CHANNEL AND NOT LIBRESSL)
if (ENABLE_SSL STREQUAL AUTO)
set (ENABLE_SSL OFF)
else ()
message (FATAL_ERROR "No SSL library found")
endif ()
endif ()
endif ()
# Defaults.
set (MONGOC_ENABLE_SSL 0)
set (MONGOC_ENABLE_SSL_OPENSSL 0)
set (MONGOC_HAVE_ASN1_STRING_GET0_DATA 0)
set (MONGOC_ENABLE_SSL_LIBRESSL 0)
set (MONGOC_ENABLE_SSL_SECURE_TRANSPORT 0)
set (MONGOC_ENABLE_SSL_SECURE_CHANNEL 0)
set (MONGOC_ENABLE_CRYPTO 0)
set (MONGOC_ENABLE_CRYPTO_LIBCRYPTO 0)
set (MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO 0)
set (MONGOC_ENABLE_CRYPTO_CNG 0)
set (MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE 0)
set (MONGOC_ENABLE_COMPRESSION 0)
set (MONGOC_ENABLE_COMPRESSION_SNAPPY 0)
set (MONGOC_ENABLE_COMPRESSION_ZLIB 0)
if (OPENSSL_FOUND)
if (WIN32 AND OPENSSL_VERSION GREATER 1.1 AND NOT
${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.7)
message (FATAL_ERROR "Building against OpenSSL 1.1.0 and later requires CMake 3.7 or later (hint:"
"You can also compile against Windows Secure Transport with -DENABLE_SSL=WINDOWS")
endif ()
if (APPLE AND NOT OPENSSL_ROOT_DIR)
message (WARNING "Building with OpenSSL but OPENSSL_ROOT_DIR not defined. If build fails to link"
" to OpenSSL, define OPENSSL_ROOT_DIR as the path to the OpenSSL installation directory.")
endif ()
include (CheckLibraryExists)
# Check for newer OpenSSL string function.
check_library_exists (ssl
ASN1_STRING_get0_data "openssl/asn1.h" HAVE_ASN1_STRING_GET0_DATA
)
if (HAVE_ASN1_STRING_GET0_DATA)
set (MONGOC_HAVE_ASN1_STRING_GET0_DATA 1)
endif ()
set (MONGOC_ENABLE_SSL 1)
set (MONGOC_ENABLE_SSL_OPENSSL 1)
set (MONGOC_ENABLE_CRYPTO 1)
set (MONGOC_ENABLE_CRYPTO_LIBCRYPTO 1)
elseif (SECURE_TRANSPORT)
set (MONGOC_ENABLE_SSL 1)
set (MONGOC_ENABLE_SSL_SECURE_TRANSPORT 1)
set (MONGOC_ENABLE_CRYPTO 1)
set (MONGOC_ENABLE_CRYPTO_COMMON_CRYPTO 1)
elseif (SECURE_CHANNEL)
set (MONGOC_ENABLE_SSL 1)
set (MONGOC_ENABLE_SSL_SECURE_CHANNEL 1)
set (MONGOC_ENABLE_CRYPTO 1)
set (MONGOC_ENABLE_CRYPTO_CNG 1)
elseif (LIBRESSL)
set (MONGOC_ENABLE_SSL 1)
set (MONGOC_ENABLE_SSL_LIBRESSL 1)
set (MONGOC_ENABLE_CRYPTO 1)
set (MONGOC_ENABLE_CRYPTO_LIBCRYPTO 1)
endif ()
if (ENABLE_CRYPTO_SYSTEM_PROFILE)
if (OPENSSL_FOUND)
set (MONGOC_ENABLE_CRYPTO_SYSTEM_PROFILE 1)
else ()
message (FATAL_ERROR "ENABLE_CRYPTO_SYSTEM_PROFILE only available with OpenSSL")
endif ()
endif ()
if (NOT ENABLE_SASL MATCHES "CYRUS|GSSAPI|SSPI|AUTO|OFF")
message (FATAL_ERROR
"ENABLE_SASL option must be CYRUS, GSSAPI, SSPI, AUTO, or OFF")
endif ()
# Defaults.
set (MONGOC_ENABLE_SASL 0)
set (MONGOC_ENABLE_SASL_CYRUS 0)
set (MONGOC_ENABLE_SASL_GSSAPI 0)
set (MONGOC_ENABLE_SASL_SSPI 0)
set (MONGOC_HAVE_SASL_CLIENT_DONE 0)
if (NOT ENABLE_SASL STREQUAL OFF)
if (ENABLE_SASL MATCHES "AUTO|CYRUS")
# Sets SASL_LIBRARIES.
include (FindSASL2)
endif ()
if (SASL_FOUND)
set (MONGOC_ENABLE_SASL 1)
set (MONGOC_ENABLE_SASL_CYRUS 1)
elseif ( (ENABLE_SASL MATCHES "SSPI|AUTO") AND WIN32)
set (MONGOC_ENABLE_SASL 1)
set (MONGOC_ENABLE_SASL_SSPI 1)
elseif ( (ENABLE_SASL MATCHES "GSSAPI|AUTO") AND DARWIN)
set (MONGOC_ENABLE_SASL 1)
set (MONGOC_ENABLE_SASL_GSSAPI 1)
endif ()
else ()
set (MONGOC_ENABLE_SASL 0)
endif ()
if (ENABLE_AUTOMATIC_INIT_AND_CLEANUP)
set (MONGOC_NO_AUTOMATIC_GLOBALS 0)
else ()
set (MONGOC_NO_AUTOMATIC_GLOBALS 1)
endif ()
include (CheckTypeSize)
if (WIN32)
SET (CMAKE_EXTRA_INCLUDE_FILES "ws2tcpip.h")
else ()
SET (CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h")
endif ()
CHECK_TYPE_SIZE (socklen_t HAVE_SOCKLEN)
SET (CMAKE_EXTRA_INCLUDE_FILES)
if (HAVE_SOCKLEN)
set (MONGOC_HAVE_SOCKLEN 1)
set (MONGOC_SOCKET_ARG3 "socklen_t")
else ()
set (MONGOC_HAVE_SOCKLEN 0)
set (MONGOC_SOCKET_ARG3 "int")
endif ()
include (FindResSearch)
include (CheckSchedGetCPU)
function (mongoc_get_accept_args ARG2 ARG3)
SET (VAR 0)
foreach (ARG2_VAL "struct sockaddr" "void")
foreach (ARG3_VAL "socklen_t" "size_t" "int")
MATH (EXPR VAR "${VAR}+1")
FILE (WRITE ${CMAKE_CURRENT_BINARY_DIR}/accept_test${VAR}.c
"#include <sys/types.h>
#include <sys/socket.h>
int main ()
{
int a = 0;
${ARG2_VAL} *b = 0;
${ARG3_VAL} *c = 0;
accept (a, b, c);
return 0;
}
")
TRY_COMPILE (RES ${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/accept_test${VAR}.c CMAKE_FLAGS
"-Werror -DCMAKE_CXX_LINK_EXECUTABLE='echo not linking now...'" OUTPUT_VARIABLE LOG2)
if (RES)
message (
STATUS
"Detected parameters: accept (int, ${ARG2_VAL} *, ${ARG3_VAL} *)")
set (${ARG2} ${ARG2_VAL} PARENT_SCOPE)
set (${ARG3} ${ARG3_VAL} PARENT_SCOPE)
return ()
endif ()
endforeach ()
endforeach ()
endfunction ()
# Reasonable defaults.
set (MONGOC_SOCKET_ARG2 "struct sockaddr")
set (MONGOC_SOCKET_ARG3 "socklen_t")
if (NOT WIN32)
mongoc_get_accept_args (MONGOC_SOCKET_ARG2 MONGOC_SOCKET_ARG3)
endif ()
set (SOURCE_DIR "${PROJECT_SOURCE_DIR}/")
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/build/cmake)
set (SOURCE_DIR "${PROJECT_SOURCE_DIR}/")
set (MONGOC_API_VERSION 1.0)
set (CPACK_RESOURCE_FILE_LICENSE "${SOURCE_DIR}/COPYING")
set (CPACK_PACKAGE_VERSION_MAJOR ${MONGOC_MAJOR_VERSION})
set (CPACK_PACKAGE_VERSION_MINOR ${MONGOC_MINOR_VERSION})
include (CPack)
set (MONGOC_CC ${CMAKE_C_COMPILER})
set (MONGOC_USER_SET_CFLAGS ${CMAKE_C_FLAGS})
set (MONGOC_USER_SET_LDFLAGS ${CMAKE_EXE_LINKER_FLAGS})
set (MONGOC_TRACE 0)
if (ENABLE_TRACING)
set (MONGOC_TRACE 1)
endif ()
if (ENABLE_COVERAGE)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g --coverage")
endif ()
set (MONGOC_ENABLE_SHM_COUNTERS 0)
if (NOT ENABLE_SHM_COUNTERS MATCHES "ON|OFF|AUTO")
message (FATAL_ERROR "ENABLE_SHM_COUNTERS option must be ON, OFF, or AUTO")
endif ()
if (ENABLE_SHM_COUNTERS STREQUAL "AUTO")
if (UNIX AND NOT APPLE)
set (ENABLE_SHM_COUNTERS ON)
endif ()
endif ()
if (ENABLE_SHM_COUNTERS STREQUAL "ON")
if (APPLE OR NOT UNIX)
message (
FATAL_ERROR
"Shared memory performance counters not supported on Mac or Windows")
endif ()
set (MONGOC_ENABLE_SHM_COUNTERS 1)
endif ()
set (MONGOC_INTERNAL_INCLUDE_DIRS "")
# Sets SNAPPY_LIBRARIES and SNAPPY_INCLUDE_DIRS.
include (FindSnappy)
if (SNAPPY_INCLUDE_DIRS)
set (MONGOC_ENABLE_COMPRESSION 1)
include_directories ("${SNAPPY_INCLUDE_DIRS}")
endif ()
if (NOT ENABLE_ZLIB MATCHES "SYSTEM|AUTO|BUNDLED|OFF")
message (FATAL_ERROR
"ENABLE_ZLIB option must be SYSTEM, BUNDLED, AUTO, or OFF"
)
endif ()
set (ZLIB_SOURCES
${SOURCE_DIR}/src/zlib-1.2.11/adler32.c
${SOURCE_DIR}/src/zlib-1.2.11/crc32.c
${SOURCE_DIR}/src/zlib-1.2.11/deflate.c
${SOURCE_DIR}/src/zlib-1.2.11/infback.c
${SOURCE_DIR}/src/zlib-1.2.11/inffast.c
${SOURCE_DIR}/src/zlib-1.2.11/inflate.c
${SOURCE_DIR}/src/zlib-1.2.11/inftrees.c
${SOURCE_DIR}/src/zlib-1.2.11/trees.c
${SOURCE_DIR}/src/zlib-1.2.11/zutil.c
${SOURCE_DIR}/src/zlib-1.2.11/compress.c
${SOURCE_DIR}/src/zlib-1.2.11/uncompr.c
${SOURCE_DIR}/src/zlib-1.2.11/gzclose.c
${SOURCE_DIR}/src/zlib-1.2.11/gzlib.c
${SOURCE_DIR}/src/zlib-1.2.11/gzread.c
${SOURCE_DIR}/src/zlib-1.2.11/gzwrite.c
)
# Disable warnings on bundled zlib source files.
set_source_files_properties (${ZLIB_SOURCES} PROPERTIES COMPILE_FLAGS -w)
# Copy zconf.h.in to zconf.h; even when using system zlib, the 'dist' target
# will look for zconf.h in that location.
configure_file (
"${SOURCE_DIR}/src/zlib-1.2.11/zconf.h.in"
"${PROJECT_BINARY_DIR}/src/zlib-1.2.11/zconf.h"
COPYONLY
)
if (ENABLE_ZLIB MATCHES "SYSTEM|AUTO")
message (STATUS "Searching for zlib CMake packages")
include (FindZLIB)
if (ZLIB_FOUND)
message ("-- zlib found version \"${ZLIB_VERSION_STRING}\"")
message ("-- zlib include path \"${ZLIB_INCLUDE_DIRS}\"")
message ("-- zlib libraries \"${ZLIB_LIBRARIES}\"")
include_directories ("${ZLIB_INCLUDE_DIRS}")
else ()
if (ENABLE_ZLIB STREQUAL "SYSTEM")
message (FATAL_ERROR
"Unable to find system zlib package. Either specify the zlib \
location by setting ZLIB_ROOT, or else set ENABLE_ZLIB=BUNDLED or \
set ENABLE_ZLIB=OFF."
)
endif()
set (ZLIB_LIBRARIES "")
endif ()
endif ()
if ( (ENABLE_ZLIB STREQUAL "BUNDLED")
OR (ENABLE_ZLIB STREQUAL "AUTO" AND NOT ZLIB_FOUND) )
message (STATUS "Enabling zlib compression (bundled)")
set (SOURCES ${SOURCES} ${ZLIB_SOURCES})
list (
APPEND
MONGOC_INTERNAL_INCLUDE_DIRS
"${SOURCE_DIR}/src/zlib-1.2.11"
"${PROJECT_BINARY_DIR}/src/zlib-1.2.11"
)
endif ()
if (NOT ENABLE_ZLIB STREQUAL "OFF")
# At this point the system zlib was found, or the bundled library was used
include (CheckIncludeFiles)
check_include_files ("unistd.h" HAVE_UNISTD_H)
check_include_files ("stdarg.h" HAVE_STDARG_H)
set (MONGOC_ENABLE_COMPRESSION 1)
set (MONGOC_ENABLE_COMPRESSION_ZLIB 1)
else ()
message (STATUS "Disabling zlib compression")
endif ()
configure_file (
"${SOURCE_DIR}/src/mongoc/mongoc-config.h.in"
"${PROJECT_BINARY_DIR}/src/mongoc/mongoc-config.h"
)
configure_file (
"${SOURCE_DIR}/src/mongoc/mongoc-version.h.in"
"${PROJECT_BINARY_DIR}/src/mongoc/mongoc-version.h"
)
include_directories ("${PROJECT_BINARY_DIR}/src/mongoc")
include_directories ("${SOURCE_DIR}/src/mongoc")
include_directories ("${PROJECT_SOURCE_DIR}/src/common")
if (UNIX AND NOT APPLE AND NOT ANDROID)
set (SHM_LIB -lrt)
endif ()
# Ensure the default behavior: don't ignore RPATH settings.
set (CMAKE_SKIP_BUILD_RPATH OFF)
# Ensure the default behavior: don't use the final install destination as the
# temporary RPATH for executables (ensure we can run tests and programs from
# the build directory).
set (CMAKE_BUILD_WITH_INSTALL_RPATH OFF)
# Include any custom library paths in the final RPATH.
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH ON)
# Install libs with names like @rpath/libmongoc-1.0.0.dylib, not bare names.
set (CMAKE_MACOSX_RPATH ON)
# https://cmake.org/cmake/help/v3.11/policy/CMP0042.html
# Enable a CMake 3.0+ policy that sets CMAKE_MACOSX_RPATH by default, and
# silence a CMake 3.11 warning that the old behavior is deprecated.
cmake_policy (SET CMP0042 NEW)
if (MSVC)
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
endif ()
add_definitions (-D_GNU_SOURCE)
add_definitions (-D_BSD_SOURCE)
add_definitions (-D_DEFAULT_SOURCE)
if (APPLE)
# Until CDRIVER-520.
add_definitions (-Wno-deprecated-declarations)
endif ()
set (SOURCES ${SOURCES}
${SOURCE_DIR}/src/mongoc/mongoc-apm.c
${SOURCE_DIR}/src/mongoc/mongoc-array.c
${SOURCE_DIR}/src/mongoc/mongoc-async.c
${SOURCE_DIR}/src/mongoc/mongoc-async-cmd.c
${SOURCE_DIR}/src/mongoc/mongoc-buffer.c
${SOURCE_DIR}/src/mongoc/mongoc-bulk-operation.c
${SOURCE_DIR}/src/mongoc/mongoc-change-stream.c
${SOURCE_DIR}/src/mongoc/mongoc-client.c
${SOURCE_DIR}/src/mongoc/mongoc-client-pool.c
${SOURCE_DIR}/src/mongoc/mongoc-cluster.c
${SOURCE_DIR}/src/mongoc/mongoc-collection.c
${SOURCE_DIR}/src/mongoc/mongoc-compression.c
${SOURCE_DIR}/src/mongoc/mongoc-counters.c
${SOURCE_DIR}/src/mongoc/mongoc-cursor-array.c
${SOURCE_DIR}/src/mongoc/mongoc-cursor.c
${SOURCE_DIR}/src/mongoc/mongoc-cursor-cmd.c
${SOURCE_DIR}/src/mongoc/mongoc-cursor-cmd-deprecated.c
${SOURCE_DIR}/src/mongoc/mongoc-cursor-find.c
${SOURCE_DIR}/src/mongoc/mongoc-cursor-find-cmd.c
${SOURCE_DIR}/src/mongoc/mongoc-cursor-find-opquery.c
${SOURCE_DIR}/src/mongoc/mongoc-cursor-legacy.c
${SOURCE_DIR}/src/mongoc/mongoc-cursor-array.c
${SOURCE_DIR}/src/mongoc/mongoc-database.c
${SOURCE_DIR}/src/mongoc/mongoc-find-and-modify.c
${SOURCE_DIR}/src/mongoc/mongoc-init.c
${SOURCE_DIR}/src/mongoc/mongoc-gridfs.c
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file.c
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-list.c
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-page.c
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-list.c
${SOURCE_DIR}/src/mongoc/mongoc-handshake.c
${SOURCE_DIR}/src/mongoc/mongoc-host-list.c
${SOURCE_DIR}/src/mongoc/mongoc-index.c
${SOURCE_DIR}/src/mongoc/mongoc-init.c
${SOURCE_DIR}/src/mongoc/mongoc-list.c
${SOURCE_DIR}/src/mongoc/mongoc-linux-distro-scanner.c
${SOURCE_DIR}/src/mongoc/mongoc-log.c
${SOURCE_DIR}/src/mongoc/mongoc-matcher.c
${SOURCE_DIR}/src/mongoc/mongoc-matcher-op.c
${SOURCE_DIR}/src/mongoc/mongoc-memcmp.c
${SOURCE_DIR}/src/mongoc/mongoc-cmd.c
${SOURCE_DIR}/src/mongoc/mongoc-opts.c
${SOURCE_DIR}/src/mongoc/mongoc-opts-helpers.c
${SOURCE_DIR}/src/mongoc/mongoc-queue.c
${SOURCE_DIR}/src/mongoc/mongoc-read-concern.c
${SOURCE_DIR}/src/mongoc/mongoc-read-prefs.c
${SOURCE_DIR}/src/mongoc/mongoc-rpc.c
${SOURCE_DIR}/src/mongoc/mongoc-server-description.c
${SOURCE_DIR}/src/mongoc/mongoc-server-stream.c
${SOURCE_DIR}/src/mongoc/mongoc-client-session.c
${SOURCE_DIR}/src/mongoc/mongoc-set.c
${SOURCE_DIR}/src/mongoc/mongoc-socket.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-buffered.c
${SOURCE_DIR}/src/mongoc/mongoc-stream.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-buffered.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-file.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-gridfs.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-socket.c
${SOURCE_DIR}/src/mongoc/mongoc-topology.c
${SOURCE_DIR}/src/mongoc/mongoc-topology-description.c
${SOURCE_DIR}/src/mongoc/mongoc-topology-description-apm.c
${SOURCE_DIR}/src/mongoc/mongoc-topology-scanner.c
${SOURCE_DIR}/src/mongoc/mongoc-uri.c
${SOURCE_DIR}/src/mongoc/mongoc-util.c
${SOURCE_DIR}/src/mongoc/mongoc-version-functions.c
${SOURCE_DIR}/src/mongoc/mongoc-write-command.c
${SOURCE_DIR}/src/mongoc/mongoc-write-command-legacy.c
${SOURCE_DIR}/src/mongoc/mongoc-write-concern.c
${PROJECT_SOURCE_DIR}/src/common/common-b64.c
)
set (HEADERS
${PROJECT_BINARY_DIR}/src/mongoc/mongoc-config.h
${PROJECT_BINARY_DIR}/src/mongoc/mongoc-version.h
${SOURCE_DIR}/src/mongoc/mongoc.h
${SOURCE_DIR}/src/mongoc/mongoc-apm.h
${SOURCE_DIR}/src/mongoc/mongoc-bulk-operation.h
${SOURCE_DIR}/src/mongoc/mongoc-change-stream.h
${SOURCE_DIR}/src/mongoc/mongoc-client.h
${SOURCE_DIR}/src/mongoc/mongoc-client-pool.h
${SOURCE_DIR}/src/mongoc/mongoc-collection.h
${SOURCE_DIR}/src/mongoc/mongoc-cursor.h
${SOURCE_DIR}/src/mongoc/mongoc-database.h
${SOURCE_DIR}/src/mongoc/mongoc-error.h
${SOURCE_DIR}/src/mongoc/mongoc-flags.h
${SOURCE_DIR}/src/mongoc/mongoc-find-and-modify.h
${SOURCE_DIR}/src/mongoc/mongoc-gridfs.h
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file.h
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-page.h
${SOURCE_DIR}/src/mongoc/mongoc-gridfs-file-list.h
${SOURCE_DIR}/src/mongoc/mongoc-handshake.h
${SOURCE_DIR}/src/mongoc/mongoc-host-list.h
${SOURCE_DIR}/src/mongoc/mongoc-init.h
${SOURCE_DIR}/src/mongoc/mongoc-index.h
${SOURCE_DIR}/src/mongoc/mongoc-iovec.h
${SOURCE_DIR}/src/mongoc/mongoc-log.h
${SOURCE_DIR}/src/mongoc/mongoc-macros.h
${SOURCE_DIR}/src/mongoc/mongoc-matcher.h
${SOURCE_DIR}/src/mongoc/mongoc-opcode.h
${SOURCE_DIR}/src/mongoc/mongoc-read-concern.h
${SOURCE_DIR}/src/mongoc/mongoc-read-prefs.h
${SOURCE_DIR}/src/mongoc/mongoc-server-description.h
${SOURCE_DIR}/src/mongoc/mongoc-client-session.h
${SOURCE_DIR}/src/mongoc/mongoc-socket.h
${SOURCE_DIR}/src/mongoc/mongoc-stream-tls-libressl.h
${SOURCE_DIR}/src/mongoc/mongoc-stream-tls-openssl.h
${SOURCE_DIR}/src/mongoc/mongoc-stream.h
${SOURCE_DIR}/src/mongoc/mongoc-stream-buffered.h
${SOURCE_DIR}/src/mongoc/mongoc-stream-file.h
${SOURCE_DIR}/src/mongoc/mongoc-stream-gridfs.h
${SOURCE_DIR}/src/mongoc/mongoc-stream-socket.h
${SOURCE_DIR}/src/mongoc/mongoc-topology-description.h
${SOURCE_DIR}/src/mongoc/mongoc-uri.h
${SOURCE_DIR}/src/mongoc/mongoc-version-functions.h
${SOURCE_DIR}/src/mongoc/mongoc-write-concern.h
${SOURCE_DIR}/src/mongoc/mongoc-rand.h
${SOURCE_DIR}/src/mongoc/mongoc-stream-tls.h
${SOURCE_DIR}/src/mongoc/mongoc-ssl.h
)
if (NOT ENABLE_SSL STREQUAL OFF)
set (SOURCES ${SOURCES}
${SOURCE_DIR}/src/mongoc/mongoc-crypto.c
${SOURCE_DIR}/src/mongoc/mongoc-scram.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-tls.c
${SOURCE_DIR}/src/mongoc/mongoc-ssl.c
)
if (OPENSSL_FOUND)
message (STATUS "Compiling against OpenSSL")
set (SOURCES ${SOURCES}
${SOURCE_DIR}/src/mongoc/mongoc-crypto-openssl.c
${SOURCE_DIR}/src/mongoc/mongoc-rand-openssl.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-tls-openssl.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-tls-openssl-bio.c
${SOURCE_DIR}/src/mongoc/mongoc-openssl.c
)
set (SSL_LIBRARIES ${OPENSSL_LIBRARIES})
include_directories (${OPENSSL_INCLUDE_DIR})
if (WIN32)
set (SSL_LIBRARIES ${SSL_LIBRARIES} crypt32.lib)
endif ()
elseif (SECURE_TRANSPORT)
message (STATUS "Compiling against Secure Transport")
set (SOURCES ${SOURCES}
${SOURCE_DIR}/src/mongoc/mongoc-crypto-common-crypto.c
${SOURCE_DIR}/src/mongoc/mongoc-rand-common-crypto.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-tls-secure-transport.c
${SOURCE_DIR}/src/mongoc/mongoc-secure-transport.c
)
set (SSL_LIBRARIES "-framework CoreFoundation -framework Security")
elseif (SECURE_CHANNEL)
message (STATUS "Compiling against Secure Channel")
set (SOURCES ${SOURCES}
${SOURCE_DIR}/src/mongoc/mongoc-crypto-cng.c
${SOURCE_DIR}/src/mongoc/mongoc-rand-cng.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-tls-secure-channel.c
${SOURCE_DIR}/src/mongoc/mongoc-secure-channel.c
)
set (SSL_LIBRARIES secur32.lib crypt32.lib Bcrypt.lib)
elseif (LIBRESSL)
message (STATUS "Compiling against LibreSSL")
set (SOURCES ${SOURCES}
${SOURCE_DIR}/src/mongoc/mongoc-crypto-openssl.c
${SOURCE_DIR}/src/mongoc/mongoc-rand-openssl.c
${SOURCE_DIR}/src/mongoc/mongoc-stream-tls-libressl.c
${SOURCE_DIR}/src/mongoc/mongoc-libressl.c
)
set (SSL_LIBRARIES -ltls -lcrypto)
endif ()
else ()
message (STATUS "SSL disabled")
endif () # ENABLE_SSL
if (MONGOC_ENABLE_SASL)
set (SOURCES ${SOURCES} ${SOURCE_DIR}/src/mongoc/mongoc-cluster-sasl.c)
set (SOURCES ${SOURCES} ${SOURCE_DIR}/src/mongoc/mongoc-sasl.c)
if (MONGOC_ENABLE_SASL_CYRUS)
message (STATUS "Compiling against Cyrus SASL")
set (SOURCES ${SOURCES} ${SOURCE_DIR}/src/mongoc/mongoc-cluster-cyrus.c)
set (SOURCES ${SOURCES} ${SOURCE_DIR}/src/mongoc/mongoc-cyrus.c)
include_directories (${SASL_INCLUDE_DIRS})
elseif (MONGOC_ENABLE_SASL_SSPI)
message (STATUS "Compiling against Windows SSPI")
set (SOURCES ${SOURCES} ${SOURCE_DIR}/src/mongoc/mongoc-cluster-sspi.c)
set (SOURCES ${SOURCES} ${SOURCE_DIR}/src/mongoc/mongoc-sspi.c)
set (SASL_LIBRARIES secur32.lib crypt32.lib Shlwapi.lib)
elseif (MONGOC_ENABLE_SASL_GSSAPI)
set (SOURCES ${SOURCES} ${SOURCE_DIR}/src/mongoc/mongoc-cluster-gssapi.c)
set (SOURCES ${SOURCES} ${SOURCE_DIR}/src/mongoc/mongoc-gssapi.c)
if (APPLE)
message (STATUS "Compiling against macOS GSS")
set (LIBRARIES ${LIBRARIES} -framework GSS)
else ()
message (FATAL_ERROR "gssapi missing krb5-config support in cmake")
endif ()
endif ()
else ()
message (STATUS "SASL disabled")
endif ()
set (THREADS_PREFER_PTHREAD_FLAG 1)
find_package (Threads REQUIRED)
if (CMAKE_USE_PTHREADS_INIT)
set (THREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
endif ()
set (LIBRARIES
${SASL_LIBRARIES} ${SSL_LIBRARIES} ${SHM_LIB} ${RESOLV_LIBRARIES}
${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES} Threads::Threads
)
if (WIN32)
set (LIBRARIES ${LIBRARIES} ws2_32)
endif ()
add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS})
set_target_properties (mongoc_shared PROPERTIES CMAKE_CXX_VISIBILITY_PRESET hidden)
target_link_libraries (mongoc_shared ${LIBRARIES} ${BSON_LIBRARIES})
target_include_directories (mongoc_shared BEFORE PUBLIC ${BSON_INCLUDE_DIRS} ${MONGOC_INTERNAL_INCLUDE_DIRS})
target_compile_definitions (mongoc_shared PUBLIC MONGOC_COMPILATION ${BSON_DEFINITIONS})
# CMake wants to make different symlinks than the Autotools, see
# https://cmake.org/pipermail/cmake/2007-September/016501.html
# This hack sets up standard symlink, libmongoc-1.0.so -> libmongoc-1.0.0.so
set_target_properties (mongoc_shared PROPERTIES VERSION 0 SOVERSION ${MONGOC_MAJOR_VERSION})
set_target_properties (mongoc_shared PROPERTIES OUTPUT_NAME "mongoc-${MONGOC_API_VERSION}" PREFIX "lib")
if (MONGOC_ENABLE_STATIC)
add_library (mongoc_static STATIC ${SOURCES} ${HEADERS})
target_link_libraries (mongoc_static ${LIBRARIES} ${BSON_STATIC_LIBRARIES})
target_include_directories (mongoc_static BEFORE PUBLIC ${BSON_STATIC_INCLUDE_DIRS} ${MONGOC_INTERNAL_INCLUDE_DIRS})
target_compile_definitions (mongoc_static PUBLIC MONGOC_COMPILATION MONGOC_STATIC ${BSON_STATIC_DEFINITIONS})
set_target_properties (mongoc_static PROPERTIES VERSION ${MONGOC_VERSION})
set_target_properties (mongoc_static PROPERTIES OUTPUT_NAME "mongoc-static-${MONGOC_API_VERSION}")
endif ()
add_executable (mongoc-stat ${SOURCE_DIR}/src/tools/mongoc-stat.c)
target_link_libraries (mongoc-stat mongoc_shared)
function (mongoc_add_test test use_shared)
if (ENABLE_TESTS)
add_executable (${test} ${ARGN})
if (NOT MSVC)
# We've tests that test our deprecated api. MSVC 2013 will complain about invalid flag
set_source_files_properties (${ARGN} PROPERTIES COMPILE_FLAGS -Wno-deprecated-declarations)
endif ()
target_include_directories (${test} PRIVATE ${SOURCE_DIR}/tests)
if (${use_shared})
target_link_libraries (${test} mongoc_shared)
target_include_directories (${test} PRIVATE ${BSON_INCLUDE_DIRS} ${MONGOC_INTERNAL_INCLUDE_DIRS})
else ()
target_compile_definitions (${test} PUBLIC "MONGOC_COMPILATION")
target_link_libraries (${test} mongoc_static)
target_include_directories (${test} PRIVATE ${BSON_STATIC_INCLUDE_DIRS} ${MONGOC_INTERNAL_INCLUDE_DIRS})
endif ()
target_link_libraries (${test} ${RESOLV_LIBRARIES})
if (WIN32)
target_link_libraries (${test} shlwapi)
else ()
target_link_libraries (${test})
endif ()
endif ()
endfunction ()
function (mongoc_add_example example use_shared)
if (ENABLE_EXAMPLES)
add_executable (${example} ${ARGN})
if (${use_shared})
target_link_libraries (${example} mongoc_shared)
else ()
target_link_libraries (${example} mongoc_static)
endif ()
if (WIN32)
target_link_libraries (${example} shlwapi)
endif ()
set (EXAMPLES ${EXAMPLES} ${example})
endif ()
endfunction ()
set (test-libmongoc-sources
${SOURCE_DIR}src/libbson/tests/corpus-test.c
${SOURCE_DIR}src/libbson/tests/corpus-test.h
${SOURCE_DIR}src/libbson/tests/test-atomic.c
${SOURCE_DIR}src/libbson/tests/test-bson.c
${SOURCE_DIR}src/libbson/tests/test-bson-corpus.c
${SOURCE_DIR}src/libbson/tests/test-bson-error.c
${SOURCE_DIR}src/libbson/tests/test-bson-version.c
${SOURCE_DIR}src/libbson/tests/test-endian.c
${SOURCE_DIR}src/libbson/tests/test-clock.c
${SOURCE_DIR}src/libbson/tests/test-decimal128.c
${SOURCE_DIR}src/libbson/tests/test-iso8601.c
${SOURCE_DIR}src/libbson/tests/test-iter.c
${SOURCE_DIR}src/libbson/tests/test-json.c
${SOURCE_DIR}src/libbson/tests/test-oid.c
${SOURCE_DIR}src/libbson/tests/test-reader.c
${SOURCE_DIR}src/libbson/tests/test-string.c
${SOURCE_DIR}src/libbson/tests/test-utf8.c
${SOURCE_DIR}src/libbson/tests/test-value.c
${SOURCE_DIR}src/libbson/tests/test-writer.c
${SOURCE_DIR}src/libbson/tests/test-bcon-basic.c
${SOURCE_DIR}src/libbson/tests/test-bcon-extract.c
${SOURCE_DIR}/tests/debug-stream.c
${SOURCE_DIR}/tests/json-test.c
${SOURCE_DIR}/tests/json-test-monitoring.c
${SOURCE_DIR}/tests/json-test-operations.c
${SOURCE_DIR}/tests/mock_server/future.c
${SOURCE_DIR}/tests/mock_server/future-functions.c
${SOURCE_DIR}/tests/mock_server/future-value.c
${SOURCE_DIR}/tests/mock_server/sync-queue.c
${SOURCE_DIR}/tests/mock_server/mock-rs.c
${SOURCE_DIR}/tests/mock_server/mock-server.c
${SOURCE_DIR}/tests/mock_server/request.c
${SOURCE_DIR}/tests/test-conveniences.c
${SOURCE_DIR}/tests/test-libmongoc.c
${SOURCE_DIR}/tests/test-happy-eyeballs.c
${SOURCE_DIR}/tests/test-mongoc-array.c
${SOURCE_DIR}/tests/test-mongoc-async.c
${SOURCE_DIR}/tests/test-mongoc-buffer.c
${SOURCE_DIR}/tests/test-mongoc-bulk.c
${SOURCE_DIR}/tests/test-mongoc-change-stream.c
${SOURCE_DIR}/tests/test-mongoc-client.c
${SOURCE_DIR}/tests/test-mongoc-client-pool.c
${SOURCE_DIR}/tests/test-mongoc-cluster.c
${SOURCE_DIR}/tests/test-mongoc-collection.c
${SOURCE_DIR}/tests/test-mongoc-collection-find.c
${SOURCE_DIR}/tests/test-mongoc-collection-find-with-opts.c
${SOURCE_DIR}/tests/test-mongoc-connection-uri.c
${SOURCE_DIR}/tests/test-mongoc-command-monitoring.c
${SOURCE_DIR}/tests/test-mongoc-counters.c
${SOURCE_DIR}/tests/test-mongoc-cursor.c
${SOURCE_DIR}/tests/test-mongoc-database.c
${SOURCE_DIR}/tests/test-mongoc-error.c
${SOURCE_DIR}/tests/test-mongoc-exhaust.c
${SOURCE_DIR}/tests/test-mongoc-find-and-modify.c
${SOURCE_DIR}/tests/test-mongoc-gridfs.c
${SOURCE_DIR}/tests/test-mongoc-gridfs-file-page.c
${SOURCE_DIR}/tests/test-mongoc-handshake.c
${SOURCE_DIR}/tests/test-mongoc-linux-distro-scanner.c
${SOURCE_DIR}/tests/test-mongoc-list.c
${SOURCE_DIR}/tests/test-mongoc-log.c
${SOURCE_DIR}/tests/test-mongoc-matcher.c
${SOURCE_DIR}/tests/test-mongoc-max-staleness.c
${SOURCE_DIR}/tests/test-mongoc-queue.c
${SOURCE_DIR}/tests/test-mongoc-read-concern.c
${SOURCE_DIR}/tests/test-mongoc-read-write-concern.c
${SOURCE_DIR}/tests/test-mongoc-read-prefs.c
${SOURCE_DIR}/tests/test-mongoc-retryable-writes.c
${SOURCE_DIR}/tests/test-mongoc-rpc.c
${SOURCE_DIR}/tests/test-mongoc-sample-commands.c
${SOURCE_DIR}/tests/test-mongoc-scram.c
${SOURCE_DIR}/tests/test-mongoc-sdam.c
${SOURCE_DIR}/tests/test-mongoc-sdam-monitoring.c
${SOURCE_DIR}/tests/test-mongoc-server-selection.c
${SOURCE_DIR}/tests/test-mongoc-server-selection-errors.c
${SOURCE_DIR}/tests/test-mongoc-client-session.c
${SOURCE_DIR}/tests/test-mongoc-set.c
${SOURCE_DIR}/tests/test-mongoc-socket.c
${SOURCE_DIR}/tests/test-mongoc-dns.c
${SOURCE_DIR}/tests/test-mongoc-stream.c
${SOURCE_DIR}/tests/test-mongoc-thread.c
${SOURCE_DIR}/tests/test-mongoc-topology.c
${SOURCE_DIR}/tests/test-mongoc-topology-description.c
${SOURCE_DIR}/tests/test-mongoc-topology-reconcile.c
${SOURCE_DIR}/tests/test-mongoc-topology-scanner.c
${SOURCE_DIR}/tests/test-mongoc-uri.c
${SOURCE_DIR}/tests/test-mongoc-version.c
${SOURCE_DIR}/tests/test-mongoc-usleep.c
${SOURCE_DIR}/tests/test-mongoc-util.c
${SOURCE_DIR}/tests/test-mongoc-write-commands.c
${SOURCE_DIR}/tests/test-mongoc-write-concern.c
${SOURCE_DIR}/tests/TestSuite.c
)
if (MONGOC_ENABLE_SSL)
set (test-libmongoc-sources ${test-libmongoc-sources}
${SOURCE_DIR}/tests/test-mongoc-x509.c
${SOURCE_DIR}/tests/ssl-test.c
${SOURCE_DIR}/tests/test-mongoc-stream-tls.c
${SOURCE_DIR}/tests/test-mongoc-stream-tls-error.c)
endif ()
if (MONGOC_ENABLE_SASL_CYRUS)
set (test-libmongoc-sources ${test-libmongoc-sources}
${SOURCE_DIR}/tests/test-mongoc-cyrus.c
)
endif ()
mongoc_add_test (test-libmongoc FALSE ${test-libmongoc-sources})
mongoc_add_test (test-mongoc-gssapi TRUE ${SOURCE_DIR}/tests/test-mongoc-gssapi.c)
if (ENABLE_TESTS)
enable_testing ()
add_test (NAME test-libmongoc
COMMAND test-libmongoc
WORKING_DIRECTORY ${SOURCE_DIR}
)
# "make test" doesn't compile tests, so we create "make check" which compiles
# and runs tests: https://gitlab.kitware.com/cmake/cmake/issues/8774
add_custom_target (check COMMAND ${CMAKE_CTEST_COMMAND} -V
DEPENDS test-libmongoc
)
endif ()
mongoc_add_example (example-gridfs TRUE ${SOURCE_DIR}/examples/example-gridfs.c)
mongoc_add_example (
example-command-monitoring TRUE
${SOURCE_DIR}/examples/example-command-monitoring.c)
mongoc_add_example (
example-sdam-monitoring TRUE
${SOURCE_DIR}/examples/example-sdam-monitoring.c)
mongoc_add_example (example-client TRUE ${SOURCE_DIR}/examples/example-client.c)
mongoc_add_example (example-command-with-opts TRUE ${SOURCE_DIR}/examples/example-command-with-opts.c)
mongoc_add_example (example-create-indexes TRUE ${SOURCE_DIR}/examples/example-create-indexes.c)
mongoc_add_example (example-scram TRUE ${SOURCE_DIR}/examples/example-scram.c)
mongoc_add_example (example-session TRUE ${SOURCE_DIR}/examples/example-session.c)
mongoc_add_example (mongoc-dump TRUE ${SOURCE_DIR}/examples/mongoc-dump.c)
mongoc_add_example (mongoc-ping TRUE ${SOURCE_DIR}/examples/mongoc-ping.c)
mongoc_add_example (mongoc-tail TRUE ${SOURCE_DIR}/examples/mongoc-tail.c)
mongoc_add_example (fam TRUE ${SOURCE_DIR}/examples/find_and_modify_with_opts/fam.c)
if (NOT WIN32 AND ENABLE_EXAMPLES)
mongoc_add_example (example-pool TRUE ${SOURCE_DIR}/examples/example-pool.c)