antlr.cmake 866 B

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