-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Make compatible with CMake 4.0 #935
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
base: master
Are you sure you want to change the base?
Conversation
When trying to build with CMake 4.0, the following error is shown: CMake Error at 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. This change raises the minimum required CMake version to 3.5 and thus makes the project compatible with CMake 4.0
We are running into this issue as well in our projects. |
Same here, it seems some GHA runners are using cmake v3.31.6, some are using 4.0.0 (ubuntu-latest). |
Confirming this issue on my side 👍 |
In case it helps anyone else that is using cJSON in their project from CMake, you can work around this issue using a CMake file plus a patch file, something like this: CMake file:
Patch file:
And of course you can customize the CMake file and patch file to suit your project needs. -Benbuck |
I just saw that this PR only updates to 3.5 - it should probably be 3.10, otherwise cmake-4 will complain about more pending deprecation. It did for me when I reported what became our fix in Gentoo :) |
That is a valid point, and I am happy to change this pull request to make 3.10 the minimum required version if a maintainer of this repo requests it. I originally chose 3.5 because it is the lowest version that makes CMake 4.0 work, and building with CMake 3.5-3.9 is still possible. So in a sense, 3.5 is the more careful, conservative choice, and I thought it had more chance at getting accepted 🙂 |
Agree with @mvieth and 3.5 is also common choice if you look at other libraries. |
When trying to build with CMake 4.0, the following error is shown:
This change raises the minimum required CMake version to 3.5 and thus makes the project compatible with CMake 4.0