Skip to content

Commit cbaa359

Browse files
committed
Reland "[CMake] Bumps minimum version to 3.20.0.
This reverts commit d763c6e. Adds the patch by @hans from llvm#62719 This patch fixes the Windows build. d763c6e reverted the reviews D144509 [CMake] Bumps minimum version to 3.20.0. This partly undoes D137724. This change has been discussed on discourse https://discourse.llvm.org/t/rfc-upgrading-llvms-minimum-required-cmake-version/66193 Note this does not remove work-arounds for older CMake versions, that will be done in followup patches. D150532 [OpenMP] Compile assembly files as ASM, not C Since CMake 3.20, CMake explicitly passes "-x c" (or equivalent) when compiling a file which has been set as having the language C. This behaviour change only takes place if "cmake_minimum_required" is set to 3.20 or newer, or if the policy CMP0119 is set to new. Attempting to compile assembly files with "-x c" fails, however this is workarounded in many cases, as OpenMP overrides this with "-x assembler-with-cpp", however this is only added for non-Windows targets. Thus, after increasing cmake_minimum_required to 3.20, this breaks compiling the GNU assembly for Windows targets; the GNU assembly is used for ARM and AArch64 Windows targets when building with Clang. This patch unbreaks that. D150688 [cmake] Set CMP0091 to fix Windows builds after the cmake_minimum_required bump The build uses other mechanism to select the runtime. Fixes llvm#62719 Reviewed By: #libc, Mordante Differential Revision: https://reviews.llvm.org/D151344
1 parent a218c99 commit cbaa359

File tree

38 files changed

+58
-143
lines changed

38 files changed

+58
-143
lines changed

bolt/runtime/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13.4)
1+
cmake_minimum_required(VERSION 3.20.0)
22
include(CheckIncludeFiles)
33
include(GNUInstallDirs)
44

clang/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13.4)
1+
cmake_minimum_required(VERSION 3.20.0)
22

33
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
44
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
@@ -11,13 +11,6 @@ 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()
2114
endif()
2215

2316
# Must go below project(..)

clang/tools/scan-build-py/tests/functional/exec/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project(exec C)
22

3-
cmake_minimum_required(VERSION 3.13.4)
3+
cmake_minimum_required(VERSION 3.20.0)
44

55
include(CheckCCompilerFlag)
66
check_c_compiler_flag("-std=c99" C99_SUPPORTED)

cmake/Modules/CMakePolicy.cmake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# CMake policy settings shared between LLVM projects
22

3+
# CMP0091: MSVC runtime library flags are selected by an abstraction.
4+
# New in CMake 3.15. https://cmake.org/cmake/help/latest/policy/CMP0091.html
5+
if(POLICY CMP0091)
6+
cmake_policy(SET CMP0091 OLD)
7+
endif()
38
# CMP0114: ExternalProject step targets fully adopt their steps.
49
# New in CMake 3.19: https://cmake.org/cmake/help/latest/policy/CMP0114.html
510
if(POLICY CMP0114)

compiler-rt/CMakeLists.txt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,19 @@
33
# An important constraint of the build is that it only produces libraries
44
# based on the ability of the host toolchain to target various platforms.
55

6-
cmake_minimum_required(VERSION 3.13.4)
6+
cmake_minimum_required(VERSION 3.20.0)
7+
8+
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
9+
include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
10+
NO_POLICY_SCOPE)
711

812
# Check if compiler-rt is built as a standalone project.
913
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR OR COMPILER_RT_STANDALONE_BUILD)
1014
project(CompilerRT C CXX ASM)
1115
set(COMPILER_RT_STANDALONE_BUILD TRUE)
1216
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()
2017
endif()
2118

22-
set(LLVM_COMMON_CMAKE_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../cmake")
23-
2419
# Add path for custom compiler-rt modules.
2520
list(INSERT CMAKE_MODULE_PATH 0
2621
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"

compiler-rt/lib/builtins/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,7 @@
33
# architecture-specific code in various subdirectories.
44

55
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
6-
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()
6+
cmake_minimum_required(VERSION 3.20.0)
147

158
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
169
project(CompilerRTBuiltins C ASM)

compiler-rt/lib/crt/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,5 @@
11
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2-
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()
2+
cmake_minimum_required(VERSION 3.20.0)
103

114
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
125
project(CompilerRTCRT C)

flang/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13.4)
1+
cmake_minimum_required(VERSION 3.20.0)
22

33
if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
44
set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
@@ -39,13 +39,6 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
3939
message("Building Flang as a standalone project.")
4040
project(Flang)
4141
set(FLANG_STANDALONE_BUILD ON)
42-
if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
43-
message(WARNING
44-
"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
45-
"minimum version of CMake required to build LLVM will become 3.20.0, and "
46-
"using an older CMake will become an error. Please upgrade your CMake to "
47-
"at least 3.20.0 now to avoid issues in the future!")
48-
endif()
4942
else()
5043
set(FLANG_STANDALONE_BUILD OFF)
5144
endif()

flang/lib/Decimal/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
2-
cmake_minimum_required(VERSION 3.13.4)
2+
cmake_minimum_required(VERSION 3.20.0)
33

44
project(FortranDecimal C CXX)
55

flang/runtime/CMakeLists.txt

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,7 @@
77
#===------------------------------------------------------------------------===#
88

99
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
10-
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()
10+
cmake_minimum_required(VERSION 3.20.0)
1811

1912
project(FlangRuntime C CXX)
2013

0 commit comments

Comments
 (0)