Skip to content

Commit d40dc41

Browse files
committed
[CMake] Warn when the version is older than 3.20.0.
This is a preparation to require CMake 3.20.0 after LLVM 16 has been released. This change has been discussed on discourse https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193 Reviewed By: #libc_vendors, MaskRay, ChuanqiXu, to268, thieta, stellaraccident, ldionne, #libc, #libc_abi, phosek Differential Revision: https://reviews.llvm.org/D137724
1 parent ba237cb commit d40dc41

File tree

15 files changed

+109
-0
lines changed

15 files changed

+109
-0
lines changed

clang/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
1111
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
1212
project(Clang)
1313
set(CLANG_BUILT_STANDALONE TRUE)
14+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
15+
message(WARNING
16+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
17+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
18+
"using an older CMake will become an error. Please upgrade your CMake to "
19+
"at least 3.20.0 now to avoid issues in the future!")
20+
endif()
1421
endif()
1522

1623
# Must go below project(..)

compiler-rt/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR COMPILER_RT_STANDALONE
1010
project(CompilerRT C CXX ASM)
1111
set(COMPILER_RT_STANDALONE_BUILD TRUE)
1212
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
13+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
14+
message(WARNING
15+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
16+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
17+
"using an older CMake will become an error. Please upgrade your CMake to "
18+
"at least 3.20.0 now to avoid issues in the future!")
19+
endif()
1320
endif()
1421

1522
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44

55
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
66
cmake_minimum_required(VERSION 3.13.4)
7+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
8+
message(WARNING
9+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
10+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
11+
"using an older CMake will become an error. Please upgrade your CMake to "
12+
"at least 3.20.0 now to avoid issues in the future!")
13+
endif()
714

815
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
916
project(CompilerRTBuiltins C ASM)

compiler-rt/lib/crt/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
22
cmake_minimum_required(VERSION 3.13.4)
3+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
4+
message(WARNING
5+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
6+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
7+
"using an older CMake will become an error. Please upgrade your CMake to "
8+
"at least 3.20.0 now to avoid issues in the future!")
9+
endif()
310

411
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
512
project(CompilerRTCRT C)

flang/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
3131
message("Building Flang as a standalone project.")
3232
project(Flang)
3333
set(FLANG_STANDALONE_BUILD ON)
34+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
35+
message(WARNING
36+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
37+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
38+
"using an older CMake will become an error. Please upgrade your CMake to "
39+
"at least 3.20.0 now to avoid issues in the future!")
40+
endif()
3441
else()
3542
set(FLANG_STANDALONE_BUILD OFF)
3643
endif()

flang/runtime/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
1010
cmake_minimum_required(VERSION 3.13.4)
11+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
12+
message(WARNING
13+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
14+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
15+
"using an older CMake will become an error. Please upgrade your CMake to "
16+
"at least 3.20.0 now to avoid issues in the future!")
17+
endif()
1118

1219
project(FlangRuntime C CXX)
1320

lld/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
1111
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
1212
project(lld)
1313
set(LLD_BUILT_STANDALONE TRUE)
14+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
15+
message(WARNING
16+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
17+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
18+
"using an older CMake will become an error. Please upgrade your CMake to "
19+
"at least 3.20.0 now to avoid issues in the future!")
20+
endif()
1421
endif()
1522

1623
# Must go below project(..)

lldb/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
1919
project(lldb)
2020
set(LLDB_BUILT_STANDALONE TRUE)
2121
set(LLVM_INCLUDE_TESTS ON CACHE INTERNAL "")
22+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
23+
message(WARNING
24+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
25+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
26+
"using an older CMake will become an error. Please upgrade your CMake to "
27+
"at least 3.20.0 now to avoid issues in the future!")
28+
endif()
2229
endif()
2330

2431
# Must go below project(..)

lldb/tools/debugserver/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ include(GNUInstallDirs)
77

88
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
99
set(LLDB_BUILT_STANDALONE TRUE)
10+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
11+
message(WARNING
12+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
13+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
14+
"using an older CMake will become an error. Please upgrade your CMake to "
15+
"at least 3.20.0 now to avoid issues in the future!")
16+
endif()
1017

1118
set(CMAKE_MODULE_PATH
1219
${CMAKE_MODULE_PATH}

llvm/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# See docs/CMake.html for instructions about how to build LLVM with CMake.
22

33
cmake_minimum_required(VERSION 3.13.4)
4+
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
5+
message(WARNING
6+
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
7+
"minimum version of CMake required to build LLVM will become 3.20.0, and "
8+
"using an older CMake will become an error. Please upgrade your CMake to "
9+
"at least 3.20.0 now to avoid issues in the future!")
10+
endif()
411

512
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
613
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake

0 commit comments

Comments
 (0)