-
Notifications
You must be signed in to change notification settings - Fork 32
/
CMakeLists.txt
1361 lines (1127 loc) · 45.8 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
#
# Copyright (c) 2015-2019 Dubalu LLC
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
message(STATUS "CMake v${CMAKE_VERSION}")
cmake_minimum_required(VERSION 3.12)
project(xapiand C CXX)
cmake_policy(SET CMP0074 NEW)
# Make sure we can import out CMake functions
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set (PACKAGE_NAME "Xapiand")
set (PACKAGE_VERSION "0.40.0")
set (PACKAGE_URL "https://github.com/Kronuz/Xapiand")
set (PACKAGE_BUGREPORT "https://github.com/Kronuz/Xapiand/issues")
set (PACKAGE_TARNAME "${PROJECT_NAME}")
########################################################################
# Options
########################################################################
option(LINK_WHAT_YOU_USE "Enable link-what-you-use" OFF)
option(INCLUDE_WHAT_YOU_USE "Enable include-what-you-use" OFF)
option(CLANG_TIDY "Enable Clang Tidy" OFF)
option(CPPLINT "Enable CppLint" OFF)
option(BUILD_TESTS "Build all tests" OFF)
option(BUILD_BENCHMARKS "Build all benchmarks" OFF)
option(DEBUGINFO_EXTERNALIZE "Externalize debug information" OFF)
option(CLUSTERING "Enable remote clustering" ON)
option(DATABASE_WAL "Enable database write ahead log (WAL)" ON)
option(DATA_STORAGE "Enable data storage" ON)
option(TRACEBACKS "Enable tracebacks (on by default in Debug)" OFF)
option(ASSERTS "Enable asserts (on by default in Debug)" OFF)
option(TRACKED_MEM "Enable tracked memory allocator" OFF)
option(CHECK_IO_FDES "Check file descriptors" OFF)
option(CHAISCRIPT "Enable ChaiScript engine" ON)
option(UUID_ENCODED "Allow encoded (base59) as UUID encoding" ON)
option(UUID_GUID "Allow GUID as UUID encoding" OFF)
option(UUID_URN "Allow URN as UUID encoding" OFF)
option(RANDOM_ERRORS "Allow adding randomized errors" OFF)
option(CHECK_SIZES "Print the objects sizes" OFF)
option(LTO "Link Time Optimizations" ON)
foreach (opt CLUSTERING DATABASE_WAL DATA_STORAGE TRACEBACKS ASSERTS TRACKED_MEM CHECK_IO_FDES CHAISCRIPT UUID_ENCODED UUID_GUID UUID_URN RANDOM_ERRORS CHECK_SIZES LTO)
if (${opt})
set ("XAPIAND_${opt}" 1)
message(STATUS "Option ${opt} - on")
else ()
set ("XAPIAND_${opt}" 0)
endif ()
endforeach ()
if (APPLE)
set (CMAKE_FIND_FRAMEWORK "LAST")
set (HOMEBREW_OPT_DIR "/usr/local/opt")
message(STATUS "HOMEBREW_OPT_DIR is ${HOMEBREW_OPT_DIR}")
endif ()
########################################################################
# Check CMAKE_BUILD_TYPE: Debug Release RelWithDebInfo MinSizeRel
########################################################################
# Default value for CMAKE_BUILD_TYPE.
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release)
endif ()
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_CMAKE_BUILD_TYPE)
# Setup CMAKE_CXX_FLAGS flags.
set (CMAKE_CXX_FLAGS_DEBUG "-g -DDEBUG -fstack-protector-strong")
if (XAPIAND_ASSERTS)
set (CMAKE_CXX_FLAGS_RELEASE "-O3")
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os")
else ()
set (CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG")
set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
endif ()
########################################################################
# CMake Includes
########################################################################
include (AC_HEADER_STDC)
include (AddCXXCompilerFlag)
include (CheckSymbolExists)
include (CheckCXXCompilerFlag)
include (CheckCXXSourceCompiles)
include (CheckCXXSourceRuns)
include (CheckCXXSymbolExists)
include (CheckFunctionExists)
include (CheckIncludeFileCXX)
include (CheckIncludeFiles)
include (CheckLibraryExists)
include (CheckTypeSize)
include (CMakePushCheckState)
include (GetGitVersion)
include (GNUInstallDirs)
include (RemoveDuplicateSubstrings)
########################################################################
# _____ _
# |_ _|__ ___ | |___
# | |/ _ \ / _ \| / __|
# | | (_) | (_) | \__ \
# |_|\___/ \___/|_|___/
#
########################################################################
# -DCMAKE_CMAKE_LINK_WHAT_YOU_USE:BOOL=ON
if (LINK_WHAT_YOU_USE)
message(STATUS "Enabling link-what-you-use - ok")
set (CMAKE_LINK_WHAT_YOU_USE ON)
endif (LINK_WHAT_YOU_USE)
# Enable Google's Include What You Use
# ------------------------------------
# -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE:STRING="include-what-you-use;-Xiwyu;--mapping_file=../iwyu.imp"
if (INCLUDE_WHAT_YOU_USE)
find_program(INCLUDE_WHAT_YOU_USE_PATH NAMES include-what-you-use iwyu)
if (INCLUDE_WHAT_YOU_USE_PATH)
message(STATUS "Looking for include-what-you-use - found")
set (INCLUDE_WHAT_YOU_USE_OPTS
${INCLUDE_WHAT_YOU_USE_PATH}
"-Xiwyu"
"--mapping_file=${PROJECT_SOURCE_DIR}/iwyu.imp"
)
set (CMAKE_C_INCLUDE_WHAT_YOU_USE "${INCLUDE_WHAT_YOU_USE_OPTS}")
set (CMAKE_CXX_INCLUDE_WHAT_YOU_USE "${INCLUDE_WHAT_YOU_USE_OPTS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ferror-limit=0")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ferror-limit=0")
else ()
message(STATUS "Looking for include-what-you-use - not found")
endif ()
endif (INCLUDE_WHAT_YOU_USE)
# Enable Clang Tidy
# -----------------
# -DCMAKE_CXX_CLANG_TIDY:STRING="clang-tidy;-checks=-*,readability-*"
if (CLANG_TIDY)
find_program(CLANG_TIDY_PATH NAMES clang-tidy)
if (CLANG_TIDY_PATH)
message(STATUS "Looking for clang-tidy - found")
set (CLANG_TIDY_OPTS
${CLANG_TIDY_PATH}
# "-fix"
"-checks=-*,readability-*,modernize-*"
)
set (CMAKE_C_CLANG_TIDY "${CLANG_TIDY_OPTS}")
set (CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_OPTS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ferror-limit=0")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ferror-limit=0")
else ()
message(STATUS "Looking for clang-tidy - not found")
endif ()
endif (CLANG_TIDY)
# Enable CppLint
# --------------
# -DCMAKE_CXX_CPPLINT:STRING="cpplint;--linelength=79"
if (CPPLINT)
find_program(CPPLINT_PATH NAMES cpplint)
if (CPPLINT_PATH)
message(STATUS "Looking for CppLint - found")
set (CPPLINT_OPTS
${CPPLINT_PATH}
"--linelength=79"
)
set (CMAKE_C_CPPLINT "${CPPLINT_OPTS}")
set (CMAKE_CXX_CPPLINT "${CPPLINT_OPTS}")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ferror-limit=0")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ferror-limit=0")
else ()
message(STATUS "Looking for CppLint - not found")
endif ()
endif (CPPLINT)
########################################################################
# _ _ _ _
# | | (_) |__ _ __ __ _ _ __(_) ___ ___
# | | | | '_ \| '__/ _` | '__| |/ _ \/ __|
# | |___| | |_) | | | (_| | | | | __/\__ \
# |_____|_|_.__/|_| \__,_|_| |_|\___||___/
#
########################################################################
########################################################################
# Use libc++ when available
########################################################################
check_cxx_compiler_flag("-stdlib=libc++" HAVE_FLAG_STDLIB_LIBCPP)
if (HAVE_FLAG_STDLIB_LIBCPP)
add_cxx_compiler_flag("-stdlib=libc++")
find_library(LIBCPP_LIBRARIES c++)
if (LIBCPP_LIBRARIES)
set (HAVE_LIBCPP 1)
find_library(LIBCPPABI_LIBRARIES c++abi)
if (LIBCPPABI_LIBRARIES)
set (HAVE_LIBCPPABI 1)
set (LIBCPP_INCLUDE_DIRS ${LIBCPP_INCLUDE_DIRS} ${LIBCPPABI_INCLUDE_DIRS})
set (LIBCPP_LIBRARIES ${LIBCPP_LIBRARIES} ${LIBCPPABI_LIBRARIES})
else ()
set (HAVE_LIBCPPABI 0)
set (LIBCPP_LIBRARIES "")
endif ()
else ()
set (HAVE_LIBCPP 0)
set (LIBCPP_LIBRARIES "")
endif ()
endif ()
########################################################################
# ZLIB Library
########################################################################
find_package(ZLIB)
if (ZLIB_FOUND)
set (HAVE_ZLIB 1)
else ()
set (HAVE_ZLIB 0)
endif ()
########################################################################
# Exec Info Library
########################################################################
find_library(EXECINFO_LIBRARIES execinfo)
if (EXECINFO_LIBRARIES)
set (HAVE_EXECINFO 1)
else ()
set (HAVE_EXECINFO 0)
set (EXECINFO_LIBRARIES "")
endif ()
########################################################################
# Real Time Library
########################################################################
find_library(RT_LIBRARIES rt)
if (RT_LIBRARIES)
set (HAVE_RT 1)
else ()
set (HAVE_RT 0)
set (RT_LIBRARIES "")
endif ()
########################################################################
# Math Library
########################################################################
find_library(M_LIBRARIES m)
if (M_LIBRARIES)
set (HAVE_M 1)
else ()
set (HAVE_M 0)
set (M_LIBRARIES "")
endif ()
########################################################################
# Dynamic Linking Library (for dladdr)
########################################################################
find_library(DL_LIBRARIES dl)
if (DL_LIBRARIES)
set (HAVE_DL 1)
else ()
set (HAVE_DL 0)
set (DL_LIBRARIES "")
endif ()
########################################################################
# Threads Library
########################################################################
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package(Threads REQUIRED)
if (CMAKE_USE_PTHREADS_INIT)
set (HAVE_PTHREADS 1)
else ()
set (HAVE_PTHREADS 0)
endif ()
########################################################################
# Capabilities Library
########################################################################
find_library(CAP_LIBRARIES cap)
if (CAP_LIBRARIES)
set (HAVE_CAP 1)
else ()
set (HAVE_CAP 0)
set (CAP_LIBRARIES "")
endif ()
########################################################################
# UUID Library
########################################################################
find_package(UUID REQUIRED)
########################################################################
# ICU Library
########################################################################
# ICU's UTF-8 word boundary code was broken before 54.1.
if (APPLE AND NOT ICU_ROOT)
set (ICU_ROOT "${HOMEBREW_OPT_DIR}/icu4c")
endif ()
find_package(ICU 54.1 COMPONENTS uc)
if (ICU_FOUND)
set (USE_ICU 1)
else ()
set (USE_ICU 0)
endif ()
########################################################################
# _____ _
# |_ _|_ _ _ __ __ _ ___| |_ ___
# | |/ _` | '__/ _` |/ _ \ __/ __|
# | | (_| | | | (_| | __/ |_\__ \
# |_|\__,_|_| \__, |\___|\__|___/
# |___/
########################################################################
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set (FIXTURES_PATH "${PROJECT_SOURCE_DIR}/oldtests")
set (XAPIAND_DATA_PATH "${CMAKE_INSTALL_FULL_DATAROOTDIR}/xapiand")
include_directories(
"${PROJECT_SOURCE_DIR}/src"
"${PROJECT_BINARY_DIR}/src"
${LIBCPP_INCLUDE_DIRS}
)
link_libraries(
${CMAKE_THREAD_LIBS_INIT}
${LIBCPP_LIBRARIES}
)
########################################################################
# Xapian library target
########################################################################
# Xapian Exceptions
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src/xapian")
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/src/xapian/error.h" "${PROJECT_BINARY_DIR}/src/xapian/errordispatch.h"
COMMAND perl
-w
-I "${PROJECT_SOURCE_DIR}/src/xapian"
"${PROJECT_SOURCE_DIR}/src/xapian/generate-exceptions"
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/src"
DEPENDS
"${PROJECT_SOURCE_DIR}/src/xapian/generate-exceptions"
"${PROJECT_SOURCE_DIR}/src/xapian/exception_data.pm"
)
list(APPEND XAPIAN_H_LIST "${PROJECT_BINARY_DIR}/src/xapian/error.h" "${PROJECT_BINARY_DIR}/src/xapian/errordispatch.h")
# Snowball
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src/xapian/languages")
file(GLOB SNOWBALL_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/xapian/languages/compiler/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/languages/compiler/*.h*"
)
add_executable(snowball EXCLUDE_FROM_ALL ${SNOWBALL_SRC_LIST})
set_target_properties(snowball PROPERTIES COMPILE_FLAGS "-DDISABLE_CSHARP -DDISABLE_GO -DDISABLE_JAVA -DDISABLE_JS -DDISABLE_PASCAL -DDISABLE_PYTHON -DDISABLE_RUST")
file(GLOB LANGUAGES_SBL_LIST
"${PROJECT_SOURCE_DIR}/src/xapian/languages/*.sbl"
)
foreach (language_sbl ${LANGUAGES_SBL_LIST})
get_filename_component(Language ${language_sbl} NAME_WE)
string(SUBSTRING ${Language} 0 1 first_letter)
string(TOUPPER ${first_letter} first_letter)
string(REGEX REPLACE "^.(.*)" "${first_letter}\\1" Language "${Language}")
string(REGEX REPLACE "^${PROJECT_SOURCE_DIR}/(.*).sbl" "${PROJECT_BINARY_DIR}/\\1" language "${language_sbl}")
# Run snowball command
add_custom_command(
OUTPUT "${language}.cc" "${language}.h"
COMMAND snowball ${language_sbl} -o ${language} -c++ -u -n InternalStem${Language} -p SnowballStemImplementation
DEPENDS snowball ${language_sbl}
)
list(APPEND LANGUAGES_SRC_LIST "${language}.cc" "${language}.h")
endforeach ()
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/src/xapian/languages/allsnowballheaders.h" "${PROJECT_BINARY_DIR}/src/xapian/languages/sbl-dispatch.h"
COMMAND perl
-I "${PROJECT_SOURCE_DIR}/src/xapian/common"
-I "${PROJECT_SOURCE_DIR}/src/xapian/languages"
"${PROJECT_SOURCE_DIR}/src/xapian/languages/collate-sbl"
"''"
${LANGUAGES_SBL_LIST}
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/src/xapian"
DEPENDS ${LANGUAGES_SBL_LIST}
)
list(APPEND LANGUAGES_SRC_LIST "${PROJECT_BINARY_DIR}/src/xapian/languages/allsnowballheaders.h" "${PROJECT_BINARY_DIR}/src/xapian/languages/sbl-dispatch.h")
# Unicode
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src/xapian/unicode")
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/src/xapian/unicode/unicode-data.cc"
COMMAND tclsh
"${PROJECT_SOURCE_DIR}/src/xapian/unicode/uniParse.tcl"
"${PROJECT_SOURCE_DIR}/src/xapian/unicode/UnicodeData.txt" 11.0.0
"${PROJECT_BINARY_DIR}/src/xapian/unicode/unicode-data.cc"
DEPENDS
"${PROJECT_SOURCE_DIR}/src/xapian/unicode/uniParse.tcl"
"${PROJECT_SOURCE_DIR}/src/xapian/unicode/UnicodeData.txt"
)
list(APPEND UNICODE_SRC_LIST "${PROJECT_BINARY_DIR}/src/xapian/unicode/unicode-data.cc")
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/src/xapian/unicode/c_istab.h"
COMMAND perl
"${PROJECT_SOURCE_DIR}/src/xapian/unicode/gen_c_istab"
"${PROJECT_BINARY_DIR}/src/xapian/unicode/c_istab.h"
DEPENDS
"${PROJECT_SOURCE_DIR}/src/xapian/unicode/gen_c_istab"
)
list(APPEND UNICODE_SRC_LIST "${PROJECT_BINARY_DIR}/src/xapian/unicode/c_istab.h")
# QueryParser
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/src/xapian/queryparser")
add_executable(lemon EXCLUDE_FROM_ALL "${PROJECT_SOURCE_DIR}/src/xapian/queryparser/lemon.c")
add_custom_command(
OUTPUT "${PROJECT_BINARY_DIR}/src/xapian/queryparser/queryparser_internal.cc" "${PROJECT_BINARY_DIR}/src/xapian/queryparser/queryparser_token.h"
COMMAND lemon -q
-o"${PROJECT_BINARY_DIR}/src/xapian/queryparser/queryparser_internal.cc"
-h"${PROJECT_BINARY_DIR}/src/xapian/queryparser/queryparser_token.h"
"${PROJECT_SOURCE_DIR}/src/xapian/queryparser/queryparser.lemony"
DEPENDS lemon "${PROJECT_SOURCE_DIR}/src/xapian/queryparser/queryparser.lemony"
)
list(APPEND QUERYPARSER_SRC_LIST "${PROJECT_BINARY_DIR}/src/xapian/queryparser/queryparser_internal.cc" "${PROJECT_BINARY_DIR}/src/xapian/queryparser/queryparser_token.h")
# Xapian
file(GLOB XAPIAN_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/xapian/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/weight/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/weight/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/cluster/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/cluster/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/queryparser/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/queryparser/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/expand/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/expand/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/net/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/net/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/unicode/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/unicode/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/backends/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/backends/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/backends/multi/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/backends/multi/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/backends/glass/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/backends/glass/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/backends/honey/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/backends/honey/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/backends/inmemory/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/backends/inmemory/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/backends/remote/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/backends/remote/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/languages/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/languages/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/matcher/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/matcher/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/common/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/common/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/diversify/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/diversify/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/api/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/api/*.h*"
"${PROJECT_SOURCE_DIR}/src/xapian/geospatial/*.c*" "${PROJECT_SOURCE_DIR}/src/xapian/geospatial/*.h*"
)
list(REMOVE_ITEM XAPIAN_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/xapian/version_h.cc"
"${PROJECT_SOURCE_DIR}/src/xapian/queryparser/lemon.c"
)
list(APPEND XAPIAN_SRC_LIST ${XAPIAN_H_LIST})
list(APPEND XAPIAN_SRC_LIST ${LANGUAGES_SRC_LIST})
list(APPEND XAPIAN_SRC_LIST ${UNICODE_SRC_LIST})
list(APPEND XAPIAN_SRC_LIST ${QUERYPARSER_SRC_LIST})
add_library(XAPIAN_OBJ OBJECT ${XAPIAN_SRC_LIST})
target_include_directories(XAPIAN_OBJ PUBLIC
${ZLIB_INCLUDE_DIRS}
${UUID_INCLUDE_DIRS}
${ICU_INCLUDE_DIRS}
)
target_link_libraries(XAPIAN_OBJ PUBLIC
${ZLIB_LIBRARIES}
${UUID_LIBRARIES}
${ICU_LIBRARIES}
)
########################################################################
# Boolean parser library target
########################################################################
file(GLOB BOOLEAN_PARSER_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/booleanParser/*.c*" "${PROJECT_SOURCE_DIR}/src/booleanParser/*.h*"
)
list(APPEND BOOLEAN_PARSER_SRC_LIST ${XAPIAN_H_LIST})
add_library(BOOLEAN_PARSER_OBJ OBJECT ${BOOLEAN_PARSER_SRC_LIST})
########################################################################
# Libev library target
########################################################################
file(GLOB LIBEV_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/ev/*.c*" "${PROJECT_SOURCE_DIR}/src/ev/*.h*"
)
list(REMOVE_ITEM LIBEV_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/ev/ev_epoll.c"
"${PROJECT_SOURCE_DIR}/src/ev/ev_kqueue.c"
"${PROJECT_SOURCE_DIR}/src/ev/ev_poll.c"
"${PROJECT_SOURCE_DIR}/src/ev/ev_port.c"
"${PROJECT_SOURCE_DIR}/src/ev/ev_select.c"
"${PROJECT_SOURCE_DIR}/src/ev/ev_win32.c"
)
list(APPEND LIBEV_SRC_LIST ${XAPIAN_H_LIST})
add_library(LIBEV_OBJ OBJECT ${LIBEV_SRC_LIST})
########################################################################
# LZ4 library target
########################################################################
file(GLOB LZ4_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/lz4/*.c*" "${PROJECT_SOURCE_DIR}/src/lz4/*.h*"
)
list(APPEND LZ4_SRC_LIST ${XAPIAN_H_LIST})
add_library(LZ4_OBJ OBJECT ${LZ4_SRC_LIST})
########################################################################
# Condensed UUID library target
########################################################################
file(GLOB CUUID_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/cuuid/*.c*" "${PROJECT_SOURCE_DIR}/src/cuuid/*.h*"
)
list(APPEND CUUID_SRC_LIST ${XAPIAN_H_LIST})
add_library(CUUID_OBJ OBJECT ${CUUID_SRC_LIST})
target_include_directories(CUUID_OBJ PUBLIC
${UUID_INCLUDE_DIRS}
)
target_link_libraries(CUUID_OBJ PUBLIC
${UUID_LIBRARIES}
)
########################################################################
# Prometheus library target
########################################################################
file(GLOB PROMETHEUS_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/prometheus/*.c*" "${PROJECT_SOURCE_DIR}/src/prometheus/*.h*"
)
list(APPEND PROMETHEUS_SRC_LIST ${XAPIAN_H_LIST})
add_library(PROMETHEUS_OBJ OBJECT ${PROMETHEUS_SRC_LIST})
########################################################################
# yaml library target
########################################################################
file(GLOB YAML_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/yaml/*.c*" "${PROJECT_SOURCE_DIR}/src/yaml/*.h*"
"${PROJECT_SOURCE_DIR}/src/y2j/*.c*" "${PROJECT_SOURCE_DIR}/src/y2j/*.h*"
)
add_library(YAML_OBJ OBJECT ${YAML_SRC_LIST})
########################################################################
# Xapiand package configuration target
########################################################################
file(GLOB FMT_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/fmt/*.c*" "${PROJECT_SOURCE_DIR}/src/fmt/*.h*"
)
add_library(FMT_OBJ OBJECT ${FMT_SRC_LIST})
########################################################################
# Xapiand package configuration target
########################################################################
list(APPEND XAPIAND_PACKAGE_SRC_LIST "${PROJECT_SOURCE_DIR}/src/package.cc")
list(APPEND XAPIAND_PACKAGE_SRC_LIST ${XAPIAN_H_LIST})
add_library(XAPIAND_PACKAGE_OBJ OBJECT ${XAPIAND_PACKAGE_SRC_LIST})
########################################################################
# Xapiand library target
########################################################################
file(GLOB XAPIAND_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/*.c*" "${PROJECT_SOURCE_DIR}/src/*.h*"
"${PROJECT_SOURCE_DIR}/src/chaipp/*.c*" "${PROJECT_SOURCE_DIR}/src/chaipp/*.h*"
"${PROJECT_SOURCE_DIR}/src/database/*.c*" "${PROJECT_SOURCE_DIR}/src/database/*.h*"
"${PROJECT_SOURCE_DIR}/src/aggregations/*.c*" "${PROJECT_SOURCE_DIR}/src/aggregations/*.h*"
"${PROJECT_SOURCE_DIR}/src/geospatial/*.c*" "${PROJECT_SOURCE_DIR}/src/geo/*.h*"
"${PROJECT_SOURCE_DIR}/src/hash/*.c*" "${PROJECT_SOURCE_DIR}/src/hash/*.h*"
"${PROJECT_SOURCE_DIR}/src/multivalue/*.c*" "${PROJECT_SOURCE_DIR}/src/multivalue/*.h*"
"${PROJECT_SOURCE_DIR}/src/server/*.c*" "${PROJECT_SOURCE_DIR}/src/server/*.h*"
"${PROJECT_SOURCE_DIR}/src/utils/*.c*" "${PROJECT_SOURCE_DIR}/src/utils/*.h*"
"${PROJECT_SOURCE_DIR}/src/xchange/*.c*" "${PROJECT_SOURCE_DIR}/src/xchange/*.h*"
)
list(REMOVE_ITEM XAPIAND_SRC_LIST
"${PROJECT_SOURCE_DIR}/src/main.cc"
"${PROJECT_SOURCE_DIR}/src/package.cc"
)
list(APPEND XAPIAND_SRC_LIST ${XAPIAN_H_LIST})
add_library(XAPIAND_OBJ OBJECT ${XAPIAND_SRC_LIST})
target_include_directories(XAPIAND_OBJ PUBLIC
${ZLIB_INCLUDE_DIRS}
${UUID_INCLUDE_DIRS}
${ICU_INCLUDE_DIRS}
)
target_link_libraries(XAPIAND_OBJ PUBLIC
${ZLIB_LIBRARIES}
${UUID_LIBRARIES}
${M_LIBRARIES}
${DL_LIBRARIES}
${CAP_LIBRARIES}
${RT_LIBRARIES}
${EXECINFO_LIBRARIES}
)
########################################################################
# Primary target
########################################################################
add_executable(${PROJECT_NAME} "${PROJECT_SOURCE_DIR}/src/main.cc")
target_link_libraries(${PROJECT_NAME}
XAPIAND_PACKAGE_OBJ
XAPIAND_OBJ
XAPIAN_OBJ
BOOLEAN_PARSER_OBJ
LIBEV_OBJ
LZ4_OBJ
CUUID_OBJ
PROMETHEUS_OBJ
YAML_OBJ
FMT_OBJ
)
########################################################################
# Copy stopwords from source to build directory
########################################################################
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/stopwords/ ${CMAKE_INSTALL_DATAROOTDIR}/xapiand/stopwords)
########################################################################
# Install target
########################################################################
# Copy stopwords during the installation
install(DIRECTORY ${CMAKE_SOURCE_DIR}/stopwords/ DESTINATION ${XAPIAND_DATA_PATH}/stopwords)
# Copy mime types file
install(FILES ${CMAKE_SOURCE_DIR}/mime.types DESTINATION ${XAPIAND_DATA_PATH})
# Manual page generation
install(FILES ${CMAKE_SOURCE_DIR}/man/xapiand.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8 COMPONENT doc)
# Install binary
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
########################################################################
# Uninstall target
########################################################################
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${PROJECT_BINARY_DIR}/cmake_uninstall.cmake"
@ONLY)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${PROJECT_BINARY_DIR}/cmake_uninstall.cmake)
########################################################################
# _____ _
# | ___| | __ _ __ _ ___
# | |_ | |/ _` |/ _` / __|
# | _| | | (_| | (_| \__ \
# |_| |_|\__,_|\__, |___/
# |___/
########################################################################
########################################################################
# Version
########################################################################
# Read the git tags to determine the project version
get_git_revision(GIT_REVISION)
if (GIT_REVISION)
set (PACKAGE_REVISION "${GIT_REVISION}")
else ()
get_date_revision(DATE_REVISION)
if (DATE_REVISION)
set (PACKAGE_REVISION "${DATE_REVISION}")
endif ()
endif ()
get_git_hash(GIT_HASH)
if (GIT_HASH)
set (PACKAGE_HASH "${GIT_HASH}")
endif ()
get_git_version(GIT_VERSION)
if (GIT_VERSION)
set (PACKAGE_VERSION "${GIT_VERSION}")
endif ()
########################################################################
# Compiler Flags
########################################################################
# Add compiler flags.
add_required_cxx_compiler_flag("-std=c++17")
add_cxx_compiler_flag("-fno-common")
if (XAPIAND_LTO)
add_cxx_compiler_flag("-flto" RELEASE)
endif ()
# add_cxx_compiler_flag("-fno-gnu-keywords")
add_cxx_compiler_flag("-fdiagnostics-color=always")
if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
# ____ _
# / ___| | __ _ _ __ __ _
# | | | |/ _` | '_ \ / _` |
# | |___| | (_| | | | | (_| |
# \____|_|\__,_|_| |_|\__, |
# |___/
message(STATUS "Compiler: Clang (${CMAKE_CXX_COMPILER_ID})")
add_cxx_compiler_flag("-Qunused-arguments")
add_cxx_compiler_flag("-pedantic")
add_cxx_compiler_flag("-pedantic-errors")
# Treat warnings as errors.
# add_cxx_compiler_flag("-Werror" RELEASE)
# add_cxx_compiler_flag("-Werror" MINSIZEREL)
# Enable warnings.
add_cxx_compiler_flag("-Wall")
add_cxx_compiler_flag("-Wextra")
add_cxx_compiler_flag("-Wshadow")
add_cxx_compiler_flag("-Wpointer-arith")
add_cxx_compiler_flag("-Wformat-security")
add_cxx_compiler_flag("-Wredundant-decls")
add_cxx_compiler_flag("-Woverloaded-virtual")
add_cxx_compiler_flag("-Wmissing-declarations")
add_cxx_compiler_flag("-Wimplicit-fallthrough")
add_cxx_compiler_flag("-Winit-self")
add_cxx_compiler_flag("-Wcast-align")
add_cxx_compiler_flag("-Wstrict-aliasing")
add_cxx_compiler_flag("-Wsuggest-final-types")
# add_cxx_compiler_flag("-Wundef") ##
# add_cxx_compiler_flag("-Wcast-qual") ##
# add_cxx_compiler_flag("-Wshorten-64-to-32") ##
# add_cxx_compiler_flag("-Wfloat-equal") ##
# Disable certain warnings.
add_cxx_compiler_flag("-Wno-unknown-pragmas")
add_cxx_compiler_flag("-Wno-variadic-macros")
add_cxx_compiler_flag("-Wno-gnu-anonymous-struct")
add_cxx_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
# ____ ____ ____
# / ___|/ ___/ ___|
# | | _| | | |
# | |_| | |__| |___
# \____|\____\____|
#
message(STATUS "Compiler: GCC (${CMAKE_CXX_COMPILER_ID})")
# Disable certain warnings.
add_cxx_compiler_flag("-Wno-attributes")
add_cxx_compiler_flag("-Wno-subobject-linkage")
else ()
message(STATUS "Compiler: ${CMAKE_CXX_COMPILER_ID}")
endif ()
########################################################################
# Xapiand Flags
########################################################################
check_include_files("pthread_np.h" HAVE_PTHREAD_NP_H)
check_include_files("fcntl.h" HAVE_FCNTL_H)
check_include_files("limits.h" HAVE_LIMITS_H)
check_include_files("netinet/in.h" HAVE_NETINET_IN_H)
check_include_files("sys/socket.h" HAVE_SYS_SOCKET_H)
check_include_files("sys/time.h" HAVE_SYS_TIME_H)
check_include_files("unistd.h" HAVE_UNISTD_H)
check_include_files("execinfo.h" HAVE_EXECINFO_H)
check_include_files("libunwind.h" HAVE_LIBUNWIND_H)
check_include_files("sys/sysctl.h" HAVE_SYS_SYSCTL_H)
check_include_files("sys/capability.h" HAVE_SYS_CAPABILITY_H)
check_include_files("sys/prctl.h" HAVE_SYS_PRCTL_H)
check_include_file_cxx("sstream" HAVE_SSTREAM)
check_include_file_cxx("strstream" HAVE_STRSTREAM)
check_function_exists("fallocate" HAVE_FALLOCATE)
check_function_exists("fsync" HAVE_FSYNC)
check_function_exists("getcwd" HAVE_GETCWD)
check_function_exists("gettimeofday" HAVE_GETTIMEOFDAY)
check_function_exists("memcpy" HAVE_MEMCPY)
check_function_exists("posix_fadvise" HAVE_POSIX_FADVISE)
check_function_exists("posix_fallocate" HAVE_POSIX_FALLOCATE)
check_function_exists("pread" HAVE_PREAD)
check_function_exists("pwrite" HAVE_PWRITE)
check_function_exists("socket" HAVE_SOCKET)
check_function_exists("setresuid" HAVE_SETRESUID)
check_library_exists(pthread "pthread_getname_np" "" HAVE_PTHREAD_GETNAME_NP)
check_library_exists(pthread "pthread_get_name_np" "" HAVE_PTHREAD_GET_NAME_NP)
check_library_exists(pthread "pthread_setname_np" "" HAVE_PTHREAD_SETNAME_NP)
check_library_exists(pthread "pthread_set_name_np" "" HAVE_PTHREAD_SET_NAME_NP)
check_library_exists(pthread "pthread_attr_setaffinity_np" "" HAVE_PTHREAD_ATTR_SETAFFINITY_NP)
check_cxx_source_compiles("int main() { __builtin_expect(0, 0); return 0; }" HAVE_DECL___BUILTIN_EXPECT)
if (${CMAKE_SYSTEM_NAME} MATCHES Darwin)
# FIXME: See if we have fdatasync, and what libraries are needed for it.
# We need to actually check for a declaration as OS X has a dummy
# implementation in the library which is not prototyped in any header.
set (HAVE_FDATASYNC 0)
else ()
check_function_exists("fdatasync" HAVE_FDATASYNC)
endif ()
########################################################################
# libev Flags
########################################################################
check_include_files("sys/epoll.h" HAVE_SYS_EPOLL_H)
check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
check_include_files("sys/eventfd.h" HAVE_SYS_EVENTFD_H)
check_include_files("sys/inotify.h" HAVE_SYS_INOTIFY_H)
check_include_files("sys/select.h" HAVE_SYS_SELECT_H)
check_include_files("sys/signalfd.h" HAVE_SYS_SIGNALFD_H)
check_include_files("port.h" HAVE_PORT_H)
check_include_files("poll.h" HAVE_POLL_H)
check_function_exists("inotify_init" HAVE_INOTIFY_INIT)
check_function_exists("epoll_ctl" HAVE_EPOLL_CTL)
check_function_exists("kqueue" HAVE_KQUEUE)
check_function_exists("select" HAVE_SELECT)
check_function_exists("eventfd" HAVE_EVENTFD)
check_function_exists("signalfd" HAVE_SIGNALFD)
check_function_exists("port_create" HAVE_PORT_CREATE)
check_function_exists("poll" HAVE_POLL)
check_function_exists("clock_gettime" HAVE_CLOCK_GETTIME)
check_function_exists("nanosleep" HAVE_NANOSLEEP)
# Tweaks
set (HAVE_CLOCK_SYSCALL ${HAVE_CLOCK_GETTIME})
########################################################################
# xapian Flags
########################################################################
check_symbol_exists(exp10 "math.h" HAVE_DECL_EXP10)
check_symbol_exists(log2 "math.h" HAVE_DECL_LOG2)
check_symbol_exists(__exp10 "math.h" HAVE_DECL___EXP10)
check_cxx_symbol_exists(strerror_r "string.h" HAVE_DECL_STRERROR_R)
check_cxx_symbol_exists(_byteswap_uint64 "stdlib.h" HAVE_DECL__BYTESWAP_UINT64)
check_cxx_symbol_exists(_byteswap_ulong "stdlib.h" HAVE_DECL__BYTESWAP_ULONG)
check_cxx_symbol_exists(_byteswap_ushort "stdlib.h" HAVE_DECL__BYTESWAP_USHORT)
check_cxx_symbol_exists(_putenv_s "stdlib.h" HAVE_DECL__PUTENV_S)
check_cxx_symbol_exists(__popcnt "intrin.h" HAVE_DECL___POPCNT)
check_cxx_symbol_exists(__popcnt64 "intrin.h" HAVE_DECL___POPCNT64)
check_function_exists("closefrom" HAVE_CLOSEFROM)
check_function_exists("fork" HAVE_FORK)
check_function_exists("ftime" HAVE_FTIME)
check_function_exists("ftruncate" HAVE_FTRUNCATE)
check_function_exists("getdirentries" HAVE_GETDIRENTRIES)
check_function_exists("gethostname" HAVE_GETHOSTNAME)
check_function_exists("getrlimit" HAVE_GETRLIMIT)
check_function_exists("getrusage" HAVE_GETRUSAGE)
check_function_exists("link" HAVE_LINK)
check_function_exists("nftw" HAVE_NFTW)
check_function_exists("random" HAVE_RANDOM)
check_function_exists("setenv" HAVE_SETENV)
check_function_exists("sigaction" HAVE_SIGACTION)
check_function_exists("sigsetjmp" HAVE_SIGSETJMP)
check_function_exists("sleep" HAVE_SLEEP)
check_function_exists("socketpair" HAVE_SOCKETPAIR)
check_function_exists("srandom" HAVE_SRANDOM)
check_function_exists("strerror_r" HAVE_STRERROR_R)
check_function_exists("sysconf" HAVE_SYSCONF)
check_function_exists("timer_create" HAVE_TIMER_CREATE)
check_function_exists("times" HAVE_TIMES)
check_function_exists("writev" HAVE_WRITEV)
check_cxx_source_compiles("
#include <errno.h>
#include <stdio.h>
int main() {
printf(\"%s\", sys_errlist[sys_nerr - 1]);
return 0;
}" HAVE_SYS_ERRLIST_AND_SYS_NERR)
check_cxx_source_compiles("
#include <errno.h>
#include <stdio.h>
int main() {
printf(\"%s\", _sys_errlist[_sys_nerr - 1]);
return 0;
}" HAVE__SYS_ERRLIST_AND__SYS_NERR)
check_cxx_source_compiles("int main() { __builtin_exp10(0.0); return 0; }" HAVE___BUILTIN_EXP10)
check_cxx_source_compiles("
#include <sys/timeb.h>
int main() {
struct timeb tp;
return ftime(&tp);
}" FTIME_RETURNS_INT)
if (NOT FTIME_RETURNS_INT)
set (FTIME_RETURNS_VOID 1)
endif ()