aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/antlr.cmake
diff options
context:
space:
mode:
authorzhukoff-pavel <zhukoff-pavel@yandex-team.com>2023-09-20 17:06:39 +0300
committerzhukoff-pavel <zhukoff-pavel@yandex-team.com>2023-09-20 17:59:17 +0300
commit82a23bf3bafa4db2bbb68ea7a068748f63fafe43 (patch)
tree10be37bd21083bf0e63069f01380ffd12304c07d /cmake/antlr.cmake
parent4ff5e7686bfb04ea92f237fc5e044c15456237e1 (diff)
downloadydb-82a23bf3bafa4db2bbb68ea7a068748f63fafe43.tar.gz
Revert commit rXXXXXX,Move antlr3 to contrib/
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()