-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
38 lines (31 loc) · 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
cmake_minimum_required(VERSION 3.0)
project(mewmew)
find_package(Java COMPONENTS Runtime REQUIRED)
if(NOT ANTLR_EXE)
set(ANTLR_EXE
/usr/local/lib/antlr-4.8-complete.jar
)
endif()
if(NOT ANTLR_LIB)
set(ANTLR_LIB
/usr/local/lib/libantlr4-runtime.a
)
endif()
set(grammar-src ${PROJECT_SOURCE_DIR}/mewmew.g4)
set(antlr4-outlib
${PROJECT_SOURCE_DIR}/mewlib/mewmewLexer.cpp
${PROJECT_SOURCE_DIR}/mewlib/mewmewParser.cpp
${PROJECT_SOURCE_DIR}/mewlib/mewmewBaseVisitor.cpp
${PROJECT_SOURCE_DIR}/mewlib/mewmewVisitor.cpp
)
add_custom_command(OUTPUT ${antlr4-outlib}
COMMAND ${Java_JAVA_EXECUTABLE} -jar ${ANTLR_EXE} ${grammar-src} -Dlanguage=Cpp -no-listener -visitor -o mewlib
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
DEPENDS ${grammar-src}
)
ADD_CUSTOM_TARGET(GenParser ALL
DEPENDS ${antlr4-outlib}
)
add_executable(mewmew ${antlr4-outlib} ${PROJECT_SOURCE_DIR}/main.cpp)
ADD_DEPENDENCIES(mewmew GenParser)
target_link_libraries(mewmew ${ANTLR_LIB})