antlr.cmake 882 B

12345678910111213141516171819202122232425262728293031
  1. function(ensure_antlr)
  2. if(NOT ANTLR3_EXECUTABLE)
  3. find_program(ANTLR3_EXECUTABLE
  4. NAMES antlr3)
  5. if (NOT ANTLR3_EXECUTABLE)
  6. message(FATAL_ERROR "Unable to find antlr3 program. Please install antlr3 and make sure executable file present in the $PATH env.")
  7. endif()
  8. endif()
  9. endfunction()
  10. function(run_antlr)
  11. ensure_antlr()
  12. set(options "")
  13. set(oneValueArgs WORKING_DIRECTORY)
  14. set(multiValueArgs OUTPUT DEPENDS ANTLER_ARGS)
  15. cmake_parse_arguments(
  16. RUN_ANTLR
  17. "${options}"
  18. "${oneValueArgs}"
  19. "${multiValueArgs}"
  20. ${ARGN}
  21. )
  22. add_custom_command(
  23. OUTPUT ${RUN_ANTLR_OUTPUT}
  24. COMMAND ${ANTLR3_EXECUTABLE} ${RUN_ANTLR_ANTLER_ARGS}
  25. WORKING_DIRECTORY ${RUN_ANTLR_WORKING_DIRECTORY}
  26. DEPENDS ${RUN_ANTLR_DEPENDS}
  27. )
  28. endfunction()