forked from 7asebat/S22-Compilers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
82 lines (67 loc) · 2.16 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
cmake_minimum_required(VERSION 3.20)
project(S22-Compilers LANGUAGES CXX)
add_subdirectory(thirdparty/imgui)
add_subdirectory(thirdparty/portable-file-dialogs-0.1.0)
get_target_property(IMGUI_SOURCES imgui INTERFACE_SOURCES)
get_target_property(IMGUI_INCLUDE_DIRS imgui INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(IMGUI_LINK_LIBS imgui INTERFACE_LINK_LIBRARIES)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
message("${IMGUI_INCLUDE_DIRS}")
include_directories(
${CMAKE_SOURCE_DIR}/compiler/include
${IMGUI_INCLUDE_DIRS}
)
link_libraries(${IMGUI_LINK_LIBS} portable_file_dialogs)
# Visual Studio hot reloading
if (MSVC AND WIN32 AND NOT MSVC_VERSION VERSION_LESS 142)
add_link_options($<$<CONFIG:Debug>:/INCREMENTAL>)
add_compile_options($<$<CONFIG:Debug>:/ZI>)
endif()
# Lexer output file
set(LEXER ${CMAKE_BINARY_DIR}/Lexer.cpp)
add_custom_command(
OUTPUT ${LEXER}
COMMAND flex -o ${LEXER} ${CMAKE_SOURCE_DIR}/compiler/Lexer.l
DEPENDS ${CMAKE_SOURCE_DIR}/compiler/Lexer.l
)
# Parser output file
set(PARSER ${CMAKE_BINARY_DIR}/Parser.cpp)
add_custom_command(
OUTPUT ${PARSER} ${CMAKE_BINARY_DIR}/Parser.hpp ${CMAKE_BINARY_DIR}/Parser.output
COMMAND bison -d -o ${PARSER} -v ${CMAKE_SOURCE_DIR}/compiler/Parser.y -Wcounterexamples
DEPENDS ${CMAKE_SOURCE_DIR}/compiler/Parser.y
)
set(COMPILER_SOURCE_FILES
compiler/src/compiler/AST.cpp
#compiler/src/compiler/Backend.cpp
compiler/src/compiler/Backend2.cpp
compiler/src/compiler/Symbol.cpp
compiler/src/compiler/Semantic_Expr.cpp
compiler/src/compiler/Parser.cpp
compiler/src/compiler/Window.cpp
compiler/src/compiler/main.cpp
)
set(COMPILER_HEADER_FILES
compiler/include/compiler/Util.h
compiler/include/compiler/AST.h
compiler/include/compiler/Backend.h
compiler/include/compiler/Symbol.h
compiler/include/compiler/Semantic_Expr.h
compiler/include/compiler/Parser.h
compiler/include/compiler/Window.h
)
# Main compiler
add_executable(compiler
${LEXER}
${PARSER}
${COMPILER_SOURCE_FILES}
${COMPILER_HEADER_FILES}
${IMGUI_SOURCES}
)
target_compile_definitions(compiler
PRIVATE
FONTS_DIR="${CMAKE_SOURCE_DIR}/thirdparty/fonts"
)
add_subdirectory(phase1)