Skip to content

Commit

Permalink
Merge pull request #6496 from daftmugi/fix-antlr4-cmake-deprecation-w…
Browse files Browse the repository at this point in the history
…arnings

Fix antlr4 CMake deprecation warnings
  • Loading branch information
Goober5000 authored Dec 31, 2024
2 parents ca9edc0 + cda02de commit 8a86254
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 24 deletions.
29 changes: 8 additions & 21 deletions lib/antlr4-cpp-runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- mode:cmake -*-
cmake_minimum_required (VERSION 2.8)
cmake_minimum_required (VERSION 3.7)
# 2.8 needed because of ExternalProject

# Detect build type, fallback to release and throw a warning if use didn't specify any
Expand All @@ -25,20 +25,6 @@ option(WITH_STATIC_CRT "(Visual C++) Enable to statically link CRT, which avoids

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)
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)
endif()

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
#find_package(PkgConfig REQUIRED)
#pkg_check_modules(UUID REQUIRED uuid)
Expand All @@ -57,7 +43,7 @@ if(WITH_DEMO)
message(FATAL_ERROR "Missing antlr4.jar location. You can specify it's path using: -DANTLR_JAR_LOCATION=<path>")
else()
get_filename_component(ANTLR_NAME ${ANTLR_JAR_LOCATION} NAME_WE)
if(NOT EXISTS "${ANTLR_JAR_LOCATION}")
if(NOT EXISTS ANTLR_JAR_LOCATION)
message(FATAL_ERROR "Unable to find ${ANTLR_NAME} in ${ANTLR_JAR_LOCATION}")
else()
message(STATUS "Found ${ANTLR_NAME}: ${ANTLR_JAR_LOCATION}")
Expand All @@ -73,8 +59,9 @@ else()
set(MY_CXX_WARNING_FLAGS " -Wall -pedantic -W")
endif()


# Initialize CXXFLAGS.
if("${CMAKE_VERSION}" VERSION_GREATER 3.1.0)
if(CMAKE_VERSION VERSION_GREATER 3.1.0)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
else()
Expand All @@ -99,20 +86,20 @@ else()
endif()

# Compiler-specific C++11 activation.
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
# Just g++-5.0 and greater contain <codecvt> header. (test in ubuntu)
if(NOT (GCC_VERSION VERSION_GREATER 5.0 OR GCC_VERSION VERSION_EQUAL 5.0))
message(FATAL_ERROR "${PROJECT_NAME} requires g++ 5.0 or greater.")
endif ()
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND ANDROID)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND ANDROID)
# Need -Os cflag and cxxflags here to work with exception handling on armeabi.
# see https://github.com/android-ndk/ndk/issues/573
# and without -stdlib=libc++ cxxflags
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND APPLE)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND ( CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") )
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND ( CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD") )
execute_process(
COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION)
if(NOT (CLANG_VERSION VERSION_GREATER 4.2.1 OR CLANG_VERSION VERSION_EQUAL 4.2.1))
Expand Down
6 changes: 3 additions & 3 deletions lib/antlr4-cpp-runtime/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux")
#target_link_libraries(antlr4_static ${UUID_LIBRARIES})
elseif(APPLE)
# target_link_libraries(antlr4_shared ${COREFOUNDATION_LIBRARY})
target_link_libraries(antlr4_static ${COREFOUNDATION_LIBRARY})
target_link_libraries(antlr4_static PRIVATE ${COREFOUNDATION_LIBRARY})
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
Expand All @@ -55,9 +55,9 @@ else()
endif()


if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(disabled_compile_warnings "${disabled_compile_warnings} -Wno-dollar-in-identifier-extension -Wno-four-char-constants")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Intel")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel")
set(disabled_compile_warnings "${disabled_compile_warnings} -Wno-multichar")
endif()

Expand Down

0 comments on commit 8a86254

Please sign in to comment.