#------------------- LIBRARY CONFIGURATION ------------------------------------

set(ANTLR4_RUNTIME antlr4_runtime CACHE INTERNAL "")
set(ANTLR4_RUNTIME_SRC
    src/antlr4-common.h
    src/antlr4-runtime.h
    src/ANTLRErrorListener.cpp
    src/ANTLRErrorListener.h
    src/ANTLRErrorStrategy.cpp
    src/ANTLRErrorStrategy.h
    src/ANTLRFileStream.cpp
    src/ANTLRFileStream.h
    src/ANTLRInputStream.cpp
    src/ANTLRInputStream.h
    src/atn/ActionTransition.cpp
    src/atn/ActionTransition.h
    src/atn/AmbiguityInfo.cpp
    src/atn/AmbiguityInfo.h
    src/atn/ArrayPredictionContext.cpp
    src/atn/ArrayPredictionContext.h
    src/atn/ATNConfig.cpp
    src/atn/ATNConfig.h
    src/atn/ATNConfigSet.cpp
    src/atn/ATNConfigSet.h
    src/atn/ATN.cpp
    src/atn/ATNDeserializationOptions.cpp
    src/atn/ATNDeserializationOptions.h
    src/atn/ATNDeserializer.cpp
    src/atn/ATNDeserializer.h
    src/atn/ATN.h
    src/atn/ATNSimulator.cpp
    src/atn/ATNSimulator.h
    src/atn/ATNState.cpp
    src/atn/ATNState.h
    src/atn/ATNStateType.cpp
    src/atn/ATNStateType.h
    src/atn/ATNType.h
    src/atn/AtomTransition.cpp
    src/atn/AtomTransition.h
    src/atn/BasicBlockStartState.h
    src/atn/BasicState.h
    src/atn/BlockEndState.h
    src/atn/BlockStartState.h
    src/atn/ContextSensitivityInfo.cpp
    src/atn/ContextSensitivityInfo.h
    src/atn/DecisionEventInfo.cpp
    src/atn/DecisionEventInfo.h
    src/atn/DecisionInfo.cpp
    src/atn/DecisionInfo.h
    src/atn/DecisionState.cpp
    src/atn/DecisionState.h
    src/atn/EpsilonTransition.cpp
    src/atn/EpsilonTransition.h
    src/atn/ErrorInfo.cpp
    src/atn/ErrorInfo.h
    src/atn/HashUtils.h
    src/atn/LexerAction.cpp
    src/atn/LexerActionExecutor.cpp
    src/atn/LexerActionExecutor.h
    src/atn/LexerAction.h
    src/atn/LexerActionType.h
    src/atn/LexerATNConfig.cpp
    src/atn/LexerATNConfig.h
    src/atn/LexerATNSimulator.cpp
    src/atn/LexerATNSimulator.h
    src/atn/LexerChannelAction.cpp
    src/atn/LexerChannelAction.h
    src/atn/LexerCustomAction.cpp
    src/atn/LexerCustomAction.h
    src/atn/LexerIndexedCustomAction.cpp
    src/atn/LexerIndexedCustomAction.h
    src/atn/LexerModeAction.cpp
    src/atn/LexerModeAction.h
    src/atn/LexerMoreAction.cpp
    src/atn/LexerMoreAction.h
    src/atn/LexerPopModeAction.cpp
    src/atn/LexerPopModeAction.h
    src/atn/LexerPushModeAction.cpp
    src/atn/LexerPushModeAction.h
    src/atn/LexerSkipAction.cpp
    src/atn/LexerSkipAction.h
    src/atn/LexerTypeAction.cpp
    src/atn/LexerTypeAction.h
    src/atn/LL1Analyzer.cpp
    src/atn/LL1Analyzer.h
    src/atn/LookaheadEventInfo.cpp
    src/atn/LookaheadEventInfo.h
    src/atn/LoopEndState.h
    src/atn/NotSetTransition.cpp
    src/atn/NotSetTransition.h
    src/atn/OrderedATNConfigSet.cpp
    src/atn/OrderedATNConfigSet.h
    src/atn/ParseInfo.cpp
    src/atn/ParseInfo.h
    src/atn/ParserATNSimulator.cpp
    src/atn/ParserATNSimulator.h
    src/atn/ParserATNSimulatorOptions.h
    src/atn/PlusBlockStartState.h
    src/atn/PlusLoopbackState.h
    src/atn/PrecedencePredicateTransition.cpp
    src/atn/PrecedencePredicateTransition.h
    src/atn/PredicateEvalInfo.cpp
    src/atn/PredicateEvalInfo.h
    src/atn/PredicateTransition.cpp
    src/atn/PredicateTransition.h
    src/atn/PredictionContextCache.cpp
    src/atn/PredictionContextCache.h
    src/atn/PredictionContext.cpp
    src/atn/PredictionContext.h
    src/atn/PredictionContextMergeCache.cpp
    src/atn/PredictionContextMergeCache.h
    src/atn/PredictionContextMergeCacheOptions.h
    src/atn/PredictionContextType.h
    src/atn/PredictionMode.cpp
    src/atn/PredictionMode.h
    src/atn/ProfilingATNSimulator.cpp
    src/atn/ProfilingATNSimulator.h
    src/atn/RangeTransition.cpp
    src/atn/RangeTransition.h
    src/atn/RuleStartState.h
    src/atn/RuleStopState.h
    src/atn/RuleTransition.cpp
    src/atn/RuleTransition.h
    src/atn/SemanticContext.cpp
    src/atn/SemanticContext.h
    src/atn/SemanticContextType.h
    src/atn/SerializedATNView.h
    src/atn/SetTransition.cpp
    src/atn/SetTransition.h
    src/atn/SingletonPredictionContext.cpp
    src/atn/SingletonPredictionContext.h
    src/atn/StarBlockStartState.h
    src/atn/StarLoopbackState.cpp
    src/atn/StarLoopbackState.h
    src/atn/StarLoopEntryState.h
    src/atn/TokensStartState.h
    src/atn/Transition.cpp
    src/atn/Transition.h
    src/atn/TransitionType.cpp
    src/atn/TransitionType.h
    src/atn/WildcardTransition.cpp
    src/atn/WildcardTransition.h
    src/BailErrorStrategy.cpp
    src/BailErrorStrategy.h
    src/BaseErrorListener.cpp
    src/BaseErrorListener.h
    src/BufferedTokenStream.cpp
    src/BufferedTokenStream.h
    src/CharStream.cpp
    src/CharStream.h
    src/CommonToken.cpp
    src/CommonTokenFactory.cpp
    src/CommonTokenFactory.h
    src/CommonToken.h
    src/CommonTokenStream.cpp
    src/CommonTokenStream.h
    src/ConsoleErrorListener.cpp
    src/ConsoleErrorListener.h
    src/DefaultErrorStrategy.cpp
    src/DefaultErrorStrategy.h
    src/dfa/DFA.cpp
    src/dfa/DFA.h
    src/dfa/DFASerializer.cpp
    src/dfa/DFASerializer.h
    src/dfa/DFAState.cpp
    src/dfa/DFAState.h
    src/dfa/LexerDFASerializer.cpp
    src/dfa/LexerDFASerializer.h
    src/DiagnosticErrorListener.cpp
    src/DiagnosticErrorListener.h
    src/Exceptions.cpp
    src/Exceptions.h
    src/FailedPredicateException.cpp
    src/FailedPredicateException.h
    src/FlatHashMap.h
    src/FlatHashSet.h
    src/InputMismatchException.cpp
    src/InputMismatchException.h
    src/internal/Synchronization.cpp
    src/internal/Synchronization.h
    src/InterpreterRuleContext.cpp
    src/InterpreterRuleContext.h
    src/IntStream.cpp
    src/IntStream.h
    src/Lexer.cpp
    src/Lexer.h
    src/LexerInterpreter.cpp
    src/LexerInterpreter.h
    src/LexerNoViableAltException.cpp
    src/LexerNoViableAltException.h
    src/ListTokenSource.cpp
    src/ListTokenSource.h
    src/misc/InterpreterDataReader.cpp
    src/misc/InterpreterDataReader.h
    src/misc/Interval.cpp
    src/misc/Interval.h
    src/misc/IntervalSet.cpp
    src/misc/IntervalSet.h
    src/misc/MurmurHash.cpp
    src/misc/MurmurHash.h
    src/misc/Predicate.cpp
    src/misc/Predicate.h
    src/NoViableAltException.cpp
    src/NoViableAltException.h
    src/Parser.cpp
    src/Parser.h
    src/ParserInterpreter.cpp
    src/ParserInterpreter.h
    src/ParserRuleContext.cpp
    src/ParserRuleContext.h
    src/ProxyErrorListener.cpp
    src/ProxyErrorListener.h
    src/RecognitionException.cpp
    src/RecognitionException.h
    src/Recognizer.cpp
    src/Recognizer.h
    src/RuleContext.cpp
    src/RuleContext.h
    src/RuleContextWithAltNum.cpp
    src/RuleContextWithAltNum.h
    src/RuntimeMetaData.cpp
    src/RuntimeMetaData.h
    src/support/Any.cpp
    src/support/Any.h
    src/support/Arrays.cpp
    src/support/Arrays.h
    src/support/BitSet.h
    src/support/Casts.h
    src/support/CPPUtils.cpp
    src/support/CPPUtils.h
    src/support/Declarations.h
    src/support/StringUtils.cpp
    src/support/StringUtils.h
    src/support/Unicode.h
    src/support/Utf8.cpp
    src/support/Utf8.h
    src/Token.cpp
    src/TokenFactory.h
    src/Token.h
    src/TokenSource.cpp
    src/TokenSource.h
    src/TokenStream.cpp
    src/TokenStream.h
    src/TokenStreamRewriter.cpp
    src/TokenStreamRewriter.h
    src/tree/AbstractParseTreeVisitor.h
    src/tree/ErrorNode.h
    src/tree/ErrorNodeImpl.cpp
    src/tree/ErrorNodeImpl.h
    src/tree/IterativeParseTreeWalker.cpp
    src/tree/IterativeParseTreeWalker.h
    src/tree/ParseTree.cpp
    src/tree/ParseTree.h
    src/tree/ParseTreeListener.cpp
    src/tree/ParseTreeListener.h
    src/tree/ParseTreeProperty.h
    src/tree/ParseTreeType.h
    src/tree/ParseTreeVisitor.cpp
    src/tree/ParseTreeVisitor.h
    src/tree/ParseTreeWalker.cpp
    src/tree/ParseTreeWalker.h
    src/tree/pattern/Chunk.cpp
    src/tree/pattern/Chunk.h
    src/tree/pattern/ParseTreeMatch.cpp
    src/tree/pattern/ParseTreeMatch.h
    src/tree/pattern/ParseTreePattern.cpp
    src/tree/pattern/ParseTreePattern.h
    src/tree/pattern/ParseTreePatternMatcher.cpp
    src/tree/pattern/ParseTreePatternMatcher.h
    src/tree/pattern/RuleTagToken.cpp
    src/tree/pattern/RuleTagToken.h
    src/tree/pattern/TagChunk.cpp
    src/tree/pattern/TagChunk.h
    src/tree/pattern/TextChunk.cpp
    src/tree/pattern/TextChunk.h
    src/tree/pattern/TokenTagToken.cpp
    src/tree/pattern/TokenTagToken.h
    src/tree/TerminalNode.h
    src/tree/TerminalNodeImpl.cpp
    src/tree/TerminalNodeImpl.h
    src/tree/Trees.cpp
    src/tree/Trees.h
    src/tree/xpath/XPath.cpp
    src/tree/xpath/XPathElement.cpp
    src/tree/xpath/XPathElement.h
    src/tree/xpath/XPath.h
    src/tree/xpath/XPathLexer.cpp
    src/tree/xpath/XPathLexerErrorListener.cpp
    src/tree/xpath/XPathLexerErrorListener.h
    src/tree/xpath/XPathLexer.g4
    src/tree/xpath/XPathLexer.h
    src/tree/xpath/XPathLexer.tokens
    src/tree/xpath/XPathRuleAnywhereElement.cpp
    src/tree/xpath/XPathRuleAnywhereElement.h
    src/tree/xpath/XPathRuleElement.cpp
    src/tree/xpath/XPathRuleElement.h
    src/tree/xpath/XPathTokenAnywhereElement.cpp
    src/tree/xpath/XPathTokenAnywhereElement.h
    src/tree/xpath/XPathTokenElement.cpp
    src/tree/xpath/XPathTokenElement.h
    src/tree/xpath/XPathWildcardAnywhereElement.cpp
    src/tree/xpath/XPathWildcardAnywhereElement.h
    src/tree/xpath/XPathWildcardElement.cpp
    src/tree/xpath/XPathWildcardElement.h
    src/UnbufferedCharStream.cpp
    src/UnbufferedCharStream.h
    src/UnbufferedTokenStream.cpp
    src/UnbufferedTokenStream.h
    src/Version.h
    src/Vocabulary.cpp
    src/Vocabulary.h
    src/WritableToken.cpp
    src/WritableToken.h
)

add_library(${ANTLR4_RUNTIME} STATIC ${ANTLR4_RUNTIME_SRC})

target_include_directories(${ANTLR4_RUNTIME} PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/src
)

target_compile_definitions(${ANTLR4_RUNTIME} PUBLIC -DANTLR4CPP_STATIC)

if(MSVC)
    target_compile_options(${ANTLR4_RUNTIME} PRIVATE
        $<$<CONFIG:Debug>:/W4 /Od>
        $<$<CONFIG:Release>:/O2>
    )
else()
    target_compile_options(${ANTLR4_RUNTIME} PRIVATE
        $<$<CONFIG:Debug>:-g -Wall -O0>
        $<$<CONFIG:Release>:-w -O3>
    )
    target_compile_options(${ANTLR4_RUNTIME} PUBLIC
        $<$<CONFIG:Release>:-Wno-attributes>
    )
endif()
