json-c 0.16r1 breaks CMake's find_package(json-c) due to non existing /usr/lib/libjson-c.a
Reproducer:
Given a simple CMakeLists.txt
that contains:
cmake_minimum_required(VERSION 3.25)
project(foo C)
find_package(json-c)
apk add cmake json-c-dev gcc make libc-dev
# Note that json-c-static is *not* installed
cmake .
outputs
-- The C compiler identification is GNU 12.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
CMake Error at /usr/lib/cmake/json-c/json-c-targets.cmake:96 (message):
The imported target "json-c::json-c-static" references the file
"/usr/lib/libjson-c.a"
but this file does not exist. Possible reasons include:
* The file was deleted, renamed, or moved to another location.
* An install or uninstall procedure did not complete successfully.
* The installation package was faulty and contained
"/usr/lib/cmake/json-c/json-c-targets.cmake"
but not all the files it references.
Call Stack (most recent call first):
/usr/lib/cmake/json-c/json-c-config.cmake:37 (include)
CMakeLists.txt:3 (find_package)
-- Configuring incomplete, errors occurred!
This is due to commit 4e34d4da . Package 0.16r0 didn't have that issue. Installing json-c-static
works around the issue.
CC @alice