Skip to content

Commit 19815ba

Browse files
committed
Cpp: Remove redundant cmake version checks
In the top-level CMakeLists.txt, a minimum cmake version of 3.15 is required. Therefore, all checks that were checking whether the cmake version is >= 3.0 or 3.1 (etc.) are redundant as those will always be true due to above requirement. Signed-off-by: Robert Adam <[email protected]>
1 parent 7511da0 commit 19815ba

File tree

1 file changed

+11
-26
lines changed

1 file changed

+11
-26
lines changed

runtime/Cpp/CMakeLists.txt

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,12 @@ endif(WITH_STATIC_CRT)
3636

3737
project(LIBANTLR4)
3838

39-
if(CMAKE_VERSION VERSION_EQUAL "3.0.0" OR
40-
CMAKE_VERSION VERSION_GREATER "3.0.0")
41-
CMAKE_POLICY(SET CMP0026 NEW)
42-
CMAKE_POLICY(SET CMP0054 OLD)
43-
CMAKE_POLICY(SET CMP0045 OLD)
44-
CMAKE_POLICY(SET CMP0042 OLD)
45-
endif()
39+
CMAKE_POLICY(SET CMP0054 OLD)
40+
CMAKE_POLICY(SET CMP0045 OLD)
41+
CMAKE_POLICY(SET CMP0042 OLD)
4642

47-
if(CMAKE_VERSION VERSION_EQUAL "3.3.0" OR
48-
CMAKE_VERSION VERSION_GREATER "3.3.0")
49-
CMAKE_POLICY(SET CMP0059 OLD)
50-
CMAKE_POLICY(SET CMP0054 OLD)
51-
endif()
43+
CMAKE_POLICY(SET CMP0059 OLD)
44+
CMAKE_POLICY(SET CMP0054 OLD)
5245

5346
if(APPLE)
5447
find_library(COREFOUNDATION_LIBRARY CoreFoundation)
@@ -90,21 +83,13 @@ endif()
9083
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_UTF8_INSTEAD_OF_CODECVT")
9184

9285
# Initialize CXXFLAGS.
93-
if(CMAKE_VERSION VERSION_GREATER 3.1.0)
94-
if(NOT DEFINED CMAKE_CXX_STANDARD)
95-
# only set CMAKE_CXX_STANDARD if not already set
96-
# this allows the standard to be set by the caller, for example with -DCMAKE_CXX_STANDARD:STRING=17
97-
set(CMAKE_CXX_STANDARD 17)
98-
endif()
99-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
100-
set(CMAKE_CXX_EXTENSIONS OFF)
101-
else()
102-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
103-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=c++17")
104-
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -std=c++17")
105-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=c++17")
106-
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -std=c++17")
86+
if(NOT DEFINED CMAKE_CXX_STANDARD)
87+
# only set CMAKE_CXX_STANDARD if not already set
88+
# this allows the standard to be set by the caller, for example with -DCMAKE_CXX_STANDARD:STRING=17
89+
set(CMAKE_CXX_STANDARD 17)
10790
endif()
91+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
92+
set(CMAKE_CXX_EXTENSIONS OFF)
10893

10994
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_WARNING_FLAGS}")
11095

0 commit comments

Comments
 (0)