-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
162 lines (134 loc) · 3.11 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
cmake_minimum_required(VERSION 3.13)
project(jcc C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(
SOURCE_FILES
src/main.c
src/args.c
src/util.c
src/vector.c
src/hashtbl.c
src/deque.c
src/hash.c
src/bitset.c
src/profile.c
src/alloc.c
src/log.c
src/graphwriter.c
src/ap_val.c
src/compiler.c
src/diagnostics.c
src/builtins.c
src/lex.c
src/io.c
src/parse.c
src/preproc.c
src/program.c
src/lower.c
src/liveness.c
src/disasm.c
src/codegen.c
src/var_table.c
src/typechk.c
src/lsra.c
src/graphcol.c
src/
src/ir/ir.c
src/ir/build.c
src/ir/var_refs.c
src/ir/eliminate_phi.c
src/ir/prettyprint.c
src/ir/validate.c
src/ir/rw.c
src/opts/opts.c
src/opts/cnst_fold.c
src/opts/cnst_branches.c
src/opts/instr_comb.c
src/opts/promote.c
src/opts/inline.c
src/aarch64.c
src/aarch64/codegen.c
src/aarch64/lower.c
src/aarch64/emit.c
src/aarch64/emitter.c
src/x64.c
src/x64/codegen.c
src/x64/lower.c
src/x64/emit.c
src/x64/emitter.c
src/rv32i.c
src/rv32i/codegen.c
src/rv32i/lower.c
src/rv32i/emit.c
src/rv32i/emitter.c
src/rv32i/object.c
# eep.c
# eep/codegen.c
# eep/lower.c
# eep/emit.c
# eep/emitter.c
# eep/object.c
# eep/disasm.c
src/macos/mach-o.c
src/macos/link.c
src/linux/elf.c
src/linux/link.c
)
# build for all platforms (support cross compilation)
# TODO: add a more granular system for including targets
add_definitions(-DJCC_ALL)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(STATUS "Debug build detected")
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
message(WARNING "Debug mode may be VERY SLOW on GCC due to ASan problems - Clang w/ ASan is significantly faster")
endif()
add_link_options(-fsanitize=address,undefined)
add_compile_options(-fsanitize=address,undefined -fno-sanitize-recover=all)
add_compile_options(-g)
add_link_options(-g3 -ldl)
add_link_options(-rdynamic)
endif()
if(MSVC)
add_compile_option(/W4 /WX)
elseif(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
message(STATUS "Building with AppleClang")
add_compile_options(
-Wall
-Wextra
-Wpedantic
-Weverything
-Wno-error=unreachable-code
-Wzero-as-null-pointer-constant
-Wbool-conversion
-Wmissing-prototypes
-Wsign-conversion
-Wimplicit-fallthrough
-Wstrict-prototypes
-Wmissing-field-initializers
# i would _like_ to enable this, but it causes errors everywhere flag enums are used
-Wno-sign-conversion
-Wno-missing-noreturn
-Wno-unused-macros
-Wno-switch-enum
-Wno-bad-function-cast
-Wno-undef
-Wno-padded
-Wno-declaration-after-statement
-Wno-class-varargs
-Wno-conditional-uninitialized
-Wno-shorten-64-to-32
-Wno-assign-enum
# TODO: remove binary literals in source
-Wno-gnu-binary-literal
)
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
# nothing for now
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU")
# nothing for now
else()
message(WARNING "Unknown compiler: ${CMAKE_C_COMPILER_ID}")
endif()
add_executable(jcc ${SOURCE_FILES})
target_link_libraries(jcc m)