cJSON
cJSON copied to clipboard
CMake ≥ 3.13 - Policy CMP0077 (option() behavior)
Hi,
I'm adding cJSON to a project using CMake version 3.25.2
My project is on a Raspberry Pico microcontroller and I need a static library. In my original CMakeLists.txt, I added set(BUILD_SHARED_LIBS OFF) then add_subdirectory(cJSON).
At building, cmake awared me of an old behavior of option which cleared BUILD_SHARED_LIBS. (cf. CMake CMP0077)
[cmake] CMake Warning (dev) at cJSON/CMakeLists.txt:112 (option):
[cmake] Policy CMP0077 is not set: option() honors normal variables. Run "cmake
[cmake] --help-policy CMP0077" for policy details. Use the cmake_policy command to
[cmake] set the policy and suppress this warning.
[cmake]
[cmake] For compatibility with older versions of CMake, option is clearing the
[cmake] normal variable 'BUILD_SHARED_LIBS'.
[cmake] This warning is for project developers. Use -Wno-dev to suppress it.
I fixed this issue by adding set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) to my parent CMakeLists.txt. However, there is a fix possible directly in cJSON's CMakeLists.txt with cmake_policy(SET CMP0077 NEW).
I'll make a PR, you'll see if it is relevant or not