You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I observed that in FindANTLR.cmake on line 40 you can specify the output directory more clearly. According to the docs, the default is ${CMAKE_CURRENT_BINARY_DIR}, so I set it manually. TParser still kept searching in build/myproject/TLexer.tokens, so I changed -lib too. Updated CMakeLists lines:
Now the generation works, but during the build process in add_executable I get:
cc1plus: fatal error: .../build/myproject/TLexer.cpp: No such file or directory
If I check the content of ${ANTLR_SampleGrammarLexer_CXX_OUTPUTS} I see indeed the incorrect path. Further investigating the FindANTLR.cmake file, I found that:
On line 38 we get only the file name, so TLexer without grammar/
On line 51 we append that path to the list also without grammar/
As a result the ${ANTLR_SampleGrammarLexer_CXX_OUTPUTS} variable contains the incorrect path.
Question
What is the correct way to overcome this? Maybe by adding an additional CMakeLists.txt file in the grammar/ subdirectory?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey everyone! I have a small question for my usage of Antlr4 with the C++ target. I'm using version 4.13.0 on wsl/ubuntu 22.04.2 with OpenJDK 11.0.20.
My directory structure is as follows:
Initial setup
The CMakeLists is as follows from the example in the official repo:
The issue I get is:
Updating path
I observed that in
FindANTLR.cmake
on line 40 you can specify the output directory more clearly. According to the docs, the default is${CMAKE_CURRENT_BINARY_DIR}
, so I set it manually. TParser still kept searching inbuild/myproject/TLexer.tokens
, so I changed-lib
too. Updated CMakeLists lines:Now the generation works, but during the build process in
add_executable
I get:If I check the content of
${ANTLR_SampleGrammarLexer_CXX_OUTPUTS}
I see indeed the incorrect path. Further investigating theFindANTLR.cmake
file, I found that:TLexer
withoutgrammar/
grammar/
${ANTLR_SampleGrammarLexer_CXX_OUTPUTS}
variable contains the incorrect path.Question
What is the correct way to overcome this? Maybe by adding an additional
CMakeLists.txt
file in thegrammar/
subdirectory?Beta Was this translation helpful? Give feedback.
All reactions