Skip to content

Commit

Permalink
Statically build and link the ANTLR4 runtime.
Browse files Browse the repository at this point in the history
Signed-off-by: Dusty DeWeese <[email protected]>
  • Loading branch information
HackerFoo committed Dec 15, 2020
1 parent 700a4d2 commit b670a21
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/antlr4/

set(CMAKE_CXX_STANDARD 11)

# required if linking to static library
add_definitions(-DANTLR4CPP_STATIC)

# add external build for antlrcpp
include(ExternalAntlr4Cpp)

# https://github.com/antlr/antlr4/issues/2776#issuecomment-677438028
set_property(TARGET antlr4_static PROPERTY POSITION_INDEPENDENT_CODE ON)

# add antrl4cpp artifacts to project environment
include_directories(${ANTLR4_INCLUDE_DIRS})

Expand All @@ -25,7 +34,7 @@ set(ANTLR_EXECUTABLE ${CMAKE_CURRENT_SOURCE_DIR}/../third_party/antlr4/antlr-4.9
# add macros to generate ANTLR Cpp code from grammar
find_package(ANTLR REQUIRED)

find_library(ANTLR4_RUNTIME NAMES antlr4-runtime REQUIRED)
set(ANTLR4_RUNTIME antlr4_static)

# Unit testing library
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../third_party/googletest EXCLUDE_FROM_ALL googletest)
Expand Down Expand Up @@ -69,6 +78,7 @@ add_library(parse_fasm SHARED ParseFasm.cpp
${ANTLR_FasmParser_CXX_OUTPUTS})
target_link_libraries(parse_fasm ${ANTLR4_RUNTIME})
target_compile_options(parse_fasm PRIVATE -Wno-attributes) # Disable warning from antlr4-runtime
set_property(TARGET parse_fasm PROPERTY POSITION_INDEPENDENT_CODE ON)

add_executable(parse_fasm_tests
ParseFasmTests.cpp
Expand Down

0 comments on commit b670a21

Please sign in to comment.