-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
56 lines (50 loc) · 1.78 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
cmake_minimum_required(VERSION 3.6)
project(coco_to_antlr)
# TODO: test finding & using coco on windows
find_program(COCO NAMES cococpp Coco.exe HINTS .. )
if(NOT COCO)
message(FATAL_ERROR "Coco/R executable not found")
endif()
set(COCO_FRAME_DIR /home/azrael/Job/OCX_Parser/coco/coco_frame_files)
message("frames at ${COCO_FRAME_DIR}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings")
set(CMAKE_CXX_STANDARD 14)
set(GRAMMAR_FILE ${CMAKE_CURRENT_SOURCE_DIR}/coco_to_antlr.atg)
set(generated_source_files
${CMAKE_CURRENT_BINARY_DIR}/Scanner.cpp
${CMAKE_CURRENT_BINARY_DIR}/Scanner.h
${CMAKE_CURRENT_BINARY_DIR}/Parser.cpp
${CMAKE_CURRENT_BINARY_DIR}/Parser.h
)
set_source_files_properties(${generated_source_files} PROPERTIES GENERATED TRUE)
set(SOURCE_FILES
CocoAstMain.cpp
CocoAstMain.h
CocoAST.cpp
CocoAST.h
CocoAstVisitor.cpp
CocoAstVisitor.h
AntlrOptimizer.cpp
AntlrOptimizer.h
SymbolResolver.cpp
SymbolResolver.h
CodeGenerator.cpp
CodeGenerator.h
main.cpp
common.h
${generated_source_files}
)
# generate using Coco
add_custom_command(
OUTPUT ${generated_source_files}
COMMAND ${COCO} ${GRAMMAR_FILE} -namespace coco_to_antlr -frames ${COCO_FRAME_DIR} -o ${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Generating Parser from ${GRAMMAR_FILE} with ${COCO}"
DEPENDS ${COCO_FRAME_DIR}/Scanner.frame
DEPENDS ${COCO_FRAME_DIR}/Parser.frame
MAIN_DEPENDENCY ${GRAMMAR_FILE}
DEPENDS ${COCO}
BYPRODUCTS trace.txt
)
include_directories ( "${CMAKE_CURRENT_SOURCE_DIR}" )
add_executable(coco_to_antlr ${SOURCE_FILES})
target_include_directories (coco_to_antlr PRIVATE "${CMAKE_CURRENT_BINARY_DIR}" )