-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
948 lines (830 loc) · 44.1 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
###############################################################################
# BARF (Bison Awesomely Replaced, Flex) -- a suite of sweet compiler tools.
###############################################################################
cmake_minimum_required(VERSION 3.18)
project(barf)
# NOTE: After cutting a release, you should increment the patch number and append `-DEV` so that
# the deb packages produced while developing are distinguished from the actual tagged release.
set(barf_VERSION 2.7.0)
string(REPLACE "." ";" VERSION_LIST ${barf_VERSION})
list(GET VERSION_LIST 0 barf_VERSION_MAJOR)
list(GET VERSION_LIST 1 barf_VERSION_MINOR)
list(GET VERSION_LIST 2 barf_VERSION_PATCH)
# Set and require the C++14 standard
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# This includes the reflex and trison source file rules (for generating C++).
# Other projects that want to define cmake rules for compiling reflex or trison
# source to C++ should copy the barf/cmake dir into their project and include it.
include(./cmake/reflex-rules.cmake)
include(./cmake/trison-rules.cmake)
# These define developer-specific rules only for use within the barf project itself.
include(./cmake-private/reflex-dev-rules.cmake)
include(./cmake-private/trison-dev-rules.cmake)
# This is the root dir for files to be installed (notably the barf target files)
# This particular value is used as a #define to the various libs and executables
# so they know where the targets dir is.
set(HARDCODED_BARF_TARGETS_DIR ${CMAKE_INSTALL_PREFIX}/lib/barf/targets)
# This indicates all executables should be put in the bin subdir of the build dir.
# Normally this wouldn't be done, but there's a stupid bug in find_program, where
# it searches the current directory for executables, instead of only searching
# the path like a reasonable person would.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# This property is set so that the cpp and hpp files generated by reflex and
# trison aren't cleaned during `make clean`. This is because those files
# should be checked into the source repo and stay there, only being re-generated
# if the corresponding reflex or trison source (or other source files) changes.
set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM true)
option(BUILD_barftest "Build barftest binary (unnecessary for `make package`)" ON)
option(barf_DEVELOPER_MODE "Enable (and require) barf developer configuration options; requires having a stable version of barf installed already, which will be used to build the barf parsers and scanners in a self-hosting manner. Not necessary to simply build this package from source." OFF)
if(barf_DEVELOPER_MODE)
find_package(barf REQUIRED)
endif()
option(barf_LINE_DIRECTIVES_RELATIVE_TO_BUILD_DIR "If enabled, specifies that the paths in the #line directives in the generated parser/scanner code will be relative to the build dir." ON)
if(barf_LINE_DIRECTIVES_RELATIVE_TO_BUILD_DIR)
set(LINE_DIRECTIVES_RELATIVE_TO_DIR "${PROJECT_BINARY_DIR}")
else()
set(LINE_DIRECTIVES_RELATIVE_TO_DIR "")
endif()
# This sets the DOXYGEN_EXECUTABLE and DOXYGEN_DOT_EXECUTABLE vars.
find_package(Doxygen REQUIRED dot)
# TODO: Hook up doxygen config and generation
# Options to correctly link the standard C++ lib on Mac.
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") # This is the correct way to detect Mac OS X operating system -- see http://www.openguru.com/2009/04/cmake-detecting-platformoperating.html
set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++")
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") # GCC ("GNU") probably would require a different option
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()
endif()
###############################################################################
# Doxygen doc rules
###############################################################################
set(DOXYGEN_OUTPUT_DIRECTORY doc)
doxygen_add_docs(doc ${PROJECT_SOURCE_DIR}/doc/doxygen_pages)
###############################################################################
# Dependencies
###############################################################################
# Helper target(s)
add_library(Strict INTERFACE)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_compile_options(Strict INTERFACE -Wall -Werror)
endif()
add_library(SaveTemps INTERFACE)
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin" OR ${CMAKE_SYSTEM_NAME} MATCHES "Linux")
target_compile_options(SaveTemps INTERFACE -save-temps)
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
# TODO
endif()
###############################################################################
# Libraries
###############################################################################
#
# barf_commonlang_and_targetspec
#
if(barf_DEVELOPER_MODE)
reflex_add_source(${PROJECT_SOURCE_DIR}/lib/commonlang/barf_commonlang_scanner.reflex ${PROJECT_SOURCE_DIR}/lib/commonlang/generated barf_commonlang_scanner "${LINE_DIRECTIVES_RELATIVE_TO_DIR}")
trison_add_source(${PROJECT_SOURCE_DIR}/lib/targetspec/barf_targetspec_parser.trison ${PROJECT_SOURCE_DIR}/lib/targetspec/generated barf_targetspec_parser "${LINE_DIRECTIVES_RELATIVE_TO_DIR}")
endif()
set(barf_commonlang_and_targetspec_SOURCES
lib/commonlang/barf_commonlang.hpp
lib/commonlang/barf_commonlang_ast.cpp
lib/commonlang/barf_commonlang_ast.hpp
lib/commonlang/barf_commonlang_scanner.reflex
lib/targetspec/barf_targetspec.hpp
lib/targetspec/barf_targetspec_ast.cpp
lib/targetspec/barf_targetspec_ast.hpp
lib/targetspec/barf_targetspec_parser.trison
)
set(barf_commonlang_and_targetspec_GENERATED_SOURCES
lib/commonlang/generated/barf_commonlang_scanner.cpp
lib/commonlang/generated/barf_commonlang_scanner.hpp
lib/targetspec/generated/barf_targetspec_parser.cpp
lib/targetspec/generated/barf_targetspec_parser.hpp
)
add_library(barf_commonlang_and_targetspec ${barf_commonlang_and_targetspec_SOURCES} ${barf_commonlang_and_targetspec_GENERATED_SOURCES})
target_compile_definitions(
barf_commonlang_and_targetspec
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
barf_commonlang_and_targetspec
PUBLIC
${PROJECT_SOURCE_DIR}/lib/commonlang
${PROJECT_SOURCE_DIR}/lib/targetspec
${PROJECT_SOURCE_DIR}/lib/commonlang/generated
${PROJECT_SOURCE_DIR}/lib/targetspec/generated
)
target_link_libraries(barf_commonlang_and_targetspec PUBLIC Strict barf_core barf_preprocessor)
# dev version of barf_commonlang_and_targetspec
reflex_add_source_dev(${PROJECT_SOURCE_DIR}/lib/commonlang/barf_commonlang_scanner.reflex ${PROJECT_SOURCE_DIR}/lib/commonlang/generated ${PROJECT_BINARY_DIR}/dev/lib/commonlang/generated dev_barf_commonlang_scanner)
trison_add_source_dev(${PROJECT_SOURCE_DIR}/lib/targetspec/barf_targetspec_parser.trison ${PROJECT_SOURCE_DIR}/lib/targetspec/generated ${PROJECT_BINARY_DIR}/dev/lib/targetspec/generated dev_barf_targetspec_parser)
reflex_add_source_metadev(${PROJECT_SOURCE_DIR}/lib/commonlang/barf_commonlang_scanner.reflex ${PROJECT_BINARY_DIR}/metadev/lib/commonlang/generated metadev_barf_commonlang_scanner dev_barf_commonlang_scanner)
trison_add_source_metadev(${PROJECT_SOURCE_DIR}/lib/targetspec/barf_targetspec_parser.trison ${PROJECT_BINARY_DIR}/metadev/lib/targetspec/generated metadev_barf_targetspec_parser dev_barf_targetspec_parser)
set(dev_barf_commonlang_and_targetspec_GENERATED_SOURCES
${PROJECT_BINARY_DIR}/dev/lib/commonlang/generated/barf_commonlang_scanner.cpp
${PROJECT_BINARY_DIR}/dev/lib/commonlang/generated/barf_commonlang_scanner.hpp
${PROJECT_BINARY_DIR}/dev/lib/targetspec/generated/barf_targetspec_parser.cpp
${PROJECT_BINARY_DIR}/dev/lib/targetspec/generated/barf_targetspec_parser.hpp
)
add_library(dev_barf_commonlang_and_targetspec EXCLUDE_FROM_ALL ${barf_commonlang_and_targetspec_SOURCES} ${dev_barf_commonlang_and_targetspec_GENERATED_SOURCES})
# CMake isn't apparently smart enough to figure out that ${PROJECT_BINARY_DIR]/dev/* files have dependencies, so this is needed.
add_dependencies(dev_barf_commonlang_and_targetspec reflex trison)
target_compile_definitions(
dev_barf_commonlang_and_targetspec
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
dev_barf_commonlang_and_targetspec
PUBLIC
${PROJECT_SOURCE_DIR}/lib/commonlang
${PROJECT_SOURCE_DIR}/lib/targetspec
# Include the dev generated dirs, not the main source ones.
${PROJECT_BINARY_DIR}/dev/lib/commonlang/generated
${PROJECT_BINARY_DIR}/dev/lib/targetspec/generated
)
target_link_libraries(dev_barf_commonlang_and_targetspec PUBLIC Strict dev_barf_core dev_barf_preprocessor)
#
# barf_core
#
set(barf_core_SOURCES
lib/core/barf.cpp
lib/core/barf.hpp
lib/core/barf_ast.cpp
lib/core/barf_ast.hpp
lib/core/barf_commandlineparser.cpp
lib/core/barf_commandlineparser.hpp
lib/core/barf_compiletimeasserts.cpp
lib/core/barf_compiletimeasserts.hpp
lib/core/barf_enums.cpp
lib/core/barf_enums.hpp
lib/core/barf_filoc.cpp
lib/core/barf_filoc.hpp
lib/core/barf_graph.cpp
lib/core/barf_graph.hpp
lib/core/barf_inputbase.cpp
lib/core/barf_inputbase.hpp
lib/core/barf_list.hpp
lib/core/barf_message.cpp
lib/core/barf_message.hpp
lib/core/barf_optionsbase.cpp
lib/core/barf_optionsbase.hpp
lib/core/barf_path.cpp
lib/core/barf_path.hpp
lib/core/barf_pointer.hpp
lib/core/barf_searchpath.cpp
lib/core/barf_searchpath.hpp
lib/core/barf_types.hpp
lib/core/barf_util.cpp
lib/core/barf_util.hpp
lib/core/barf_weakreference.hpp
)
# NOTE: If any parsers/scanners are added to barf_core, then add barf_core_GENERATED_SOURCES here
# and make analogous entries in the commands below as other targets that already have parsers/scanners.
add_library(barf_core ${barf_core_SOURCES})
target_compile_definitions(
barf_core
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
barf_core
PUBLIC
${PROJECT_SOURCE_DIR}/lib/core
)
target_link_libraries(barf_core PUBLIC Strict)
# dev version of barf_core
add_library(dev_barf_core EXCLUDE_FROM_ALL ${barf_core_SOURCES})
target_compile_definitions(
dev_barf_core
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
dev_barf_core
PUBLIC
${PROJECT_SOURCE_DIR}/lib/core
# ${PROJECT_BINARY_DIR}/dev/lib/core/generated # This doesn't need to exist yet, but may later.
)
target_link_libraries(dev_barf_core PUBLIC Strict)
#
# barf_preprocessor
#
if(barf_DEVELOPER_MODE)
reflex_add_source(${PROJECT_SOURCE_DIR}/lib/preprocessor/barf_preprocessor_scanner.reflex ${PROJECT_SOURCE_DIR}/lib/preprocessor/generated barf_preprocessor_scanner "${LINE_DIRECTIVES_RELATIVE_TO_DIR}")
trison_add_source(${PROJECT_SOURCE_DIR}/lib/preprocessor/barf_preprocessor_parser.trison ${PROJECT_SOURCE_DIR}/lib/preprocessor/generated barf_preprocessor_parser "${LINE_DIRECTIVES_RELATIVE_TO_DIR}")
endif()
set(barf_preprocessor_SOURCES
lib/preprocessor/barf_preprocessor.hpp
lib/preprocessor/barf_preprocessor_ast.cpp
lib/preprocessor/barf_preprocessor_ast_execute.cpp
lib/preprocessor/barf_preprocessor_ast.hpp
lib/preprocessor/barf_preprocessor_ast_print.cpp
lib/preprocessor/barf_preprocessor_parser.trison
lib/preprocessor/barf_preprocessor_scanner.reflex
lib/preprocessor/barf_preprocessor_symboltable.cpp
lib/preprocessor/barf_preprocessor_symboltable.hpp
lib/preprocessor/barf_preprocessor_textifier.cpp
lib/preprocessor/barf_preprocessor_textifier.hpp
)
set(barf_preprocessor_GENERATED_SOURCES
lib/preprocessor/generated/barf_preprocessor_parser.cpp
lib/preprocessor/generated/barf_preprocessor_parser.hpp
lib/preprocessor/generated/barf_preprocessor_scanner.cpp
lib/preprocessor/generated/barf_preprocessor_scanner.hpp
)
add_library(barf_preprocessor ${barf_preprocessor_SOURCES} ${barf_preprocessor_GENERATED_SOURCES})
target_compile_definitions(
barf_preprocessor
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
barf_preprocessor
PUBLIC
${PROJECT_SOURCE_DIR}/lib/preprocessor
${PROJECT_SOURCE_DIR}/lib/preprocessor/generated
)
target_link_libraries(barf_preprocessor PUBLIC Strict barf_core)
# dev version of barf_preprocessor
reflex_add_source_dev(${PROJECT_SOURCE_DIR}/lib/preprocessor/barf_preprocessor_scanner.reflex ${PROJECT_SOURCE_DIR}/lib/preprocessor/generated ${PROJECT_BINARY_DIR}/dev/lib/preprocessor/generated dev_barf_preprocessor_scanner)
trison_add_source_dev(${PROJECT_SOURCE_DIR}/lib/preprocessor/barf_preprocessor_parser.trison ${PROJECT_SOURCE_DIR}/lib/preprocessor/generated ${PROJECT_BINARY_DIR}/dev/lib/preprocessor/generated dev_barf_preprocessor_parser)
reflex_add_source_metadev(${PROJECT_SOURCE_DIR}/lib/preprocessor/barf_preprocessor_scanner.reflex ${PROJECT_BINARY_DIR}/metadev/lib/preprocessor/generated metadev_barf_preprocessor_scanner dev_barf_preprocessor_scanner)
trison_add_source_metadev(${PROJECT_SOURCE_DIR}/lib/preprocessor/barf_preprocessor_parser.trison ${PROJECT_BINARY_DIR}/metadev/lib/preprocessor/generated metadev_barf_preprocessor_parser dev_barf_preprocessor_parser)
set(dev_barf_preprocessor_GENERATED_SOURCES
${PROJECT_BINARY_DIR}/dev/lib/preprocessor/generated/barf_preprocessor_parser.cpp
${PROJECT_BINARY_DIR}/dev/lib/preprocessor/generated/barf_preprocessor_parser.hpp
${PROJECT_BINARY_DIR}/dev/lib/preprocessor/generated/barf_preprocessor_scanner.cpp
${PROJECT_BINARY_DIR}/dev/lib/preprocessor/generated/barf_preprocessor_scanner.hpp
)
add_library(dev_barf_preprocessor EXCLUDE_FROM_ALL ${barf_preprocessor_SOURCES} ${dev_barf_preprocessor_GENERATED_SOURCES})
add_dependencies(dev_barf_preprocessor reflex trison)
target_compile_definitions(
dev_barf_preprocessor
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
dev_barf_preprocessor
PUBLIC
${PROJECT_SOURCE_DIR}/lib/preprocessor
# Include the dev generated dirs, not the main source ones.
${PROJECT_BINARY_DIR}/dev/lib/preprocessor/generated
)
target_link_libraries(dev_barf_preprocessor PUBLIC Strict dev_barf_core)
#
# barf_regex
#
if(barf_DEVELOPER_MODE)
trison_add_source(${PROJECT_SOURCE_DIR}/lib/regex/barf_regex_parser.trison ${PROJECT_SOURCE_DIR}/lib/regex/generated barf_regex_parser "${LINE_DIRECTIVES_RELATIVE_TO_DIR}")
endif()
set(barf_regex_SOURCES
lib/regex/barf_regex.cpp
lib/regex/barf_regex.hpp
lib/regex/barf_regex_ast.cpp
lib/regex/barf_regex_ast.hpp
lib/regex/barf_regex_dfa.cpp
lib/regex/barf_regex_dfa.hpp
lib/regex/barf_regex_graph.cpp
lib/regex/barf_regex_graph.hpp
lib/regex/barf_regex_nfa.cpp
lib/regex/barf_regex_nfa.hpp
lib/regex/barf_regex_parser.trison
)
set(barf_regex_GENERATED_SOURCES
lib/regex/generated/barf_regex_parser.cpp
lib/regex/generated/barf_regex_parser.hpp
)
add_library(barf_regex ${barf_regex_SOURCES} ${barf_regex_GENERATED_SOURCES})
target_compile_definitions(
barf_regex
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
barf_regex
PUBLIC
${PROJECT_SOURCE_DIR}/lib/regex
${PROJECT_SOURCE_DIR}/lib/regex/generated
)
target_link_libraries(barf_regex PUBLIC Strict barf_core)
# dev version of barf_regex
trison_add_source_dev(${PROJECT_SOURCE_DIR}/lib/regex/barf_regex_parser.trison ${PROJECT_SOURCE_DIR}/lib/regex/generated ${PROJECT_BINARY_DIR}/dev/lib/regex/generated dev_barf_regex_parser)
trison_add_source_metadev(${PROJECT_SOURCE_DIR}/lib/regex/barf_regex_parser.trison ${PROJECT_BINARY_DIR}/metadev/lib/regex/generated metadev_barf_regex_parser dev_barf_regex_parser)
set(dev_barf_regex_GENERATED_SOURCES
${PROJECT_BINARY_DIR}/dev/lib/regex/generated/barf_regex_parser.cpp
${PROJECT_BINARY_DIR}/dev/lib/regex/generated/barf_regex_parser.hpp
)
add_library(dev_barf_regex EXCLUDE_FROM_ALL ${barf_regex_SOURCES} ${dev_barf_regex_GENERATED_SOURCES})
add_dependencies(dev_barf_regex trison)
target_compile_definitions(
dev_barf_regex
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
dev_barf_regex
PUBLIC
${PROJECT_SOURCE_DIR}/lib/regex
# Include the dev generated dirs, not the main source ones.
${PROJECT_BINARY_DIR}/dev/lib/regex/generated
)
target_link_libraries(dev_barf_regex PUBLIC Strict dev_barf_core)
###############################################################################
# Executables
###############################################################################
#
# barftest
#
if(BUILD_barftest)
find_package(lvd REQUIRED 0.8.0)
if(barf_DEVELOPER_MODE)
reflex_add_source(${barf_SOURCE_DIR}/bin/barftest/text/Scanner.reflex ${barf_SOURCE_DIR}/bin/barftest/text barftest_text_Scanner "${PROJECT_BINARY_DIR}")
trison_add_source(${barf_SOURCE_DIR}/bin/barftest/text/Parser.trison ${barf_SOURCE_DIR}/bin/barftest/text barftest_text_Parser "${PROJECT_BINARY_DIR}")
endif()
set(barftest_SOURCES
bin/barftest/core.hpp
bin/barftest/Exception.cpp
bin/barftest/Exception.hpp
bin/barftest/FiLoc.hpp
bin/barftest/FiPos.hpp
bin/barftest/FiRange.hpp
bin/barftest/InputBase.cpp
bin/barftest/InputBase.hpp
bin/barftest/literal.hpp
bin/barftest/Log.hpp
bin/barftest/main.cpp
bin/barftest/parser__declaration_statement.cpp
bin/barftest/parser__expression.cpp
bin/barftest/parser__expression_then_end.cpp
bin/barftest/parser__expression_then_lookahead_end.cpp
bin/barftest/parser__function_literal.cpp
bin/barftest/parser__function_prototype.cpp
bin/barftest/parser__function_type_then_end.cpp
bin/barftest/parser__id_list.cpp
bin/barftest/parser__id_list_then_end.cpp
bin/barftest/parser__lookahead_test_expression.cpp
bin/barftest/parser__parenthesized_id_list.cpp
bin/barftest/parser__root.cpp
bin/barftest/parser__statement.cpp
bin/barftest/parser__statement_list.cpp
bin/barftest/parser__statement_list_then_end.cpp
bin/barftest/parser__statement_then_end.cpp
bin/barftest/parser__type_expression.cpp
bin/barftest/UnitTestParser.cpp
bin/barftest/UnitTestParser.hpp
bin/barftest/sem/Assignment.cpp
bin/barftest/sem/Assignment.hpp
bin/barftest/sem/Base.hpp
bin/barftest/sem/BinaryOperation.cpp
bin/barftest/sem/BinaryOperation.hpp
bin/barftest/sem/Break.cpp
bin/barftest/sem/Break.hpp
bin/barftest/sem/Conditional.cpp
bin/barftest/sem/Conditional.hpp
bin/barftest/sem/Declaration.cpp
bin/barftest/sem/Declaration.hpp
bin/barftest/sem/Definition.cpp
bin/barftest/sem/Definition.hpp
bin/barftest/sem/Determinability.cpp
bin/barftest/sem/Determinability.hpp
bin/barftest/sem/Dummy.cpp
bin/barftest/sem/Dummy.hpp
bin/barftest/sem/ElementAccess.cpp
bin/barftest/sem/ElementAccess.hpp
bin/barftest/sem/ErrorDummy.cpp
bin/barftest/sem/ErrorDummy.hpp
bin/barftest/sem/ExpressionKind.cpp
bin/barftest/sem/ExpressionKind.hpp
bin/barftest/sem/Function.cpp
bin/barftest/sem/FunctionEvaluation.cpp
bin/barftest/sem/FunctionEvaluation.hpp
bin/barftest/sem/Function.hpp
bin/barftest/sem/FunctionPrototype.cpp
bin/barftest/sem/FunctionPrototype.hpp
bin/barftest/sem/FunctionType.cpp
bin/barftest/sem/FunctionType.hpp
bin/barftest/sem/GlobalValueLinkage.cpp
bin/barftest/sem/GlobalValueLinkage.hpp
bin/barftest/sem/Identifier.cpp
bin/barftest/sem/Identifier.hpp
bin/barftest/sem/Initialization.cpp
bin/barftest/sem/Initialization.hpp
bin/barftest/sem/LLVMCast.cpp
bin/barftest/sem/LLVMCast.hpp
bin/barftest/sem/Loop.cpp
bin/barftest/sem/Loop.hpp
bin/barftest/sem/NullPtr.cpp
bin/barftest/sem/NullPtr.hpp
bin/barftest/sem/PointerType.cpp
bin/barftest/sem/PointerType.hpp
bin/barftest/sem/ReferenceType.cpp
bin/barftest/sem/ReferenceType.hpp
bin/barftest/sem/Return.cpp
bin/barftest/sem/Return.hpp
bin/barftest/sem/Specifier.hpp
bin/barftest/sem/StringLiteral.cpp
bin/barftest/sem/StringLiteral.hpp
bin/barftest/sem/SymbolSpecifier.cpp
bin/barftest/sem/SymbolSpecifier.hpp
bin/barftest/sem/TypeArray.cpp
bin/barftest/sem/TypeArray.hpp
bin/barftest/sem/Type.cpp
bin/barftest/sem/TypeEnum.cpp
bin/barftest/sem/TypeEnum.hpp
bin/barftest/sem/Type.hpp
bin/barftest/sem/TypeIdentifier.cpp
bin/barftest/sem/TypeIdentifier.hpp
bin/barftest/sem/UnaryOperation.cpp
bin/barftest/sem/UnaryOperation.hpp
bin/barftest/sem/Value.cpp
bin/barftest/sem/Value.hpp
bin/barftest/sem/ValueKind.cpp
bin/barftest/sem/ValueKind.hpp
bin/barftest/sem/ValueLifetime.cpp
bin/barftest/sem/ValueLifetime.hpp
bin/barftest/sem/Vector.cpp
bin/barftest/sem/Vector.hpp
bin/barftest/text/Parser.cpp
bin/barftest/text/Parser.hpp
bin/barftest/text/Parser.trison
bin/barftest/text/Scanner.cpp
bin/barftest/text/Scanner.hpp
bin/barftest/text/Scanner.reflex
)
add_executable(barftest ${barftest_SOURCES})
target_include_directories(barftest PUBLIC ${barf_SOURCE_DIR}/bin) # So includes look like #include "barftest/sem/Xyz.hpp"
target_compile_definitions(barftest PUBLIC PACKAGE_VERSION="${barf_VERSION}")
target_link_libraries(barftest PUBLIC Strict lvd)
endif()
#
# bpp (BARF Pre-Processor)
#
set(BPP_SOURCES
bin/bpp/bpp.hpp
bin/bpp/bpp_main.cpp
bin/bpp/bpp_options.cpp
bin/bpp/bpp_options.hpp
)
# NOTE: If any parsers/scanners are added to barf_core, then add barf_core_GENERATED_SOURCES here
# and make analogous entries in the commands below as other targets that already have parsers/scanners.
add_executable(bpp ${BPP_SOURCES})
target_compile_definitions(
bpp
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
bpp
PUBLIC
${PROJECT_SOURCE_DIR}/bin/bpp
# ${PROJECT_SOURCE_DIR}/bin/bpp/generated # This doesn't need to exist yet
)
target_link_libraries(bpp PUBLIC Strict barf_core barf_preprocessor)
# dev version of bpp
# Just use the same sources because there are no parsers or scanners in bpp itself.
add_executable(dev_bpp EXCLUDE_FROM_ALL ${BPP_SOURCES})
target_compile_definitions(
dev_bpp
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
dev_bpp
PUBLIC
${PROJECT_SOURCE_DIR}/bin/bpp
# ${PROJECT_BINARY_DIR}/dev/bin/bpp/generated # This doesn't need to exist yet.
)
target_link_libraries(dev_bpp PUBLIC Strict dev_barf_core dev_barf_preprocessor)
#
# reflex (scanner generator)
#
if(barf_DEVELOPER_MODE)
trison_add_source(${PROJECT_SOURCE_DIR}/bin/reflex/reflex_parser.trison ${PROJECT_SOURCE_DIR}/bin/reflex/generated reflex_parser "${LINE_DIRECTIVES_RELATIVE_TO_DIR}")
endif()
set(reflex_SOURCES
bin/reflex/reflex.hpp
bin/reflex/reflex_ast.cpp
bin/reflex/reflex_ast.hpp
bin/reflex/reflex_automaton.cpp
bin/reflex/reflex_automaton.hpp
bin/reflex/reflex_codespecsymbols.cpp
bin/reflex/reflex_codespecsymbols.hpp
bin/reflex/reflex_main.cpp
bin/reflex/reflex_options.cpp
bin/reflex/reflex_options.hpp
bin/reflex/reflex_parser.trison
)
set(reflex_GENERATED_SOURCES
bin/reflex/generated/reflex_parser.cpp
bin/reflex/generated/reflex_parser.hpp
)
add_executable(reflex ${reflex_SOURCES} ${reflex_GENERATED_SOURCES})
target_compile_definitions(
reflex
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
reflex
PUBLIC
${PROJECT_SOURCE_DIR}/bin/reflex
${PROJECT_SOURCE_DIR}/bin/reflex/generated
)
target_link_libraries(reflex PUBLIC Strict barf_commonlang_and_targetspec barf_core barf_preprocessor barf_regex)
# dev version of reflex
trison_add_source_dev(${PROJECT_SOURCE_DIR}/bin/reflex/reflex_parser.trison ${PROJECT_SOURCE_DIR}/bin/reflex/generated ${PROJECT_BINARY_DIR}/dev/bin/reflex/generated dev_reflex_parser)
trison_add_source_metadev(${PROJECT_SOURCE_DIR}/bin/reflex/reflex_parser.trison ${PROJECT_BINARY_DIR}/metadev/bin/reflex/generated metadev_reflex_parser dev_reflex_parser)
set(dev_reflex_GENERATED_SOURCES
${PROJECT_BINARY_DIR}/dev/bin/reflex/generated/reflex_parser.cpp
${PROJECT_BINARY_DIR}/dev/bin/reflex/generated/reflex_parser.hpp
)
add_executable(dev_reflex EXCLUDE_FROM_ALL ${reflex_SOURCES} ${dev_reflex_GENERATED_SOURCES})
add_dependencies(dev_reflex trison)
target_compile_definitions(
dev_reflex
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
dev_reflex
PUBLIC
${PROJECT_SOURCE_DIR}/bin/reflex
# Include the dev generated dirs, not the main source ones.
${PROJECT_BINARY_DIR}/dev/bin/reflex/generated
)
target_link_libraries(dev_reflex PUBLIC Strict dev_barf_commonlang_and_targetspec dev_barf_core dev_barf_preprocessor dev_barf_regex)
#
# trison (parser generator)
#
if(barf_DEVELOPER_MODE)
trison_add_source(${PROJECT_SOURCE_DIR}/bin/trison/trison_parser.trison ${PROJECT_SOURCE_DIR}/bin/trison/generated trison_parser "${LINE_DIRECTIVES_RELATIVE_TO_DIR}")
endif()
set(trison_SOURCES
bin/trison/trison.hpp
bin/trison/trison_ast.cpp
bin/trison/trison_ast.hpp
bin/trison/trison_codespecsymbols.cpp
bin/trison/trison_codespecsymbols.hpp
bin/trison/trison_dpda.cpp
bin/trison/trison_dpda.hpp
bin/trison/trison_enums.cpp
bin/trison/trison_enums.hpp
bin/trison/trison_graph.cpp
bin/trison/trison_graph.hpp
bin/trison/trison_main.cpp
bin/trison/trison_npda.cpp
bin/trison/trison_npda.hpp
bin/trison/trison_options.cpp
bin/trison/trison_options.hpp
bin/trison/trison_parser.trison
)
set(trison_GENERATED_SOURCES
bin/trison/generated/trison_parser.cpp
bin/trison/generated/trison_parser.hpp
)
add_executable(trison ${trison_SOURCES} ${trison_GENERATED_SOURCES})
target_compile_definitions(
trison
PUBLIC PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
target_include_directories(
trison
PUBLIC
${PROJECT_SOURCE_DIR}/bin/trison
${PROJECT_SOURCE_DIR}/bin/trison/generated
)
target_link_libraries(trison PUBLIC Strict barf_commonlang_and_targetspec barf_core barf_preprocessor)
# dev version of trison
trison_add_source_dev(${PROJECT_SOURCE_DIR}/bin/trison/trison_parser.trison ${PROJECT_SOURCE_DIR}/bin/trison/generated ${PROJECT_BINARY_DIR}/dev/bin/trison/generated dev_trison_parser)
trison_add_source_metadev(${PROJECT_SOURCE_DIR}/bin/trison/trison_parser.trison ${PROJECT_BINARY_DIR}/metadev/bin/trison/generated metadev_trison_parser dev_trison_parser)
set(dev_trison_GENERATED_SOURCES
${PROJECT_BINARY_DIR}/dev/bin/trison/generated/trison_parser.cpp
${PROJECT_BINARY_DIR}/dev/bin/trison/generated/trison_parser.hpp
)
add_executable(dev_trison EXCLUDE_FROM_ALL ${trison_SOURCES} ${dev_trison_GENERATED_SOURCES})
add_dependencies(dev_trison trison)
target_compile_definitions(
dev_trison
PUBLIC
PACKAGE_VERSION="${barf_VERSION}"
HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}"
)
# It's a little hacky to include ${PROJECT_BINARY_DIR}/dev since it's not separated like
# the subdirs of ${PROJECT_SOURCE_DIR}/lib, but it doesn't really matter.
target_include_directories(
dev_trison
PUBLIC
${PROJECT_SOURCE_DIR}/bin/trison
# Include the dev generated dirs, not the main source ones.
${PROJECT_BINARY_DIR}/dev/bin/trison/generated
)
target_link_libraries(dev_trison PUBLIC Strict dev_barf_commonlang_and_targetspec dev_barf_core dev_barf_preprocessor)
#
# playground (miscellaneous tooling around; only if barf_DEVELOPER_MODE is enabled)
#
if(barf_DEVELOPER_MODE)
set(playground_SOURCES
bin/playground.cpp
)
add_executable(playground ${playground_SOURCES})
# This is probably not strictly needed, but might as well include anyway.
# Could be solved by having these propagate automatically through the public
# or interface parts of the dependent cmake targets
target_compile_definitions(playground PUBLIC PACKAGE_VERSION="${barf_VERSION}" HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}")
target_link_libraries(playground PUBLIC Strict barf_regex)
# dev version of playground
add_executable(dev_playground EXCLUDE_FROM_ALL ${playground_SOURCES})
# This is probably not strictly needed, but might as well include anyway.
# Could be solved by having these propagate automatically through the public
# or interface parts of the dependent cmake targets
target_compile_definitions(dev_playground PUBLIC PACKAGE_VERSION="${barf_VERSION}" HARDCODED_BARF_TARGETS_DIR="${HARDCODED_BARF_TARGETS_DIR}")
target_link_libraries(dev_playground PUBLIC Strict dev_barf_regex)
endif()
###############################################################################
# Install rules
###############################################################################
install(
TARGETS bpp reflex trison # Executables produced by this package
RUNTIME DESTINATION bin # This is relative to CMAKE_INSTALL_PREFIX
)
install(
DIRECTORY targets # This holds all the reflex and trison targets (targetspec and codespec files)
DESTINATION lib/barf # This is relative to CMAKE_INSTALL_PREFIX
)
install(
DIRECTORY cmake # This installs other cmake scripts.
DESTINATION lib/barf # This is relative to CMAKE_INSTALL_PREFIX
)
install(
DIRECTORY extra # This holds "extras" (e.g. syntax highlighting files)
DESTINATION lib/barf # This is relative to CMAKE_INSTALL_PREFIX
)
install(
FILES # Important files
LICENSE.txt
README.md
barf-config.cmake # barf-config.cmake is how find_package(barf) works.
DESTINATION lib/barf # This is relative to CMAKE_INSTALL_PREFIX
)
if(DEFINED DOXYGEN_EXECUTABLE)
install(
DIRECTORY ${PROJECT_BINARY_DIR}/doc # Doxygen-generated documentation
DESTINATION lib/barf # This is relative to CMAKE_INSTALL_PREFIX
EXCLUDE_FROM_ALL
)
endif()
###############################################################################
# Helper targets (this defines a hierarchy of related build rules)
###############################################################################
if(barf_DEVELOPER_MODE)
add_custom_target(all_parsers DEPENDS barf_preprocessor_parser barf_regex_parser barf_targetspec_parser reflex_parser trison_parser)
add_custom_target(all_scanners DEPENDS barf_commonlang_scanner barf_preprocessor_scanner)
add_custom_target(all_thingies DEPENDS all_parsers all_scanners)
add_custom_target(force_all_parsers DEPENDS force_barf_preprocessor_parser force_barf_regex_parser force_barf_targetspec_parser force_reflex_parser trison_parser)
add_custom_target(force_all_scanners DEPENDS force_barf_commonlang_scanner force_barf_preprocessor_scanner)
add_custom_target(force_all_thingies DEPENDS force_all_parsers force_all_scanners)
add_custom_target(clean_all_parsers DEPENDS clean_barf_preprocessor_parser clean_barf_regex_parser clean_barf_targetspec_parser clean_reflex_parser clean_trison_parser)
add_custom_target(clean_all_scanners DEPENDS clean_barf_commonlang_scanner clean_barf_preprocessor_scanner)
add_custom_target(clean_all_thingies DEPENDS clean_all_parsers clean_all_scanners)
add_custom_target(all_parser_dot_pngs DEPENDS barf_preprocessor_parser_dot_png barf_regex_parser_dot_png barf_targetspec_parser_dot_png reflex_parser_dot_png trison_parser_dot_png)
add_custom_target(all_parser_npda_pngs DEPENDS barf_preprocessor_parser_npda_png barf_regex_parser_npda_png barf_targetspec_parser_npda_png reflex_parser_npda_png trison_parser_npda_png)
add_custom_target(all_scanner_dfa_pngs DEPENDS barf_commonlang_scanner_dfa_png barf_preprocessor_scanner_dfa_png)
add_custom_target(all_scanner_nfa_pngs DEPENDS barf_commonlang_scanner_nfa_png barf_preprocessor_scanner_nfa_png)
add_custom_target(all_scanner_dot_pngs DEPENDS barf_commonlang_scanner_dot_png barf_preprocessor_scanner_dot_png)
add_custom_target(all_thingy_dot_pngs DEPENDS all_parser_dot_pngs all_scanner_dot_pngs)
add_custom_target(clean_all_parser_dot_pngs DEPENDS clean_barf_preprocessor_parser_dot_png clean_barf_regex_parser_dot_png clean_barf_targetspec_parser_dot_png clean_reflex_parser_dot_png clean_trison_parser_dot_png)
add_custom_target(clean_all_parser_npda_pngs DEPENDS clean_barf_preprocessor_parser_npda_png clean_barf_regex_parser_npda_png clean_barf_targetspec_parser_npda_png clean_reflex_parser_npda_png clean_trison_parser_npda_png)
add_custom_target(clean_all_scanner_dfa_pngs DEPENDS clean_barf_commonlang_scanner_dfa_png clean_barf_preprocessor_scanner_dfa_png)
add_custom_target(clean_all_scanner_nfa_pngs DEPENDS clean_barf_commonlang_scanner_nfa_png clean_barf_preprocessor_scanner_nfa_png)
add_custom_target(clean_all_scanner_dot_pngs DEPENDS clean_barf_commonlang_scanner_dot_png clean_barf_preprocessor_scanner_dot_png)
add_custom_target(clean_all_thingy_dot_pngs DEPENDS clean_all_parser_dot_pngs clean_all_scanner_dot_pngs)
endif()
# dev related helper targets
if(TRUE)
add_custom_target(all_dev_parsers DEPENDS dev_barf_preprocessor_parser dev_barf_regex_parser dev_barf_targetspec_parser dev_reflex_parser dev_trison_parser)
add_custom_target(all_dev_scanners DEPENDS dev_barf_commonlang_scanner dev_barf_preprocessor_scanner)
add_custom_target(all_dev_thingies DEPENDS all_dev_parsers all_dev_scanners)
add_custom_target(diff_all_dev_parsers DEPENDS diff_dev_barf_preprocessor_parser diff_dev_barf_regex_parser diff_dev_barf_targetspec_parser diff_dev_reflex_parser diff_dev_trison_parser)
add_custom_target(diff_all_dev_scanners DEPENDS diff_dev_barf_commonlang_scanner diff_dev_barf_preprocessor_scanner)
add_custom_target(diff_all_dev_thingies DEPENDS diff_all_dev_parsers diff_all_dev_scanners)
add_custom_target(clean_dev_bpp COMMAND rm -f ${PROJECT_BINARY_DIR}/bin/dev_bpp)
add_custom_target(clean_dev_reflex COMMAND rm -f ${PROJECT_BINARY_DIR}/bin/dev_reflex)
add_custom_target(clean_dev_trison COMMAND rm -f ${PROJECT_BINARY_DIR}/bin/dev_trison)
add_custom_target(clean_all_dev_parsers DEPENDS clean_dev_barf_preprocessor_parser clean_dev_barf_regex_parser clean_dev_barf_targetspec_parser clean_dev_reflex_parser clean_dev_trison_parser)
add_custom_target(clean_all_dev_scanners DEPENDS clean_dev_barf_commonlang_scanner clean_dev_barf_preprocessor_scanner)
add_custom_target(clean_all_dev_thingies DEPENDS clean_all_dev_parsers clean_all_dev_scanners)
add_custom_target(all_dev_parser_dot_pngs DEPENDS dev_barf_preprocessor_parser_dot_png dev_barf_regex_parser_dot_png dev_barf_targetspec_parser_dot_png dev_reflex_parser_dot_png dev_trison_parser_dot_png)
add_custom_target(all_dev_parser_npda_pngs DEPENDS dev_barf_preprocessor_parser_npda_png dev_barf_regex_parser_npda_png dev_barf_targetspec_parser_npda_png dev_reflex_parser_npda_png dev_trison_parser_npda_png)
add_custom_target(all_dev_scanner_dfa_pngs DEPENDS dev_barf_commonlang_scanner_dfa_png dev_barf_preprocessor_scanner_dfa_png)
add_custom_target(all_dev_scanner_nfa_pngs DEPENDS dev_barf_commonlang_scanner_nfa_png dev_barf_preprocessor_scanner_nfa_png)
add_custom_target(all_dev_scanner_dot_pngs DEPENDS dev_barf_commonlang_scanner_dot_png dev_barf_preprocessor_scanner_dot_png)
add_custom_target(all_dev_thingy_dot_pngs DEPENDS all_dev_parser_dot_pngs all_dev_scanner_dot_pngs)
add_custom_target(clean_all_dev_parser_dot_pngs DEPENDS clean_dev_barf_preprocessor_parser_dot_png clean_dev_barf_regex_parser_dot_png clean_dev_barf_targetspec_parser_dot_png clean_dev_reflex_parser_dot_png clean_dev_trison_parser_dot_png)
add_custom_target(clean_all_dev_parser_npda_pngs DEPENDS clean_dev_barf_preprocessor_parser_npda_png clean_dev_barf_regex_parser_npda_png clean_dev_barf_targetspec_parser_npda_png clean_dev_reflex_parser_npda_png clean_dev_trison_parser_npda_png)
add_custom_target(clean_all_dev_scanner_dfa_pngs DEPENDS clean_dev_barf_commonlang_scanner_dfa_png clean_dev_barf_preprocessor_scanner_dfa_png)
add_custom_target(clean_all_dev_scanner_nfa_pngs DEPENDS clean_dev_barf_commonlang_scanner_nfa_png clean_dev_barf_preprocessor_scanner_nfa_png)
add_custom_target(clean_all_dev_scanner_dot_pngs DEPENDS clean_dev_barf_commonlang_scanner_dot_png clean_dev_barf_preprocessor_scanner_dot_png)
add_custom_target(clean_all_dev_thingy_dot_pngs DEPENDS clean_all_dev_parser_dot_pngs clean_all_dev_scanner_dot_pngs)
add_custom_target(clean_all_dev DEPENDS clean_dev_reflex clean_dev_trison clean_dev_bpp clean_all_dev_thingies)
# metadev related helper targets
add_custom_target(all_metadev_parsers DEPENDS metadev_barf_preprocessor_parser metadev_barf_regex_parser metadev_barf_targetspec_parser metadev_reflex_parser metadev_trison_parser)
add_custom_target(all_metadev_scanners DEPENDS metadev_barf_commonlang_scanner metadev_barf_preprocessor_scanner)
add_custom_target(all_metadev_thingies DEPENDS all_metadev_parsers all_metadev_scanners)
add_custom_target(diff_all_metadev_parsers DEPENDS diff_metadev_barf_preprocessor_parser diff_metadev_barf_regex_parser diff_metadev_barf_targetspec_parser diff_metadev_reflex_parser diff_metadev_trison_parser)
add_custom_target(diff_all_metadev_scanners DEPENDS diff_metadev_barf_commonlang_scanner diff_metadev_barf_preprocessor_scanner)
add_custom_target(diff_all_metadev_thingies DEPENDS diff_all_metadev_parsers diff_all_metadev_scanners)
add_custom_target(clean_all_metadev_parsers DEPENDS clean_metadev_barf_preprocessor_parser clean_metadev_barf_regex_parser clean_metadev_barf_targetspec_parser clean_metadev_reflex_parser clean_metadev_trison_parser)
add_custom_target(clean_all_metadev_scanners DEPENDS clean_metadev_barf_commonlang_scanner clean_metadev_barf_preprocessor_scanner)
add_custom_target(clean_all_metadev_thingies DEPENDS clean_all_metadev_parsers clean_all_metadev_scanners)
add_custom_target(all_metadev_parser_dot_pngs DEPENDS metadev_barf_preprocessor_parser_dot_png metadev_barf_regex_parser_dot_png metadev_barf_targetspec_parser_dot_png metadev_reflex_parser_dot_png metadev_trison_parser_dot_png)
add_custom_target(all_metadev_parser_npda_pngs DEPENDS metadev_barf_preprocessor_parser_npda_png metadev_barf_regex_parser_npda_png metadev_barf_targetspec_parser_npda_png metadev_reflex_parser_npda_png metadev_trison_parser_npda_png)
add_custom_target(all_metadev_scanner_dfa_pngs DEPENDS metadev_barf_commonlang_scanner_dfa_png metadev_barf_preprocessor_scanner_dfa_png)
add_custom_target(all_metadev_scanner_nfa_pngs DEPENDS metadev_barf_commonlang_scanner_nfa_png metadev_barf_preprocessor_scanner_nfa_png)
add_custom_target(all_metadev_scanner_dot_pngs DEPENDS metadev_barf_commonlang_scanner_dot_png metadev_barf_preprocessor_scanner_dot_png)
add_custom_target(all_metadev_thingy_dot_pngs DEPENDS all_metadev_parser_dot_pngs all_metadev_scanner_dot_pngs)
add_custom_target(clean_all_metadev_parser_dot_pngs DEPENDS clean_metadev_barf_preprocessor_parser_dot_png clean_metadev_barf_regex_parser_dot_png clean_metadev_barf_targetspec_parser_dot_png clean_metadev_reflex_parser_dot_png clean_metadev_trison_parser_dot_png)
add_custom_target(clean_all_metadev_parser_npda_pngs DEPENDS clean_metadev_barf_preprocessor_parser_npda_png clean_metadev_barf_regex_parser_npda_png clean_metadev_barf_targetspec_parser_npda_png clean_metadev_reflex_parser_npda_png clean_metadev_trison_parser_npda_png)
add_custom_target(clean_all_metadev_scanner_dfa_pngs DEPENDS clean_metadev_barf_commonlang_scanner_dfa_png clean_metadev_barf_preprocessor_scanner_dfa_png)
add_custom_target(clean_all_metadev_scanner_nfa_pngs DEPENDS clean_metadev_barf_commonlang_scanner_nfa_png clean_metadev_barf_preprocessor_scanner_nfa_png)
add_custom_target(clean_all_metadev_scanner_dot_pngs DEPENDS clean_metadev_barf_commonlang_scanner_dot_png clean_metadev_barf_preprocessor_scanner_dot_png)
add_custom_target(clean_all_metadev_thingy_dot_pngs DEPENDS clean_all_metadev_parser_dot_pngs clean_all_metadev_scanner_dot_pngs)
add_custom_target(clean_all_metadev DEPENDS clean_all_metadev_thingies)
# This is necessary because clean is not a first class target in cmake.
add_custom_target(clean_all_dev_and_metadev DEPENDS clean_all_dev clean_all_metadev)
endif()
###############################################################################
# Testing targets
###############################################################################
# Note that this doesn't explicitly depend on the ${PROJECT_BINARY_DIR}/bin/reflex
# or ${PROJECT_BINARY_DIR}/bin/trison binaries. This is done so that building
# of those binaries can be done independently of running of the various dev
# and metadev targets, including this one. This ability is crucial to have
# during certain development in order to keep the ability to bootstrap reflex
# and trison.
add_custom_target(
metadev_check
DEPENDS dev_reflex dev_trison
COMMAND +make diff_all_metadev_thingies
COMMAND echo ""
COMMAND echo ""
COMMAND echo "Target metadev_check succeeded -- all dev and metadev files are identical."
COMMAND echo ""
COMMAND echo ""
)
###############################################################################
# Dependency graph visualization
###############################################################################
add_custom_target(
dependency_graph
COMMAND mkdir -p dependency_graph
COMMAND cmake --graphviz=dependency_graph/dep.dot ${PROJECT_BINARY_DIR}
COMMAND dot dependency_graph/dep.dot -Tpng -o dependency_graph/dep.png
)
###############################################################################
# CPack rules for creating distributions
###############################################################################
# Reference: https://github.com/geoffmcl/cpack-test
if(WIN32)
if(USE_WIX_TOOLSET)
set(CPACK_GENERATOR "WIX") # this need WiX Tooset installed and a path to candle.exe
else ()
set(CPACK_GENERATOR "NSIS") # this needs NSIS installed, and available
endif ()
set(CPACK_SOURCE_GENERATOR "ZIP")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CPACK_GENERATOR "PackageMake")
else()
set(CPACK_GENERATOR "DEB")
set(CPACK_SOURCE_GENERATOR "TGZ")
endif()
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Victor Dods")
# NOTE: Normally setting barf_VERSION_MAJOR, MINOR, PATCH would go here, but for some reason,
# barf_VERSION is being set to the empty string somewhere between the beginning of this file
# and here. So it's moved up to the top.
set(CPACK_PACKAGE_VERSION "${barf_VERSION_MAJOR}.${barf_VERSION_MINOR}.${barf_VERSION_PATCH}")
set(CPACK_PACKAGE_VERSION_MAJOR "${barf_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${barf_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${barf_VERSION_PATCH}")
# set(CPACK_PACKAGE_DESCRIPTION_FILE "${PROJECT_SOURCE_DIR}/README.html")
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_RESOURCE_FILE_README "${PROJECT_SOURCE_DIR}/README.md")
# set(CPACK_RESOURCE_FILE_WELCOME "${PROJECT_SOURCE_DIR}/README.html")
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${barf_VERSION}")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${PROJECT_NAME}-${barf_VERSION}")
set(CPACK_SOURCE_IGNORE_FILES "${PROJECT_SOURCE_DIR}/build/;${PROJECT_SOURCE_DIR}/.git/;${PROJECT_SOURCE_DIR}/.gitignore;${PROJECT_SOURCE_DIR}/barf.kdev4;${PROJECT_SOURCE_DIR}/.kdev4;${PROJECT_SOURCE_DIR}/dev/calc/build/;${PROJECT_SOURCE_DIR}/test/build/")
include(CPack)