This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Warn when the version is older than 3.20.0.
ClosedPublic

Authored by Mordante on Nov 9 2022, 9:09 AM.

Details

Summary

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

Diff Detail

Event Timeline

Mordante created this revision.Nov 9 2022, 9:09 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald Transcript
Mordante edited the summary of this revision. (Show Details)Nov 9 2022, 9:14 AM
Mordante added reviewers: Restricted Project, Restricted Project, tstellar, mehdi_amini, MaskRay, ChuanqiXu, to268, kparzysz, thieta, tschuett, mgorny, stellaraccident, mizvekov, ldionne.
Mordante published this revision for review.Nov 9 2022, 9:15 AM
Herald added projects: Restricted Project, Restricted Project, Restricted Project, Restricted Project, Restricted Project, Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptNov 9 2022, 9:15 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
thieta accepted this revision as: thieta.Nov 9 2022, 9:17 AM

I think this is fine as we have discussed before. But I really dislike the code duplication for the check. We could put it in a include() I guess - but maybe it's not worth it.

I think this is fine as we have discussed before. But I really dislike the code duplication for the check. We could put it in a include() I guess - but maybe it's not worth it.

I wanted to make sure it shows up in different build scenarios. The code is temporary, once we switch to CMake 3.20.0 we can just change the cmake_minimum_required and remove these verbose blocks.

MaskRay accepted this revision as: MaskRay.EditedNov 9 2022, 9:39 AM

I think if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) checks for standalone builds is not necessary. The check in llvm/CMakeLists.txt suffices.
It's unlikely the users will use different cmake versions to configure llvm and a subproject like clang so that: when the cmake used for llvm satisfies the check, the cmake used for clang does not satisfy the check.

I think if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) checks for standalone builds is not necessary. The check in llvm/CMakeLists.txt suffices.
It's unlikely the users will use different cmake versions to configure llvm and a subproject like clang.

I can remove the others, but we need to keep the one in runtimes/CMakeLists.txt too. The runtimes (libc++, libc++abi, and libunwind) can be build without building or configuring LLVM.

ldionne accepted this revision.Nov 9 2022, 12:18 PM
This revision is now accepted and ready to land.Nov 9 2022, 12:18 PM

LGTM (sorry, it looks like I approved on behalf of all libc++ vendors but that wasn't my intention).

mgorny added inline comments.Nov 9 2022, 12:41 PM
clang/CMakeLists.txt
14

I wonder if we could move this to CMakePolicy.cmake, though admittedly you'd have to somehow avoid warning multiple times in in-tree builds.

ChuanqiXu accepted this revision.Nov 9 2022, 6:11 PM

LGTM. Thanks.

phosek accepted this revision.Nov 9 2022, 11:42 PM
phosek added a subscriber: phosek.

LGTM

to268 accepted this revision.Nov 11 2022, 8:02 AM

LGTM

stellaraccident accepted this revision.Nov 12 2022, 1:11 PM
thieta added a comment.Dec 6 2022, 8:32 AM

I think this is ready to land @Mordante or is there anything else missing?

Mordante marked an inline comment as done.Dec 11 2022, 11:15 AM

Thanks for all reviews!

I think this is ready to land @Mordante or is there anything else missing?

No but I've been quite busy. I needed some time to find the list of buildbot owners to mail after landing this.

clang/CMakeLists.txt
14

Yes I prefer to keep it this way. The warning will be removed once 3.20.0 or newer is mandated.

This revision was landed with ongoing or failed builds.Dec 11 2022, 11:19 AM
This revision was automatically updated to reflect the committed changes.
Mordante marked an inline comment as done.