forked from scp-fs2open/fs2open.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
51 lines (40 loc) · 1.75 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
function(add_parser filename)
get_filename_component(_name "${filename}" NAME_WE)
get_filename_component(_absolutePath "${filename}" ABSOLUTE)
get_filename_component(_directory "${_absolutePath}" DIRECTORY)
get_filename_component(_directoryName "${_directory}" NAME)
if (ANTLR_FOUND)
antlr_target(${_name} "${_absolutePath}"
VISITOR
OUTPUT_DIRECTORY "${_directory}/generated")
target_sources(parsers PRIVATE "${_absolutePath}")
source_group("${_directoryName}" FILES "${_absolutePath}")
else()
# Otherwise we just use the ones that are checked in
set(ANTLR_${_name}_OUTPUTS
${_directory}/generated/${_name}BaseVisitor.cpp
${_directory}/generated/${_name}BaseVisitor.h
${_directory}/generated/${_name}Lexer.cpp
${_directory}/generated/${_name}Lexer.h
${_directory}/generated/${_name}Parser.cpp
${_directory}/generated/${_name}Parser.h
${_directory}/generated/${_name}Visitor.cpp
${_directory}/generated/${_name}Visitor.h
)
endif()
target_sources(parsers PRIVATE ${ANTLR_${_name}_OUTPUTS})
source_group("${_directoryName}\\generated" FILES ${ANTLR_${_name}_OUTPUTS})
endfunction()
add_library(parsers STATIC)
target_link_libraries(parsers PUBLIC antlr4_static)
find_package(ANTLR)
if (ANTLR_FOUND)
# If we have an ANTLR installation then we can generate new sources
message(STATUS "Using ANTLR to generate parser")
else()
message(STATUS "Using generated ANTLR files")
endif()
add_parser(arg_parser/ArgumentList.g4)
add_parser(action_expression/ActionExpression.g4)
target_include_directories(parsers PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
suppress_warnings(parsers)