Skip to content

Commit

Permalink
Cpp: Remove deprecated policy settings
Browse files Browse the repository at this point in the history
Setting any policy to the OLD behavior is almost always a bad idea in
the long run as the OLD behavior of cmake policies are deprecated by
definition and may be completely removed in a future cmake version.

The changes in cmake behavior introduced by this are
- Only auto-expand variables in if-expressions, if they are unquoted.
  Doing this differently just opens you up for hell to break loose.
  As far as I can tell, we don't make use of this behavior anyway.
- If referring to a non-existing target with get_target_properties,
  cmake will now produce an error. This is what one usually wants as
  referencing non-existing targets is simply a bug in your setup.
- cmake won't recognize "DEFINITIONS" as a built-in directory property.
  Instead, one has to use the (proper) "COMPILE_DEFINITIONS". Again,
  I was unable to find a location in which we use "DEFINITIONS", so the
  change should have no effect on us.
- "@rpath" can now be used in a target's install name on macOS. With the
  OLD behavior, this had to explicitly be enabled, while the new
  behavior is to enable this by default. In order to still remain at the
  old behavior, without depending on deprecated functionality, we now
  instead set CMAKE_MACOSX_RPATH to OFF, which should have the same
  effect.

Besides removing deprecated behavior, this has the nice side effect of
removing the warnings that were emitted when building the cpp runtime
with cmake.

Signed-off-by: Robert Adam <[email protected]>
  • Loading branch information
Krzmbrzl authored and parrt committed Feb 19, 2023
1 parent b028de2 commit 1bd8bbe
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions runtime/Cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ cmake_minimum_required (VERSION 3.15)
# 3.14 needed because of FetchContent
# 3.15 needed to avid spew of warnings related to overriding cl command line flags

set(CMAKE_MACOSX_RPATH OFF)

enable_testing()

# Detect build type, fallback to release and throw a warning if use didn't specify any
Expand Down Expand Up @@ -36,13 +38,6 @@ endif(WITH_STATIC_CRT)

project(LIBANTLR4)

CMAKE_POLICY(SET CMP0054 OLD)
CMAKE_POLICY(SET CMP0045 OLD)
CMAKE_POLICY(SET CMP0042 OLD)

CMAKE_POLICY(SET CMP0059 OLD)
CMAKE_POLICY(SET CMP0054 OLD)

if(APPLE)
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
endif()
Expand Down

0 comments on commit 1bd8bbe

Please sign in to comment.