Skip to content

Won't build with CMake 4 as compatibility with CMake < 3.5 has been removed #942

@cpswan

Description

@cpswan

When I attempt to build cJSON with CMake 4(.0.2):

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.


-- Configuring incomplete, errors occurred!

If I apply this patch it's all good:

Index: cJSON/CMakeLists.txt
===================================================================
--- cJSON.orig/CMakeLists.txt
+++ cJSON/CMakeLists.txt
# CMake 4 has removed compatibility with CMake < 3.5
@@ -1,5 +1,5 @@
 set(CMAKE_LEGACY_CYGWIN_WIN32 0)
-cmake_minimum_required(VERSION 3.0)
+cmake_minimum_required(VERSION 3.5)

 project(cJSON
     VERSION 1.7.18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions