You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

73 lines
2.4 KiB

3 months ago
  1. find_program(MAVEN mvn)
  2. if(NOT MAVEN)
  3. message(SEND_ERROR "Can not build ANTLR4, missing binary for maven")
  4. endif()
  5. find_path(UUID_PATH NAMES uuid/uuid.h)
  6. if(NOT UUID_PATH)
  7. message(WARNING "Building ANTLR4 C++ runtime will probably fail, could not find uuid.h")
  8. endif()
  9. ExternalProject_Add(
  10. ANTLR
  11. GIT_REPOSITORY "https://github.com/volkm/antlr4.git"
  12. #GIT_TAG "${ANTLR_VERSION}"
  13. GIT_TAG "rpath_fix"
  14. BUILD_IN_SOURCE 1
  15. UPDATE_COMMAND ""
  16. CONFIGURE_COMMAND ""
  17. BUILD_COMMAND ""
  18. INSTALL_COMMAND ""
  19. )
  20. ExternalProject_Get_Property(ANTLR SOURCE_DIR)
  21. ExternalProject_Get_Property(ANTLR INSTALL_DIR)
  22. if (BUILD_JAR)
  23. ExternalProject_Add(
  24. ANTLR-jar
  25. EXCLUDE_FROM_ALL 1
  26. DOWNLOAD_COMMAND ""
  27. SOURCE_DIR "${SOURCE_DIR}"
  28. BUILD_IN_SOURCE 1
  29. UPDATE_COMMAND ""
  30. CONFIGURE_COMMAND mvn clean
  31. BUILD_COMMAND mvn -DskipTests package -pl tool -am
  32. INSTALL_COMMAND ""
  33. )
  34. endif()
  35. set(ANTLR-runtime_TARGETS "antlr4_shared")
  36. ExternalProject_Add(
  37. ANTLR-runtime
  38. DOWNLOAD_COMMAND ""
  39. SOURCE_DIR "${SOURCE_DIR}"
  40. UPDATE_COMMAND ""
  41. CONFIGURE_COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR} -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=ON -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX:PATH=<INSTALL_DIR> "<SOURCE_DIR>/runtime/Cpp" -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
  42. BUILD_COMMAND ${CMAKE_COMMAND} --build . --target antlr4_shared
  43. COMMAND ${CMAKE_COMMAND} --build . --target antlr4_static
  44. BUILD_BYPRODUCTS ${CMAKE_BINARY_DIR}/resources/lib/libantlr4-runtime${DYNAMIC_EXT}
  45. )
  46. ExternalProject_Get_Property(ANTLR-runtime INSTALL_DIR)
  47. file(MAKE_DIRECTORY "${INSTALL_DIR}/include")
  48. file(MAKE_DIRECTORY "${INSTALL_DIR}/include/antlr4-runtime")
  49. add_library(antlr4shared SHARED IMPORTED GLOBAL)
  50. set_target_properties(antlr4shared PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libantlr4-runtime${DYNAMIC_EXT})
  51. set_target_properties(antlr4shared PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include;${INSTALL_DIR}/include/antlr4-runtime")
  52. add_library(antlr4static STATIC IMPORTED GLOBAL)
  53. set_target_properties(antlr4static PROPERTIES IMPORTED_LOCATION ${INSTALL_DIR}/lib/libantlr4-runtime${STATIC_EXT})
  54. set_target_properties(antlr4static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${INSTALL_DIR}/include;${INSTALL_DIR}/include/antlr4-runtime")
  55. if (USE_SHIPPED_JAR)
  56. add_dependencies(ANTLR-jar ANTLR)
  57. endif()
  58. add_dependencies(ANTLR-runtime ANTLR)
  59. add_dependencies(antlr4shared ANTLR-runtime)
  60. add_dependencies(antlr4static ANTLR-runtime)
  61. mark_as_advanced(MAVEN)