Merge pull request #2685 from felixn/master

Fix ExternalAntlr4Cpp.cmake to work with CMake 3.14
This commit is contained in:
Terence Parr 2019-12-09 09:13:55 -08:00 committed by GitHub
commit 242d900ba6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 3 deletions

View File

@ -233,4 +233,5 @@ YYYY/MM/DD, github id, Full name, email
2019/09/28, lmy269, Mingyang Liu, lmy040758@gmail.com
2019/10/31, a-square, Alexei Averchenko, lex.aver@gmail.com
2019/11/11, foxeverl, Liu Xinfeng, liuxf1986[at]gmail[dot]com
2019/11/17, felixn, Felix Nieuwenhuizhen, felix@tdlrali.com
2019/11/18, mlilback, Mark Lilback, mark@lilback.com

View File

@ -109,6 +109,12 @@ else()
endif()
# Seperate build step as rarely people want both
set(ANTLR4_BUILD_DIR ${ANTLR4_ROOT})
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
# CMake 3.14 builds in above's SOURCE_SUBDIR when BUILD_IN_SOURCE is true
set(ANTLR4_BUILD_DIR ${ANTLR4_ROOT}/runtime/Cpp)
endif()
ExternalProject_Add_Step(
antlr4_runtime
build_static
@ -118,7 +124,7 @@ ExternalProject_Add_Step(
DEPENDS antlr4_runtime
BYPRODUCTS ${ANTLR4_STATIC_LIBRARIES}
EXCLUDE_FROM_MAIN 1
WORKING_DIRECTORY ${ANTLR4_ROOT})
WORKING_DIRECTORY ${ANTLR4_BUILD_DIR})
ExternalProject_Add_StepTargets(antlr4_runtime build_static)
add_library(antlr4_static STATIC IMPORTED)
@ -135,7 +141,7 @@ ExternalProject_Add_Step(
DEPENDS antlr4_runtime
BYPRODUCTS ${ANTLR4_SHARED_LIBRARIES} ${ANTLR4_RUNTIME_LIBRARIES}
EXCLUDE_FROM_MAIN 1
WORKING_DIRECTORY ${ANTLR4_ROOT})
WORKING_DIRECTORY ${ANTLR4_BUILD_DIR})
ExternalProject_Add_StepTargets(antlr4_runtime build_shared)
add_library(antlr4_shared SHARED IMPORTED)

View File

@ -40,7 +40,8 @@ antlr_target(SampleGrammarLexer TLexer.g4 LEXER
PACKAGE antlrcpptest)
antlr_target(SampleGrammarParser TParser.g4 PARSER
PACKAGE antlrcpptest
DEPENDS_ANTLR SampleGrammarLexer)
DEPENDS_ANTLR SampleGrammarLexer
COMPILE_FLAGS -lib ${ANTLR_SampleGrammarLexer_OUTPUT_DIR})
# include generated files in project environment
include_directories(${ANTLR_SampleGrammarLexer_OUTPUT_DIR})