yaml-cpp icon indicating copy to clipboard operation
yaml-cpp copied to clipboard

Does not build with CMake 4.0.

Open junhaoliao opened this issue 1 year ago • 15 comments

The project now does not build with the latest version 4.0.0 of CMake

CMake Error at submodules/yaml-cpp/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.

junhaoliao avatar Apr 01 '25 05:04 junhaoliao

Changing the <MIN> bound from 3.4 to 3.5 resolved the issue: https://github.com/jbeder/yaml-cpp/blob/28f93bdec6387d42332220afa9558060c8016795/CMakeLists.txt#L1-L3

Maybe 3.5 is a better minimum now. :)

junhaoliao avatar Apr 01 '25 05:04 junhaoliao

Just creating some noise here; CMake 4.0 is currently being deployed all over the place (e.g. packaged alongside other tools), and this deprecation is creating build errors for projects which directly or transitively depend on yaml-cpp. A version bump to at least 3.5 should occur ASAP. CC @jbeder.

mortbopet avatar Apr 01 '25 09:04 mortbopet

@junhaoliao Are you building the release version and quoting the latest master source code? CMake 4.0 builds the latest master without error for me. The error description even specifically says what's on master is a recommended solution.

                                            Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

Blzut3 avatar Apr 02 '25 23:04 Blzut3

The minimum version as referenced in https://github.com/jbeder/yaml-cpp/issues/1352#issuecomment-2768136519 is the current state of master branch. This PR is needed => https://github.com/jbeder/yaml-cpp/pull/1351

pfeerick avatar Apr 03 '25 03:04 pfeerick

My project, which also using this library as a submodule, is hitting this problem while its build test with github actions:

 Submodule path 'yaml-cpp': checked out 'c73ee34704c512ebe915b283645aefa9f424a22f'
CMake Error at external_libs/yaml-cpp/CMakeLists.txt:2 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

So hoping the modification on this line should be done very soon.

mnagaso avatar Apr 03 '25 05:04 mnagaso

@mnagaso the commit that fixed this was the very next commit after the 0.8 release tag: c2680200486572baf8221ba052ef50b58ecd816e It looks like you're currently using some commit between 0.7 and 0.8. If you're not using the bundled Google Test (or building without tests) that commit should be enough to solve your issue.

Blzut3 avatar Apr 03 '25 05:04 Blzut3

Hi do we have a target date for the fix?

sidhant-microsoft avatar Apr 04 '25 13:04 sidhant-microsoft

@Blzut3 Thank you for letting me know about the update! I will verify if I am using the latest one.

mnagaso avatar Apr 04 '25 13:04 mnagaso

We have the same issue. Azure updated their Ubuntu agent so it uses CMake 3.31 now, which complains about the cmake_minimum_required(VERSION 3.4...3.14) line. We use yaml-cpp from conan center.

A patch release 0.8.1 with followin PR would fix the issue: https://github.com/jbeder/yaml-cpp/pull/1351

mskripnik avatar Apr 04 '25 14:04 mskripnik

@mskripnik Isn't the error pointing to the bundled gtest directory? I believe Conan sets BUILD_TESTING to ON by default. With testing off (or presumably using a system copy of gtest) yaml-cpp master should configure and build with CMake 4.0 no warnings or errors.

Blzut3 avatar Apr 04 '25 21:04 Blzut3

3.4...3.14 is perfectly valid. The upper bound needs to be 3.5 or higher, not the lower bound. Why is the upper bound only 3.14, though? That's really old (most projects require 3.15+ these days), and eventually that will start producing warnings, and eventually error. The upper bound is the one that's most important to update.

henryiii avatar Apr 28 '25 18:04 henryiii

Why is the upper bound only 3.14, though?

The person who submitted the change was just being conservative in regards to not accepting policies if they couldn't verify the project was definitely unaffected.

Blzut3 avatar Apr 28 '25 22:04 Blzut3

That’s a good idea, you should only put a bound here that you actually test, that’s the point of it. But it does need to be updated and tested!

henryiii avatar Apr 28 '25 23:04 henryiii

I think the issue can be closed since it has been resolved: https://github.com/jbeder/yaml-cpp/commit/c9371de7836d113c0b14bfa15ca70f00ebb3ac6f

I think it's time to create a new tag; version 0.8.0 has this problem.

mosfet80 avatar Sep 21 '25 18:09 mosfet80

Running into this problem. Would be nice to bump the tag...

sjalloq avatar Nov 22 '25 09:11 sjalloq