aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/antlr.cmake
diff options
context:
space:
mode:
authorarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-18 15:49:59 +0300
committerarcadia-devtools <arcadia-devtools@yandex-team.ru>2022-02-18 15:49:59 +0300
commitb4cb34dfb2619f594d82e512fd9ff7fc97400133 (patch)
tree6a64ab25a145265287789bceed3f59e953561206 /cmake/antlr.cmake
parent5e837a820d5be0671fa4096a1cc1e378453e5132 (diff)
downloadydb-b4cb34dfb2619f594d82e512fd9ff7fc97400133.tar.gz
intermediate changes
ref:1a0585d83f27cb6fb5b9c4f68a08177e10faf3b3
Diffstat (limited to 'cmake/antlr.cmake')
-rw-r--r--cmake/antlr.cmake31
1 files changed, 31 insertions, 0 deletions
diff --git a/cmake/antlr.cmake b/cmake/antlr.cmake
new file mode 100644
index 0000000000..d203fd9c88
--- /dev/null
+++ b/cmake/antlr.cmake
@@ -0,0 +1,31 @@
+function(ensure_antlr)
+ if(NOT ANTLR3_EXECUTABLE)
+ find_program(ANTLR3_EXECUTABLE
+ NAMES antlr3)
+ if (NOT ANTLR3_EXECUTABLE)
+ message(FATAL_ERROR "Unable to find antlr3 program. Please install antlr3 and make sure executable file present in the $PATH env.")
+ endif()
+ endif()
+endfunction()
+
+function(run_antlr)
+ ensure_antlr()
+ set(options "")
+ set(oneValueArgs WORKING_DIRECTORY)
+ set(multiValueArgs OUTPUT DEPENDS ANTLER_ARGS)
+ cmake_parse_arguments(
+ RUN_ANTLR
+ "${options}"
+ "${oneValueArgs}"
+ "${multiValueArgs}"
+ ${ARGN}
+ )
+
+ add_custom_command(
+ OUTPUT ${RUN_ANTLR_OUTPUT}
+ COMMAND ${ANTLR3_EXECUTABLE} ${RUN_ANTLR_ANTLER_ARGS}
+ WORKING_DIRECTORY ${RUN_ANTLR_WORKING_DIRECTORY}
+ DEPENDS ${RUN_ANTLR_DEPENDS}
+ )
+
+endfunction()