cmake: FindANTLR: Check if antlr3FileStreamNew is available.
authorMathias Preiner <mathias.preiner@gmail.com>
Sat, 15 Sep 2018 00:23:30 +0000 (17:23 -0700)
committerMathias Preiner <mathias.preiner@gmail.com>
Sat, 22 Sep 2018 23:30:59 +0000 (16:30 -0700)
cmake/FindANTLR.cmake
src/parser/CMakeLists.txt

index 79d38854e7a1b760f41c358176c4c79af68ab599..1356680061ae8a8836663a404e4723940f24c874 100644 (file)
@@ -32,8 +32,19 @@ if(CHECK_SYSTEM_VERSION)
   find_library(ANTLR_LIBRARIES NAMES antlr3c)
 endif()
 
+# Check if antlr3FileStreamNew is available. If not we have to
+# define CVC4_ANTLR3_OLD_INPUT_STREAM (src/parser/CMakeLists.txt).
+if(ANTLR_INCLUDE_DIR)
+  include(CheckSymbolExists)
+  set(CMAKE_REQUIRED_INCLUDES ${ANTLR_INCLUDE_DIR})
+  set(CMAKE_REQUIRED_LIBRARIES ${ANTLR_LIBRARIES})
+  check_symbol_exists(
+    antlr3FileStreamNew "antlr3defs.h" HAVE_ANTLR3_FILE_STREAM_NEW)
+endif()
+
 include(FindPackageHandleStandardArgs)
 find_package_handle_standard_args(
   ANTLR DEFAULT_MSG ANTLR_BINARY ANTLR_INCLUDE_DIR ANTLR_LIBRARIES)
 
-mark_as_advanced(ANTLR_BINARY ANTLR_INCLUDE_DIR ANTLR_LIBRARIES)
+mark_as_advanced(ANTLR_BINARY ANTLR_INCLUDE_DIR ANTLR_LIBRARIES
+                 HAVE_ANTLR3_FILE_STREAM_NEW)
index d78068f6b22a8c119aa32704c259ff800f16caec..389ebd814aa6e8b313b641ababad009a0568bbef 100644 (file)
@@ -1,6 +1,10 @@
 set(ANTLR_HOME ${ANTLR_DIR})
 find_package(ANTLR REQUIRED)
 
+if(NOT HAVE_ANTLR3_FILE_STREAM_NEW)
+  add_definitions(-DCVC4_ANTLR3_OLD_INPUT_STREAM)
+endif()
+
 # Java runtime is required for ANTLR
 find_package(Java COMPONENTS Runtime REQUIRED)