At the moment libc++ ships its dylib using C++20. This is needed since the dylib contains code using C++20. All exceptions are anchored in the dylib and in C++20 std::format_error has been added. Some C++23 features might require libc++ to switch to C++23. (Whether or not it is required, depends on which code end up in the dylib and which code is header only.) The easiest way to switch, is by setting the CMake property CXX_STANDARD to 23. The value 23 requires CMake 3.20.0 or newer. To prepare for this future change I propose to update the CMake requirement from 3.13.4 (released 4 February 2019) to CMake 3.20.0 (23 March 2021). Historically we tried to raise the CMake required version for all subprojects [1] and I propose to do that again. The goal is to make CMake 3.20.0 required in LLVM 17.
The proposal to achieve that goal is:
- Immediately let CMake issue a diagnostic when the CMake version is less than 3.20.0, this patch will be considered a breaking change.
- Notify all build bot owners.
- After LLVM 16 has been branched update the required CMake version in main to 3.20.0, this patch will be considered a breaking change.
- After all build bots are green all send a message we can use CMake 3.20.0 features.
I volunteer to make these changes.
The current CMake support for the various Linux distributions is (pkgs.org):
CentOS 7 (released 2014-07-07) 2.8.12 (EPEL 3.14.6)
CentOS 8 (released 8 2019-09-24) 3.20.2
CentOS 9 Stream 3.20.2
Debian 10 (released 6 July 2019) 3.13.4
Debian 11 (released 14 August 2021) 3.18.4 (backports has 3.24.2)
FreeBSD 12 (released 11 December 2018) 2.23.2
FreeBSD 13 (released 13 April 2021) 3.24.2
NetBSD 8 (released 17 July 2018) 3.22.3
NetBSD 9 (released 14 February 2020) 3.23.2
Ubuntu 20.04 (release April 2020) 3.16.3
Ubuntu 22.04 (release April 2022) 3.22.1
macOS latest version is readily available through Homebrew
Windows: You can install it yourself or use the one bundled with Visual Studio.
CMake also offers prebuilt binaries for Linux, MacOS, and Windows.
So the proposed change will mean we no longer directly support CentOS 7, Debian 10, and Ubuntu 20.04. All these Distributions have a newer release available.
The are other new interesting features between 3.13.4 and 3.20, the release notes are available here:
- CMake 3.14 Release Notes — CMake 3.25.0-rc2 Documentation
- CMake 3.15 Release Notes — CMake 3.25.0-rc2 Documentation
- CMake 3.16 Release Notes — CMake 3.25.0-rc2 Documentation
- CMake 3.17 Release Notes — CMake 3.25.0-rc2 Documentation
- CMake 3.18 Release Notes — CMake 3.25.0-rc2 Documentation
- CMake 3.19 Release Notes — CMake 3.25.0-rc2 Documentation
- CMake 3.20 Release Notes — CMake 3.25.0-rc2 Documentation
I don’t work a lot on our CMake infrastructure so I haven’t looked a which of these features can be interesting for the LLVM Project. However in a previous thread some benefits were listed:
CMake 3.14 (released March 14th 2019):
- file(CREATE_LINK) to create hard or symbolic links
- if(DEFINED CACHE{VAR}) for checking if a cache variable is defined
- $<IN_LIST:…> generator expression correctly handles empty argument
- Fixes for object library linking propagation
- Link options to manage position independent executables added automatically
CMake 3.15 (released July 17th 2019):
- list(PREPEND), list(POP_FRONT) and list(POP_BACK) added
- New message() types NOTICE, VERBOSE, DEBUG and TRACE
- string(REPEAT) added
- MSVC_RUNTIME_LIBRARY target property and CMAKE_MSVC_RUNTIME_LIBRARY variable to select the runtime library type for MSVC
- $<C_COMPILER_ID:…>, $<CXX_COMPILER_ID:…>, $<COMPILE_LANGUAGE:…>, and $<PLATFORM_ID:…> generator expressions support matching one value from a list
- $<COMPILE_LANG_AND_ID:…> generator expression added
- $FILTER:list,INCLUDE|EXCLUDE,regex generator expression added
- $<REMOVE_DUPLICATES:list> generator expression added
- New $<TARGET_FILE*> generator expressions added: $<TARGET_FILE_PREFIX:…>, $<TARGET_FILE_BASE_NAME:…>, $<TARGET_FILE_SUFFIX:…>, $<TARGET_LINKER_FILE_PREFIX:…>, $<TARGET_LINKER_FILE_BASE_NAME:…>, $<TARGET_LINKER_FILE_SUFFIX:…>, $<TARGET_PDB_FILE_BASE_NAME:…>
- $<TARGET_OBJECTS:…> generator expression supports executables and static, shared, and module libraries
CMake 3.16 (released November 26th 2019):
- Support for generator expressions in BUILD_RPATH and INSTALL_RPATH
CMake 3.17 (released March 20th 2020):
- Ninja Multi-Config generator, which among other things would greatly simplify LLVM_OPTIMIZED_TABLEGEN
- foreach(ZIP_LISTS) added to iterate multiple lists simultaneously
- New message() keywords CHECK_START, CHECK_PASS, and CHECK_FAIL
- INSTALL_NAME_DIR supports generator expressions
[1] Upgrading LLVM's minimum required CMake version - #10 by petrhosek