1commit 286b9c6e69691292dce4f2b4beaac8f886da184d
2Author: sternenseemann <sternenseemann@systemli.org>
3Date: Tue Oct 5 18:16:10 2021 +0200
4
5 Link against system antlr4 runtime, dynamically
6
7 Instead of cloning a antlr4 version from git, use the system one. Also
8 don't link it statically, but dynamically by default (the library is
9 called antlr4-runtime, not antlr4_static).
10
11diff --git a/CMakeLists.txt b/CMakeLists.txt
12index 9ce80598..a75b6fb1 100644
13--- a/CMakeLists.txt
14+++ b/CMakeLists.txt
15@@ -36,11 +36,11 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
16 # https://www.antlr.org/download/antlr4-cpp-runtime-4.9.3-source.zip
17 # set(ANTLR4_ZIP_REPOSITORY "/path_to_antlr4_archive/a4.zip")
18
19-add_definitions(-DANTLR4CPP_STATIC)
20 set(ANTLR4_WITH_STATIC_CRT OFF)
21 # 4.9.3 is the latest ANTLR4 version
22 set(ANTLR4_TAG tags/4.9.3)
23-include(ExternalAntlr4Cpp)
24+find_path(ANTLR4_HEADER antlr4-runtime.h PATH_SUFFIXES antlr4-runtime)
25+set(ANTLR4_INCLUDE_DIRS ${ANTLR4_HEADER})
26
27 FIND_PACKAGE(LibXml2)
28 IF (NOT ${LibXml2_FOUND})
29diff --git a/c/makeotf/lib/cffread/CMakeLists.txt b/c/makeotf/lib/cffread/CMakeLists.txt
30index 9a400fde..5452d987 100644
31--- a/c/makeotf/lib/cffread/CMakeLists.txt
32+++ b/c/makeotf/lib/cffread/CMakeLists.txt
33@@ -13,6 +13,6 @@ else ()
34 endif()
35 endif()
36
37-target_link_libraries(makeotf_cffread PUBLIC antlr4_static)
38+target_link_libraries(makeotf_cffread PUBLIC antlr4-runtime)
39
40 target_compile_definitions(makeotf_cffread PRIVATE $<$<CONFIG:Debug>:CFF_DEBUG=1> CFF_T13_SUPPORT=0)
41diff --git a/c/makeotf/lib/hotconv/CMakeLists.txt b/c/makeotf/lib/hotconv/CMakeLists.txt
42index 3cceceea..9695ea21 100644
43--- a/c/makeotf/lib/hotconv/CMakeLists.txt
44+++ b/c/makeotf/lib/hotconv/CMakeLists.txt
45@@ -69,7 +69,7 @@ add_library(hotconv STATIC
46
47 set_property(TARGET hotconv PROPERTY C_STANDARD 99)
48 target_include_directories(hotconv PRIVATE AFTER $<$<COMPILE_LANGUAGE:CXX>:${ANTLR4_INCLUDE_DIRS}>)
49-target_link_libraries(hotconv PUBLIC antlr4_static)
50+target_link_libraries(hotconv PUBLIC antlr4-runtime)
51
52 if (${LibXml2_FOUND})
53 target_link_libraries(hotconv PUBLIC ${LIBXML2_LIBRARY})