fix: update antlr4 CMAKE_POLICY from OLD to NEW for CMake 3.31+ compatibility (#145)

CMake 3.31+ has removed support for the OLD behavior of policies
CMP0042, CMP0045, CMP0054, and CMP0059. This causes a hard
configuration error when building from source with newer CMake versions.

Changing these to NEW resolves the build failure. The NEW behavior has
been the default since CMake 3.0/3.3 and does not affect functionality.

Fixes #144
This commit is contained in:
Aashish Thapa 2026-02-27 00:35:55 -06:00 committed by GitHub
parent 04860d7d9d
commit 0d84e30dd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 4 deletions

View File

@ -1,9 +1,25 @@
diff --git a/runtime/Cpp/CMakeLists.txt b/runtime/Cpp/CMakeLists.txt
index 390078151..de657dcc4 100644
index 390078151..213258ac8 100644
--- a/runtime/Cpp/CMakeLists.txt
+++ b/runtime/Cpp/CMakeLists.txt
@@ -39,10 +39,10 @@ if(CMAKE_VERSION VERSION_EQUAL "3.3.0" OR
CMAKE_POLICY(SET CMP0054 OLD)
@@ -28,21 +28,21 @@ project(LIBANTLR4)
if(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR
CMAKE_VERSION VERSION_GREATER "3.0.0")
CMAKE_POLICY(SET CMP0026 NEW)
- CMAKE_POLICY(SET CMP0054 OLD)
- CMAKE_POLICY(SET CMP0045 OLD)
- CMAKE_POLICY(SET CMP0042 OLD)
+ CMAKE_POLICY(SET CMP0054 NEW)
+ CMAKE_POLICY(SET CMP0045 NEW)
+ CMAKE_POLICY(SET CMP0042 NEW)
endif()
if(CMAKE_VERSION VERSION_EQUAL "3.3.0" OR
CMAKE_VERSION VERSION_GREATER "3.3.0")
- CMAKE_POLICY(SET CMP0059 OLD)
- CMAKE_POLICY(SET CMP0054 OLD)
+ CMAKE_POLICY(SET CMP0059 NEW)
+ CMAKE_POLICY(SET CMP0054 NEW)
endif()
-if(CMAKE_SYSTEM_NAME MATCHES "Linux")
@ -18,7 +34,7 @@ index 390078151..de657dcc4 100644
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
endif()
diff --git a/runtime/Cpp/runtime/CMakeLists.txt b/runtime/Cpp/runtime/CMakeLists.txt
index 2c5e7376f..bcc0134dc 100644
index 2c5e7376f..ae992f9cc 100644
--- a/runtime/Cpp/runtime/CMakeLists.txt
+++ b/runtime/Cpp/runtime/CMakeLists.txt
@@ -25,7 +25,7 @@ file(GLOB libantlrcpp_SRC