DaveGamble / cJSON

Ultralightweight JSON parser in ANSI C
MIT License
10.83k stars 3.22k forks source link

Use CMakePackageConfigHelpers to generate config.cmake #812

Open zeerd opened 11 months ago

zeerd commented 11 months ago

The current generated cJSONConfig.cmake holds hard coded path of libraries. Use CMakePackageConfigHelpers and @PACKAGE_INIT@ to make them suit for realy environment dynamically.

AndreaGreco commented 3 months ago

Found same issue of @zeerd and reported in #837 by @aurelien-enchanted-tools

Thats error raised by OpenEmmbedded build-System:

| NOTE: Installed into sysroot: []
| NOTE: Skipping as already exists in sysroot: ['cjson', 'openssl', 'gettext-minimal-native', 'glibc', 'zlib', 'binutils-cross-aarch64', 'cmake-native', 'gcc-cross-aarch64', 'gcc-runtime', 'libgcc', 'libtool-native', 'm4-native', 'opkg-utils', 'quilt-native', 'libidn2', 'texinfo-dummy-native', 'linux-libc-headers', 'curl', 'libunistring', 'openssl-native', 'ncurses-native', 'zlib-native', 'flex-native', 'gnu-config-native', 'make-native', 'ninja-native', 'patch-native', 'perl-native', 'pseudo-native', 'bzip2-native', 'xz-native', 'zstd-native', 'attr-native', 'gdbm-native', 'gmp-native', 'libmpc-native', 'mpfr-native', 're2c-native', 'sqlite3-native']
| DEBUG: Python function extend_recipe_sysroot finished
| DEBUG: Executing shell function do_configure
| -- The C compiler identification is GNU 13.3.0
| -- The CXX compiler identification is GNU 13.3.0
| -- Detecting C compiler ABI info
| -- Detecting C compiler ABI info - done
| -- Check for working C compiler: /work/build-image/tmp-glibc/work/cortexa53-crypto-oe-linux/my-software-example/1.0/recipe-sysroot-native/usr/bin/aarch64-oe-linux/aarch64-oe-linux-gcc - skipped
| -- Detecting C compile features
| -- Detecting C compile features - done
| -- Detecting CXX compiler ABI info
| -- Detecting CXX compiler ABI info - done
| -- Check for working CXX compiler: /work/build-image/tmp-glibc/work/cortexa53-crypto-oe-linux/my-software-example/1.0/recipe-sysroot-native/usr/bin/aarch64-oe-linux/aarch64-oe-linux-g++ - skipped
| -- Detecting CXX compile features
| -- Detecting CXX compile features - done
| -- Found CURL: /work/build-image/tmp-glibc/work/cortexa53-crypto-oe-linux/my-software-example/1.0/recipe-sysroot/usr/lib/libcurl.so (found version "8.7.1")
| CMake Error at /work/build-image/tmp-glibc/work/cortexa53-crypto-oe-linux/my-software-example/1.0/recipe-sysroot/usr/lib/cmake/cJSON/cjson.cmake:86 (message):
|   The imported target "cjson" references the file
| 
|      "/usr/lib/libcjson.so.1.7.18"
| 
|   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
| 
|      "/work/build-image/tmp-glibc/work/cortexa53-crypto-oe-linux/my-software-example/1.0/recipe-sysroot/usr/lib/cmake/cJSON/cjson.cmake"
| 
|   but not all the files it references.
| 
| Call Stack (most recent call first):
|   /work/build-image/tmp-glibc/work/cortexa53-crypto-oe-linux/my-software-example/1.0/recipe-sysroot/usr/lib/cmake/cJSON/cJSONConfig.cmake:14 (include)
|   CMakeLists.txt:15 (find_package)
| 
| 
| -- Configuring incomplete, errors occurred!
| WARNING: exit code 1 from a shell command.

Seems that cmake try search in /usr/lib/libcjson.so.1.7.18 instead of in /work/build-image/tmp-glibc/work/cortexa53-crypto-oe-linux/my-software-example/1.0/recipe-sysroot/ Maybe because using CMAKE_INSTALLFULL instead of CMAKEINSTALL

Add to issue @kraj that is OpenEmmbedded maintainer of cJSON

Seems that @FSMaxB made first implementation of cJSONConfig.cmake.in and friends. Is there some reason to use CMAKE_INSTALL_FULL instead of CMAKE_INSTALL