From e192ec42b426f6ffbc25419238a90f3c59088587 Mon Sep 17 00:00:00 2001 From: Petr Hosek Date: Mon, 29 Jun 2026 11:16:27 -0700 Subject: [PATCH] [CMake] Warn when the version of CMake is older than 3.31.0 (#204203) This is a preparation to raise the minimum required CMake version to 3.31.0 in LLVM 24. See https://discourse.llvm.org/t/rfc-raising-minimum-required-cmake-version-to-3-31/91086. --- bolt/CMakeLists.txt | 7 +++++++ clang/CMakeLists.txt | 8 ++++++++ compiler-rt/CMakeLists.txt | 8 ++++++++ flang/CMakeLists.txt | 8 ++++++++ libc/CMakeLists.txt | 8 ++++++++ libclc/CMakeLists.txt | 7 +++++++ libcxx/CMakeLists.txt | 8 ++++++++ libcxxabi/CMakeLists.txt | 8 ++++++++ libsycl/CMakeLists.txt | 7 +++++++ libunwind/CMakeLists.txt | 8 ++++++++ lld/CMakeLists.txt | 8 ++++++++ lldb/CMakeLists.txt | 8 ++++++++ llvm-libgcc/CMakeLists.txt | 8 ++++++++ llvm/CMakeLists.txt | 7 +++++++ mlir/CMakeLists.txt | 8 ++++++++ offload/CMakeLists.txt | 8 ++++++++ openmp/CMakeLists.txt | 8 ++++++++ orc-rt/CMakeLists.txt | 7 +++++++ polly/CMakeLists.txt | 8 ++++++++ runtimes/CMakeLists.txt | 7 +++++++ 20 files changed, 154 insertions(+) diff --git a/bolt/CMakeLists.txt b/bolt/CMakeLists.txt index 5c7d51e1e398..8deb5cea0401 100644 --- a/bolt/CMakeLists.txt +++ b/bolt/CMakeLists.txt @@ -1,4 +1,11 @@ cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() set(LLVM_SUBPROJECT_TITLE "BOLT") diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index e920e83a537d..20276a034d50 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -1,4 +1,12 @@ cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "Clang") if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 115d953e456c..d720b86c6df2 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -4,6 +4,14 @@ # based on the ability of the host toolchain to target various platforms. cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "Compiler-RT") if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) diff --git a/flang/CMakeLists.txt b/flang/CMakeLists.txt index bb74465411ad..42a7031c37fe 100644 --- a/flang/CMakeLists.txt +++ b/flang/CMakeLists.txt @@ -1,4 +1,12 @@ cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "Flang") if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) diff --git a/libc/CMakeLists.txt b/libc/CMakeLists.txt index 3b5f3949b286..6ddd75a0a333 100644 --- a/libc/CMakeLists.txt +++ b/libc/CMakeLists.txt @@ -1,4 +1,12 @@ cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "libc") if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) diff --git a/libclc/CMakeLists.txt b/libclc/CMakeLists.txt index bc3624688a08..5829bd9b39ea 100644 --- a/libclc/CMakeLists.txt +++ b/libclc/CMakeLists.txt @@ -1,4 +1,11 @@ cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) project(libclc VERSION 0.2.0 LANGUAGES CXX C) diff --git a/libcxx/CMakeLists.txt b/libcxx/CMakeLists.txt index e58191ccae59..31aaf2977a9a 100644 --- a/libcxx/CMakeLists.txt +++ b/libcxx/CMakeLists.txt @@ -2,6 +2,14 @@ # Setup Project #=============================================================================== cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "libc++") # Unset the C++ Standard: other projects sometimes override this global property, which diff --git a/libcxxabi/CMakeLists.txt b/libcxxabi/CMakeLists.txt index aca448ccf10b..d9ab9c494c06 100644 --- a/libcxxabi/CMakeLists.txt +++ b/libcxxabi/CMakeLists.txt @@ -5,6 +5,14 @@ #=============================================================================== cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "libc++abi") set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") diff --git a/libsycl/CMakeLists.txt b/libsycl/CMakeLists.txt index 0c2a57f7b083..baa2dd289c33 100644 --- a/libsycl/CMakeLists.txt +++ b/libsycl/CMakeLists.txt @@ -2,6 +2,13 @@ # Setup Project #=============================================================================== cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() set(LLVM_SUBPROJECT_TITLE "libsycl") diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 9606b072be0c..7f9c757bbd21 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -3,6 +3,14 @@ #=============================================================================== cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "libunwind") set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") diff --git a/lld/CMakeLists.txt b/lld/CMakeLists.txt index 80e25204a65e..b4b06caf3996 100644 --- a/lld/CMakeLists.txt +++ b/lld/CMakeLists.txt @@ -1,4 +1,12 @@ cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "LLD") if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) diff --git a/lldb/CMakeLists.txt b/lldb/CMakeLists.txt index 46e83681a814..20efb6fb1eb1 100644 --- a/lldb/CMakeLists.txt +++ b/lldb/CMakeLists.txt @@ -1,4 +1,12 @@ cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "LLDB") if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) diff --git a/llvm-libgcc/CMakeLists.txt b/llvm-libgcc/CMakeLists.txt index 55c052165dbd..a29744732793 100644 --- a/llvm-libgcc/CMakeLists.txt +++ b/llvm-libgcc/CMakeLists.txt @@ -3,6 +3,14 @@ #=============================================================================== cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "LLVM libgcc") set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake") diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index cec5462ae02a..7b8f1b3b3ced 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -1,5 +1,12 @@ # See docs/CMake.html for instructions about how to build LLVM with CMake. cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() include(CMakeDependentOption) diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 6d05fa50ecd0..ec4b8f729349 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -1,5 +1,13 @@ # MLIR project. cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "MLIR") if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS) diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt index fc23f6454f00..b218ed264707 100644 --- a/offload/CMakeLists.txt +++ b/offload/CMakeLists.txt @@ -2,6 +2,14 @@ # to build offload with CMake. cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "liboffload") # The minimum versions required for dependencies. diff --git a/openmp/CMakeLists.txt b/openmp/CMakeLists.txt index 08546dfaf249..1f328785f611 100644 --- a/openmp/CMakeLists.txt +++ b/openmp/CMakeLists.txt @@ -1,4 +1,12 @@ cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(LLVM_SUBPROJECT_TITLE "OpenMP") set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) diff --git a/orc-rt/CMakeLists.txt b/orc-rt/CMakeLists.txt index 95b7b852138e..7b16ceff463a 100644 --- a/orc-rt/CMakeLists.txt +++ b/orc-rt/CMakeLists.txt @@ -5,6 +5,13 @@ #=============================================================================== cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake diff --git a/polly/CMakeLists.txt b/polly/CMakeLists.txt index 52d1be6fe295..48459c61f456 100644 --- a/polly/CMakeLists.txt +++ b/polly/CMakeLists.txt @@ -2,6 +2,14 @@ if (NOT DEFINED LLVM_MAIN_SRC_DIR) project(Polly) cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() + set(POLLY_STANDALONE_BUILD TRUE) endif() set(LLVM_SUBPROJECT_TITLE "Polly") diff --git a/runtimes/CMakeLists.txt b/runtimes/CMakeLists.txt index 0a84ef3957f7..67ed49a7dcab 100644 --- a/runtimes/CMakeLists.txt +++ b/runtimes/CMakeLists.txt @@ -1,5 +1,12 @@ # This file handles building LLVM runtime sub-projects. cmake_minimum_required(VERSION 3.20.0) +if("${CMAKE_VERSION}" VERSION_LESS "3.31.0") + message(WARNING + "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 24, the " + "minimum version of CMake required to build LLVM will become 3.31.0, and " + "using an older CMake will become an error. Please upgrade your CMake to " + "at least 3.31.0 now to avoid issues in the future.") +endif() # This file can be used in two ways: the bootstrapping build calls it from # llvm/runtimes/CMakeLists.txt where we reuse the build tree of the top-level