summaryrefslogtreecommitdiff
path: root/dev-lang/gdl/files/0.9.5-antlr.patch
blob: f5b627ab444ea18d831119c963e8eeace2c4de8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
 CMakeLists.txt               | 14 +++++++++++---
 CMakeModules/FindANTLR.cmake | 11 +++++++++++
 src/CMakeLists.txt           | 18 +++++++++++-------
 3 files changed, 33 insertions(+), 10 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 407e39a..c4b3278 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -111,6 +111,8 @@ set(SZIPDIR "" CACHE PATH "GDL: Specify the SZip directory tree")
 
 set(GDL_DATA_DIR "/share/gnudatalanguage" CACHE PATH "GDL: data directory relative to CMAKE_INSTALL_PREFIX")
 
+set(BUNDLED_ANTLR OFF CACHE BOOL "Use bundled ANTLR grammar ?")
+set(ANTLRDIR "" CACHE PATH "Specify the system ANTLR directory tree")
 
 # check for 64-bit OS
 if(${CMAKE_SIZEOF_VOID_P} EQUAL 8)
@@ -174,9 +176,15 @@ check_library_exists(m nexttoward "" HAVE_NEXTTOWARD)
 # mpi
 check_include_file(mpi.h HAVE_MPI_H)
 
-# SA: whithout it compilation of antlr fails if there's a conflicting 
-#     version of antlr in system-wide directories
-include_directories(src)
+if(BUNDLED_ANTLR)
+  # SA: whithout it compilation of antlr fails if there's a conflicting 
+  #     version of antlr in system-wide directories
+  include_directories(src)
+else(BUNDLED_ANTLR)
+  find_package(ANTLR QUIET)
+  set(LIBRARIES ${LIBRARIES} ${ANTLR_LIBRARIES})
+  include_directories(${ANTLR_INCLUDE_DIR})
+endif(BUNDLED_ANTLR)
 
 if(WIN32 AND NOT CYGWIN)
 	# For Win32 find Pdcureses instead of (N)Curses
diff --git a/CMakeModules/FindANTLR.cmake b/CMakeModules/FindANTLR.cmake
new file mode 100644
index 0000000..b61cc5b
--- /dev/null
+++ b/CMakeModules/FindANTLR.cmake
@@ -0,0 +1,11 @@
+
+
+find_library(ANTLR_LIBRARIES NAMES antlr)
+find_path(ANTLR_INCLUDE_DIR NAMES antlr/ANTLRUtil.hpp)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ANTLR DEFAULT_MSG ANTLR_LIBRARIES ANTLR_INCLUDE_DIR)
+
+mark_as_advanced(
+ANTLR_LIBRARIES
+ANTLR_INCLUDE_DIR
+)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1f7ffec..776a1fd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -262,9 +262,8 @@ widget.cpp
 widget.hpp
 )
 
-add_subdirectory(antlr)
 
-include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_SOURCE_DIR}/src/antlr ${CMAKE_BINARY_DIR})
+include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src ${CMAKE_BINARY_DIR})
 link_directories(${LINK_DIRECTORIES})
 
 if(PYTHON_MODULE) #libgdl
@@ -275,11 +274,16 @@ else(PYTHON_MODULE) #gdl
 	add_executable(gdl ${SOURCES})
 endif(PYTHON_MODULE)
 
-add_dependencies(gdl antlr) # be sure that antlr is built before gdl
-target_link_libraries(gdl antlr) # link antlr against gdl
-if (MINGW)
-target_link_libraries(gdl ws2_32)
-endif (MINGW)
+if(BUNDLED_ANTLR)
+  add_subdirectory(antlr)
+  include_directories(${CMAKE_SOURCE_DIR}/src/antlr)
+  add_dependencies(gdl antlr) # be sure that antlr is built before gdl
+  target_link_libraries(gdl antlr) # link antlr against gdl
+  if (MINGW)
+    target_link_libraries(gdl ws2_32)
+  endif (MINGW)
+endif(BUNDLED_ANTLR)
+
 target_link_libraries(gdl ${LIBRARIES})
 add_definitions(-DHAVE_CONFIG_H)