This repository was archived by the owner on Jun 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
54 lines (42 loc) · 1.86 KB
/
CMakeLists.txt
File metadata and controls
54 lines (42 loc) · 1.86 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
cmake_minimum_required(VERSION 3.10)
project(compiler)
# compile flags
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_FLAGS "-g") # 调试信息
set(CMAKE_CXX_FLAGS "-Wall") # 开启所有警告
# debug flags
# add_definitions(-DDEBUG_DFA)
# add_definitions(-DDEBUG_SCANNER)
# add_definitions(-DDEBUG_PARSER)
# output settings
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
set(CMAKE_C_COMPILER "/usr/bin/x86_64-linux-gnu-gcc-7")
set(CMAKE_CXX_COMPILER "/usr/bin/x86_64-linux-gnu-g++-7")
# include
include_directories(./include)
# third party libs
add_library(jsoncpp ./src/third_party/jsoncpp/jsoncpp.cpp)
# --------------------- from lib ---------------------
# link libxx.a
# u should rename libxx-x86-win.a or libxx-x86-linux.a to libxx.a according to ur own platform
link_directories(./lib)
# --------------------- from lib ---------------------
# build library
# every src file directory should be compile into a lib
aux_source_directory(./src/front FRONT_SRC)
add_library(Front ${FRONT_SRC})
aux_source_directory(./src/backend BACKEND_SRC)
add_library(Backend ${BACKEND_SRC})
# 为了 debug 方便,你可以选择通过源文件来构建 IR 测评机,但是请以链接静态库文件的方式去跑分(为了防止你们修改测评机,在OJ上我们会采取此方式)
# --------------------- from src ---------------------
# aux_source_directory(./src/ir IR_SRC)
# add_library(IR ${IR_SRC})
# aux_source_directory(./src/tools TOOLS_SRC)
# add_library(Tools ${TOOLS_SRC})
# --------------------- from src ---------------------
# executable
add_executable(compiler main.cpp)
# link
# every lib should be linked with [compiler]
target_link_libraries(compiler Backend Front jsoncpp Tools-x86-linux IR-x86-linux)