Skip to content

Commit 3fef4d1

Browse files
committed
Cpp: Remove deprecated policy settings
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]>
1 parent 19815ba commit 3fef4d1

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

runtime/Cpp/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ cmake_minimum_required (VERSION 3.15)
33
# 3.14 needed because of FetchContent
44
# 3.15 needed to avid spew of warnings related to overriding cl command line flags
55

6+
set(CMAKE_MACOSX_RPATH OFF)
7+
68
enable_testing()
79

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

3739
project(LIBANTLR4)
3840

39-
CMAKE_POLICY(SET CMP0054 OLD)
40-
CMAKE_POLICY(SET CMP0045 OLD)
41-
CMAKE_POLICY(SET CMP0042 OLD)
42-
43-
CMAKE_POLICY(SET CMP0059 OLD)
44-
CMAKE_POLICY(SET CMP0054 OLD)
45-
4641
if(APPLE)
4742
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
4843
endif()

0 commit comments

Comments
 (0)