Open hagen666 opened 1 year ago
No one response?
Facing the same issue while using Antlr-4.x The build fails with the error:
CMake Error at CMakeLists.txt:112 (message):
LIBANTLR4 requires g++ 5.0 or greater.
Is there a fix for this issue?
in runtime/Cpp/CMakeLists.txt, replace the 'GCC_VERSION' with 'CMAKE_CXX_COMPILER_VERSION'.
Facing the same issue while using Antlr-4.x The build fails with the error:
CMake Error at CMakeLists.txt:112 (message): LIBANTLR4 requires g++ 5.0 or greater.
Is there a fix for this issue?
target information: C++ antlr version: antlr 4.10 smallest possible grammar: None
smallest possible code to reproduce:
when following environment was set, I cannot use ExternalAntlr4Cpp to compile the antlr_runtime: It's a CentOS 7. The system's gcc is version 4.8.5, ccache version is v4.0 , and I installed gcc 7.3.0 using scl toolset.
It has an error:
I found the following code cannot get the version 7.3.0 in the latest version: https://github.com/antlr/antlr4/blob/aa1f1f12a846846fcb78544bdb2ad135471376db/runtime/Cpp/CMakeLists.txt#L124-L130 as the same in v4.10.1: https://github.com/antlr/antlr4/blob/44d87bc1d130c88aa452894aa5f7e2f710f68253/runtime/Cpp/CMakeLists.txt#L110-L116
Here the variable value of
CMAKE_CXX_COMPILER
is the path to ccache(ccache's version is 4.0), and the gcc is in the variableCMAKE_CXX_COMPILER_ARG1
. The variableGCC_VERSION
here may be empty.expected behavior:
ExternalAntlr4Cpp can work when using ccache.
a possible solution:
use
CMAKE_CXX_COMPILER_VERSION
other than${CMAKE_CXX_COMPILER} -dumpversion
When the file changed, the behavior is normal:reference:
reference 1 Check GCC minor: https://stackoverflow.com/questions/4058565/check-gcc-minor-in-cmake reference 2 How to use ccache with cmake:https://stackoverflow.com/questions/1815688/how-to-use-ccache-with-cmake
some code segment
Addition cmake file segment:
and then link antlr4_static to the project: