91 lines
3 KiB
Diff
91 lines
3 KiB
Diff
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)
|
|
|