-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Increase minimum required CMake version to 3.5, update Googletest to 1.13 #1351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Soon CMake 4.0 will be released. It requires that projects set a minimum required CMake version of 3.5. There is a workaround with an additional flag, but it would is better to increase the minimum required version.
Fix issue with CMake 4.0
|
Be aware that the warning from #1301 won't go away with this merge request. Newer versions of CMake will emit a deprecation warning for CMake versions older than 3.10. It wanted, I can provide a different merge request bumping the minimum required version to CMake 3.10. |
he support for CMake3.4 does not play well with our configuration, so * Use -DCMAKE_POLICY_VERSION_MINIMUM=3.14 * Statically link: target_compile_definitions(ebpfverifier PRIVATE YAML_CPP_STATIC_DEFINE) There's a pending PR regarding removal of CMake 3.4: jbeder/yaml-cpp#1351 Signed-off-by: Elazar Gershuni <[email protected]>
With the following declaration, I can't see any version warning with CMake 4.0 running in a MSYS2 environment ?? |
|
The warning (and error in CMake 4.0) is based on the <max> value in cmake_minimum_required not the <min> (unless a max isn't given obviously). So the warning mentioned would only appear if building with tests enabled since Google Test hasn't adopted the range syntax. For what it's worth setting Not personally attached to CMake 3.4 or anything like that, just trying to fight the seeming misinformation that Kitware is forcing the minimum to be raised. As the warning/error itself states, you just need to adopt the new policies which is what the range syntax does. |
Please make sure to bump the min. req. version to 3.10 to make it compatible with CMake 3.31. |
|
@jbeder Can you please review? |
It's the max version that matters, not the min version. Max above 3.10 will produce no warning currently. |
No. CMake 3.5 is considered outdated and CMake 4.0 refuses to work with it as a minimum required version by default. Increasing the mininmum version is the right thing to do. Setting a max version is ignoring the behavior of newer CMakes. Setting a max at or 3.30 (not 3.10) will silence the deprecation warning. It is no long-term solution, it is just looking away. |
|
No, that is not true. CMake only cares about your maximum version, because what it really cares about is the policies. CMake does not refuse to work with a minimum version of <3.5. It refuses to work with a maximum version of <3.5, since that means you need <3.5 policies, and those polices were removed in CMake 4.0. If you don't set a maximum version, then it's based on the minimum version (because that's also the maximum version). The maximum version sets the policies to that version. If your project builds with those policies, then you will be supported until CMake drops support for those polices. So setting 3.30 as the maximum version means you'll be supported until all the policies from 3.30 and earlier are removed. This will be supported: cmake_minimum_required(VERSION 2.12...4.0)Much, much longer than this will be: cmake_minimum_required(VERSION 3.5...3.9)In fact, it will be supported exactly as long as: cmake_minimum_required(VERSION 4.0)(The downside of a large range is you need to test both ends of it, and you don't get to use newer CMake features, and there are a ton of great CMake features, especially in 3.24 with the ability to find a package or download it if it's not found!) |
|
Henry, you are wrong.
|
|
To be clear, I highly recommend increasing the minimum version; even 3.10 is really old. I think what you've done in this PR is perfect for starters. But the upper bound is not a "means to suppress" warnings. It is an indication of what you've tested on. It changes the policies just like the minimum version by itself would do. CMake sets the policies to the highest version in the range that it supports. The min version literally doesn't matter. You can set 2.6 as your min version for all CMake cares if you have a max version. For example, in 3.27, they "removed" the FindPythonLibs module. That means if you set your maximum version to 3.27 or later, then the FindPythonLibs module will be gone when running on those versions of CMake. If you have your maximum version lower than 3.27, though, then that "missing" module will still be there, since CMake will never change your build when upgrading the CMake version you are running with after the maximum version it knows you've tested with.
Here's my current recommendation, copied from my Modern CMake book, which I updated when 4.0 was released:
|
|
@henryiii I finally got around to skimming this thread, and since you're an expert, can you tell me either:
|
|
I am not reviewing the google test changes (which sound great, but it's nearly 300 files so I'm just assuming it's good), but the CMake updates look great and are thorough. As long as you have CI that use a reasonably recent version of CMake, I think it's great, though a followup could probably bump the min to 3.10 or 3.15 and the max to 4.0. Having a CI run with the minimum and the maximum is a good idea. You don't have to go as far as pybind11 were we run the configure step with every single version in the range, though. :) |
|
FYI, 3.12 added CONFIGURE_DEPENDS to GLOB, I notice #1349 mentions globbing, so updating to 3.15+ in a followup would allow you to use CONFIGURE_DEPENDS to improve the behavior of globbing (you can also get rid of globbing, but I like to at least compare the hard-coded list with a glob, to help catch added files that are forgotten in the hard-coded list). You can see a high level overview of what's new in each version here. |
|
Thanks for merging! Do you consider creating a new version of yaml-cpp to help packagers with getting the new required CMake version? Further, I created #1358 to follow up on Henry's suggestion to require CMake 3.15..4.0. |
CMake 4.0 has be released. It requires that projects set a minimum required CMake version of 3.5. There is a workaround with an additional flag, but it would is better to increase the minimum required version.
Googletest 1.13 requires CMake 3.5, too.
Only tested with CMake, not with Bazel!