-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
540 lines (434 loc) · 14.7 KB
/
Copy pathCMakeLists.txt
File metadata and controls
540 lines (434 loc) · 14.7 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
cmake_minimum_required(VERSION 3.24)
project(core VERSION 0.0.0 LANGUAGES C CXX ASM_MASM DESCRIPTION "Sourcemeta Core")
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# Options
option(SOURCEMETA_CORE_LANG_ALLOCATOR "Build the Sourcemeta Core language allocator library" ON)
option(SOURCEMETA_CORE_LANG_PREPROCESSOR "Build the Sourcemeta Core language preprocessor library" ON)
option(SOURCEMETA_CORE_LANG_IO "Build the Sourcemeta Core language I/O library" ON)
option(SOURCEMETA_CORE_LANG_PROCESS "Build the Sourcemeta Core language Process library" ON)
option(SOURCEMETA_CORE_LANG_PARALLEL "Build the Sourcemeta Core language parallel library" ON)
option(SOURCEMETA_CORE_LANG_NUMERIC "Build the Sourcemeta Core language numeric library" ON)
option(SOURCEMETA_CORE_LANG_MEMORY "Build the Sourcemeta Core language memory library" ON)
option(SOURCEMETA_CORE_LANG_ERROR "Build the Sourcemeta Core language error library" ON)
option(SOURCEMETA_CORE_LANG_OPTIONS "Build the Sourcemeta Core Options library" ON)
option(SOURCEMETA_CORE_LANG_TEXT "Build the Sourcemeta Core language text library" ON)
option(SOURCEMETA_CORE_LANG_STACKTRACE "Build the Sourcemeta Core language stacktrace library" ON)
option(SOURCEMETA_CORE_LANG_TEST "Build the Sourcemeta Core language test library" ON)
option(SOURCEMETA_CORE_LANG_BENCHMARK "Build the Sourcemeta Core language benchmark library" ON)
option(SOURCEMETA_CORE_UNICODE "Build the Sourcemeta Core Unicode library" ON)
option(SOURCEMETA_CORE_PUNYCODE "Build the Sourcemeta Core Punycode library" ON)
option(SOURCEMETA_CORE_TIME "Build the Sourcemeta Core time library" ON)
option(SOURCEMETA_CORE_CRYPTO "Build the Sourcemeta Core Crypto library" ON)
option(SOURCEMETA_CORE_CRYPTO_USE_REFERENCE "Use reference backend for the Sourcemeta Core Crypto library" OFF)
option(SOURCEMETA_CORE_REGEX "Build the Sourcemeta Core Regex library" ON)
option(SOURCEMETA_CORE_IP "Build the Sourcemeta Core IP library" ON)
option(SOURCEMETA_CORE_IDNA "Build the Sourcemeta Core IDNA library" ON)
option(SOURCEMETA_CORE_DNS "Build the Sourcemeta Core DNS library" ON)
option(SOURCEMETA_CORE_EMAIL "Build the Sourcemeta Core Email library" ON)
option(SOURCEMETA_CORE_LANGTAG "Build the Sourcemeta Core LangTag library" ON)
option(SOURCEMETA_CORE_URI "Build the Sourcemeta Core URI library" ON)
option(SOURCEMETA_CORE_URITEMPLATE "Build the Sourcemeta Core URI Template library" ON)
option(SOURCEMETA_CORE_JSON "Build the Sourcemeta Core JSON library" ON)
option(SOURCEMETA_CORE_JSONPOINTER "Build the Sourcemeta Core JSON Pointer library" ON)
option(SOURCEMETA_CORE_JSONSCHEMA "Build the Sourcemeta Core JSON Schema library" ON)
option(SOURCEMETA_CORE_JSONPATH "Build the Sourcemeta Core JSON Path library" ON)
option(SOURCEMETA_CORE_JSONLD "Build the Sourcemeta Core JSON-LD library" ON)
option(SOURCEMETA_CORE_JSONL "Build the Sourcemeta Core JSONL library" ON)
option(SOURCEMETA_CORE_YAML "Build the Sourcemeta Core YAML library" ON)
option(SOURCEMETA_CORE_JSONRPC "Build the Sourcemeta Core JSON-RPC library" ON)
option(SOURCEMETA_CORE_MCP "Build the Sourcemeta Core MCP library" ON)
option(SOURCEMETA_CORE_HTTP "Build the Sourcemeta Core HTTP library" ON)
option(SOURCEMETA_CORE_HTTP_USE_SYSTEM_CURL "Use system cURL for the Sourcemeta Core HTTP library" OFF)
option(SOURCEMETA_CORE_OPENAPI "Build the Sourcemeta Core OpenAPI library" ON)
option(SOURCEMETA_CORE_JOSE "Build the Sourcemeta Core JOSE library" ON)
option(SOURCEMETA_CORE_OAUTH "Build the Sourcemeta Core OAuth library" ON)
option(SOURCEMETA_CORE_OIDC "Build the Sourcemeta Core OIDC library" ON)
option(SOURCEMETA_CORE_SEMVER "Build the Sourcemeta Core SemVer library" ON)
option(SOURCEMETA_CORE_GZIP "Build the Sourcemeta Core GZIP library" ON)
option(SOURCEMETA_CORE_HTML "Build the Sourcemeta Core HTML library" ON)
option(SOURCEMETA_CORE_CSS "Build the Sourcemeta Core CSS library" ON)
option(SOURCEMETA_CORE_MARKDOWN "Build the Sourcemeta Core Markdown library" ON)
option(SOURCEMETA_CORE_DIFF "Build the Sourcemeta Core Diff library" ON)
option(SOURCEMETA_CORE_TERMINAL "Build the Sourcemeta Core Terminal library" ON)
option(SOURCEMETA_CORE_TESTS "Build the Sourcemeta Core tests" OFF)
option(SOURCEMETA_CORE_TESTS_CI "Build the Sourcemeta Core CI tests" OFF)
option(SOURCEMETA_CORE_BENCHMARK "Build the Sourcemeta Core benchmarks" OFF)
option(SOURCEMETA_CORE_DOCS "Build the Sourcemeta Core docs" OFF)
option(SOURCEMETA_CORE_CLANG_TIDY "Run ClangTidy alongside compilation wherever this project can" ON)
option(SOURCEMETA_CORE_INSTALL "Install the Sourcemeta Core library" ON)
option(SOURCEMETA_CORE_ADDRESS_SANITIZER "Build Sourcemeta Core with an address sanitizer" OFF)
option(SOURCEMETA_CORE_UNDEFINED_SANITIZER "Build Sourcemeta Core with an undefined behavior sanitizer" OFF)
option(SOURCEMETA_CORE_USE_SYSTEM_ALLOCATOR "Always use the system allocator" OFF)
include(Sourcemeta)
# Don't force downstream consumers on this
if(PROJECT_IS_TOP_LEVEL)
sourcemeta_enable_simd()
endif()
# The compiler cache has to be in place before we declare any target
if(PROJECT_IS_TOP_LEVEL)
sourcemeta_ccache_attempt_enable(DIRECTORY "${PROJECT_SOURCE_DIR}/.ccache")
endif()
# Enable the sanitizers before defining any target
if(SOURCEMETA_CORE_ADDRESS_SANITIZER)
sourcemeta_sanitizer(TYPE address)
elseif(SOURCEMETA_CORE_UNDEFINED_SANITIZER)
sourcemeta_sanitizer(TYPE undefined)
endif()
# Dependencies
if(SOURCEMETA_CORE_CRYPTO)
if(SOURCEMETA_CORE_CRYPTO_USE_REFERENCE)
set(SOURCEMETA_CORE_CRYPTO_BACKEND reference)
elseif(APPLE)
set(SOURCEMETA_CORE_CRYPTO_BACKEND apple)
elseif(WIN32)
set(SOURCEMETA_CORE_CRYPTO_BACKEND windows)
else()
find_package(OpenSSL 3.0 REQUIRED)
set(SOURCEMETA_CORE_CRYPTO_BACKEND openssl)
endif()
message(STATUS
"Using the ${SOURCEMETA_CORE_CRYPTO_BACKEND} cryptography backend")
endif()
if(SOURCEMETA_CORE_LANG_ALLOCATOR
AND (SOURCEMETA_OS_LINUX OR SOURCEMETA_OS_MACOS)
AND NOT SOURCEMETA_CORE_ADDRESS_SANITIZER
AND NOT SOURCEMETA_CORE_UNDEFINED_SANITIZER
AND NOT SOURCEMETA_CORE_USE_SYSTEM_ALLOCATOR)
message(STATUS "Using the mimalloc allocator")
find_package(Mimalloc REQUIRED)
endif()
if(SOURCEMETA_CORE_REGEX)
find_package(SLJIT REQUIRED)
find_package(PCRE2 REQUIRED)
endif()
if(SOURCEMETA_CORE_LANG_PARALLEL)
find_package(Threads REQUIRED)
endif()
# TODO: Turn this into a re-usable utility CMake function
if(SOURCEMETA_CORE_INSTALL)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
configure_package_config_file(
config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
COMPATIBILITY SameMajorVersion)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
COMPONENT sourcemeta_${PROJECT_NAME}_dev)
endif()
# Every executable in this build links this one, so it comes first
if(SOURCEMETA_CORE_LANG_ALLOCATOR)
add_subdirectory(src/lang/allocator)
else()
# A previous configuration of this same directory may have recorded a library
# that this one does not define, which every executable would then try to
# link by name
unset(SOURCEMETA_CORE_ALLOCATOR_TARGET CACHE)
endif()
if(SOURCEMETA_CORE_LANG_PREPROCESSOR)
add_subdirectory(src/lang/preprocessor)
endif()
if(SOURCEMETA_CORE_LANG_IO)
add_subdirectory(src/lang/io)
endif()
if(SOURCEMETA_CORE_LANG_PROCESS)
add_subdirectory(src/lang/process)
endif()
if(SOURCEMETA_CORE_LANG_PARALLEL)
add_subdirectory(src/lang/parallel)
endif()
if(SOURCEMETA_CORE_LANG_NUMERIC)
add_subdirectory(src/lang/numeric)
endif()
if(SOURCEMETA_CORE_LANG_MEMORY)
add_subdirectory(src/lang/memory)
endif()
if(SOURCEMETA_CORE_LANG_ERROR)
add_subdirectory(src/lang/error)
endif()
if(SOURCEMETA_CORE_LANG_OPTIONS)
add_subdirectory(src/lang/options)
endif()
if(SOURCEMETA_CORE_LANG_TEXT)
add_subdirectory(src/lang/text)
endif()
if(SOURCEMETA_CORE_LANG_STACKTRACE)
add_subdirectory(src/lang/stacktrace)
endif()
if(SOURCEMETA_CORE_LANG_TEST)
add_subdirectory(src/lang/test)
endif()
if(SOURCEMETA_CORE_LANG_BENCHMARK)
add_subdirectory(src/lang/benchmark)
endif()
if(SOURCEMETA_CORE_UNICODE)
add_subdirectory(src/core/unicode)
endif()
if(SOURCEMETA_CORE_PUNYCODE)
add_subdirectory(src/core/punycode)
endif()
if(SOURCEMETA_CORE_TIME)
add_subdirectory(src/core/time)
endif()
if(SOURCEMETA_CORE_CRYPTO)
add_subdirectory(src/core/crypto)
endif()
if(SOURCEMETA_CORE_REGEX)
add_subdirectory(src/core/regex)
endif()
if(SOURCEMETA_CORE_IP)
add_subdirectory(src/core/ip)
endif()
if(SOURCEMETA_CORE_IDNA)
add_subdirectory(src/core/idna)
endif()
if(SOURCEMETA_CORE_DNS)
add_subdirectory(src/core/dns)
endif()
if(SOURCEMETA_CORE_EMAIL)
add_subdirectory(src/core/email)
endif()
if(SOURCEMETA_CORE_LANGTAG)
add_subdirectory(src/core/langtag)
endif()
if(SOURCEMETA_CORE_URI)
add_subdirectory(src/core/uri)
endif()
if(SOURCEMETA_CORE_URITEMPLATE)
add_subdirectory(src/core/uritemplate)
endif()
if(SOURCEMETA_CORE_JSON)
add_subdirectory(src/core/json)
endif()
if(SOURCEMETA_CORE_JSONPOINTER)
add_subdirectory(src/core/jsonpointer)
endif()
if(SOURCEMETA_CORE_JSONSCHEMA)
add_subdirectory(src/core/jsonschema)
endif()
if(SOURCEMETA_CORE_JSONPATH)
add_subdirectory(src/core/jsonpath)
endif()
if(SOURCEMETA_CORE_JSONLD)
add_subdirectory(src/core/jsonld)
endif()
if(SOURCEMETA_CORE_GZIP)
add_subdirectory(src/core/gzip)
endif()
if(SOURCEMETA_CORE_JSONL)
add_subdirectory(src/core/jsonl)
endif()
if(SOURCEMETA_CORE_YAML)
add_subdirectory(src/core/yaml)
endif()
if(SOURCEMETA_CORE_JSONRPC)
add_subdirectory(src/core/jsonrpc)
endif()
if(SOURCEMETA_CORE_MCP)
add_subdirectory(src/core/mcp)
endif()
if(SOURCEMETA_CORE_HTTP)
add_subdirectory(src/core/http)
endif()
if(SOURCEMETA_CORE_OPENAPI)
add_subdirectory(src/core/openapi)
endif()
if(SOURCEMETA_CORE_JOSE)
add_subdirectory(src/core/jose)
endif()
if(SOURCEMETA_CORE_OAUTH)
add_subdirectory(src/core/oauth)
endif()
if(SOURCEMETA_CORE_OIDC)
add_subdirectory(src/core/oidc)
endif()
if(SOURCEMETA_CORE_SEMVER)
add_subdirectory(src/core/semver)
endif()
if(SOURCEMETA_CORE_HTML)
add_subdirectory(src/core/html)
endif()
if(SOURCEMETA_CORE_CSS)
add_subdirectory(src/core/css)
endif()
if(SOURCEMETA_CORE_MARKDOWN)
add_subdirectory(src/core/markdown)
endif()
if(SOURCEMETA_CORE_DIFF)
add_subdirectory(src/core/diff)
endif()
if(SOURCEMETA_CORE_TERMINAL)
add_subdirectory(src/core/terminal)
endif()
if(SOURCEMETA_CORE_DOCS)
sourcemeta_target_doxygen(CONFIG "${PROJECT_SOURCE_DIR}/doxygen/Doxyfile.in"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/website")
endif()
if(PROJECT_IS_TOP_LEVEL)
sourcemeta_target_clang_format(SOURCES
src/*.h src/*.cc
benchmark/*.h benchmark/*.cc
test/*.h test/*.cc)
endif()
# Testing
if(SOURCEMETA_CORE_TESTS)
enable_testing()
if(SOURCEMETA_CORE_LANG_ALLOCATOR)
add_subdirectory(test/allocator)
endif()
if(SOURCEMETA_CORE_LANG_IO)
add_subdirectory(test/io)
endif()
if(SOURCEMETA_CORE_LANG_PROCESS)
add_subdirectory(test/process)
endif()
if(SOURCEMETA_CORE_LANG_PARALLEL)
add_subdirectory(test/parallel)
endif()
if(SOURCEMETA_CORE_LANG_NUMERIC)
add_subdirectory(test/numeric)
endif()
if(SOURCEMETA_CORE_LANG_MEMORY)
add_subdirectory(test/memory)
endif()
if(SOURCEMETA_CORE_LANG_ERROR)
add_subdirectory(test/error)
endif()
if(SOURCEMETA_CORE_LANG_OPTIONS)
add_subdirectory(test/options)
endif()
if(SOURCEMETA_CORE_LANG_TEXT)
add_subdirectory(test/text)
endif()
if(SOURCEMETA_CORE_LANG_STACKTRACE
AND NOT SOURCEMETA_CORE_ADDRESS_SANITIZER
AND NOT SOURCEMETA_CORE_UNDEFINED_SANITIZER)
add_subdirectory(test/stacktrace)
endif()
if(SOURCEMETA_CORE_LANG_TEST)
add_subdirectory(test/test)
endif()
if(SOURCEMETA_CORE_LANG_BENCHMARK)
add_subdirectory(test/benchmark)
endif()
if(SOURCEMETA_CORE_UNICODE)
add_subdirectory(test/unicode)
endif()
if(SOURCEMETA_CORE_PUNYCODE)
add_subdirectory(test/punycode)
endif()
if(SOURCEMETA_CORE_TIME)
add_subdirectory(test/time)
endif()
if(SOURCEMETA_CORE_CRYPTO)
add_subdirectory(test/crypto)
endif()
if(SOURCEMETA_CORE_REGEX)
add_subdirectory(test/regex)
endif()
if(SOURCEMETA_CORE_IP)
add_subdirectory(test/ip)
endif()
if(SOURCEMETA_CORE_IDNA)
add_subdirectory(test/idna)
endif()
if(SOURCEMETA_CORE_DNS)
add_subdirectory(test/dns)
endif()
if(SOURCEMETA_CORE_EMAIL)
add_subdirectory(test/email)
endif()
if(SOURCEMETA_CORE_LANGTAG)
add_subdirectory(test/langtag)
endif()
if(SOURCEMETA_CORE_URI)
add_subdirectory(test/uri)
endif()
if(SOURCEMETA_CORE_URITEMPLATE)
add_subdirectory(test/uritemplate)
endif()
if(SOURCEMETA_CORE_JSON)
add_subdirectory(test/json)
endif()
if(SOURCEMETA_CORE_JSONPOINTER)
add_subdirectory(test/jsonpointer)
endif()
if(SOURCEMETA_CORE_JSONSCHEMA)
add_subdirectory(test/jsonschema)
endif()
if(SOURCEMETA_CORE_JSONPATH)
add_subdirectory(test/jsonpath)
endif()
if(SOURCEMETA_CORE_JSONLD)
add_subdirectory(test/jsonld)
endif()
if(SOURCEMETA_CORE_GZIP)
add_subdirectory(test/gzip)
endif()
if(SOURCEMETA_CORE_JSONL)
add_subdirectory(test/jsonl)
endif()
if(SOURCEMETA_CORE_YAML)
add_subdirectory(test/yaml)
endif()
if(SOURCEMETA_CORE_JSONRPC)
add_subdirectory(test/jsonrpc)
endif()
if(SOURCEMETA_CORE_MCP)
add_subdirectory(test/mcp)
endif()
if(SOURCEMETA_CORE_HTTP)
add_subdirectory(test/http)
endif()
if(SOURCEMETA_CORE_OPENAPI)
add_subdirectory(test/openapi)
endif()
if(SOURCEMETA_CORE_JOSE)
add_subdirectory(test/jose)
endif()
if(SOURCEMETA_CORE_OAUTH)
add_subdirectory(test/oauth)
endif()
if(SOURCEMETA_CORE_OIDC)
add_subdirectory(test/oidc)
endif()
if(SOURCEMETA_CORE_SEMVER)
add_subdirectory(test/semver)
endif()
if(SOURCEMETA_CORE_HTML)
add_subdirectory(test/html)
endif()
if(SOURCEMETA_CORE_CSS)
add_subdirectory(test/css)
endif()
if(SOURCEMETA_CORE_MARKDOWN)
add_subdirectory(test/markdown)
endif()
if(SOURCEMETA_CORE_DIFF)
add_subdirectory(test/diff)
endif()
if(SOURCEMETA_CORE_TERMINAL)
add_subdirectory(test/terminal)
endif()
if(PROJECT_IS_TOP_LEVEL)
# Otherwise we need the child project to link
# against the sanitizers too.
if(NOT SOURCEMETA_CORE_ADDRESS_SANITIZER AND NOT SOURCEMETA_CORE_UNDEFINED_SANITIZER)
add_subdirectory(test/packaging)
endif()
endif()
endif()
if(SOURCEMETA_CORE_TESTS_CI)
enable_testing()
if(SOURCEMETA_CORE_HTTP)
add_subdirectory(test/http/ci)
endif()
endif()
if(SOURCEMETA_CORE_BENCHMARK)
add_subdirectory(benchmark)
endif()