151 Commits

Author SHA1 Message Date
JaisonZheng
653a12c7c2 Fix memory leak on macOS by auto-enabling NEWLOCALE_NEEDS_FREELOCALE
macOS's newlocale() does not follow POSIX specification - it doesn't
reuse the passed locale_t, causing ~1,472 bytes leak per json_tokener_parse() call.

This is the same issue as #668 (FreeBSD). The existing workaround works,
but macOS was not auto-detected.

Tested with AddressSanitizer: leak drops from 1,472,000 bytes to ~120 bytes
(system init only).
2026-01-21 17:28:20 +08:00
Michele Locati
b01b5b701b Add VERSIONINFO to libjson-c.dll 2026-01-18 20:23:50 +01:00
Tyler Erickson
461d9f90c4 bug: Fixing Cmake build when using clang-cl
Clang-cl will fail to build and produce warnings about redefining existing symbols, mostly for float.h and math.h compatibility.

To resolve this, this moves the clang-cl detection earlier in the CMakeLists.txt so that CLANG_CL can be checked properly where there is an existing MSVC workaround for these symbols.
This resolves the build using the latest clang-cl from the LLVM clang repo as well as clang-cl that can be installed with MSVC 2022.

Signed-off-by: Tyler Erickson <tyler.erickson@seagate.com>
2025-10-20 11:39:04 -06:00
Cameron Armstrong (Nightfox)
ca1a6b0cc9 Add support for MorphOS 2024-12-24 10:09:50 +08:00
Cameron Armstrong (Nightfox)
daff6eb746 Remove linking to libamiga and libc 2024-12-24 10:09:50 +08:00
Cameron Armstrong (Nightfox)
254b5abef8 Do not use duplocale if building for libnix because it isnt supported yet 2024-12-24 10:09:50 +08:00
Cameron Armstrong (Nightfox)
d31d635af1 Clean up CMakeLists.txt and remove Amiga specific locale.h guard 2024-12-24 10:09:50 +08:00
Cameron Armstrong
f928e7c0fa Get working ror libnix and clib2 2024-12-24 10:09:50 +08:00
Cameron Armstrong
4feebc1cd6 Add support for Commodore Amiga 2024-12-24 10:09:50 +08:00
Eric Hawicz
e9bd26d568 Update the master branch to version 0.18.99 2024-09-15 13:06:06 -04:00
Pavel Zwerschke
906d1581de Update CMakeLists.txt 2024-08-29 10:55:02 +02:00
Pavel Zwerschke
9b8d170d1f Build pkg-config for msvc as well 2024-06-18 00:11:13 +02:00
Eric Haszlakiewicz
781675758f Although CMAKE_C_COMPILER_FRONTEND_VARIANT is defined, it's not always set to some value. Fix builds for cases when it's blank. 2024-04-28 17:15:42 +00:00
Eric Hawicz
e3464a2ab4 Issue #829: attempt to detect clang-cl.exe and pass MSVC-compatile command line arguments. 2024-03-29 22:40:45 -04:00
evo
eef983b1df Update CMakeLists.txt
Replace with `execute_process` available on v3.0+
2023-12-17 11:19:20 +03:00
evo
c0cf4bc23b Update CMakeLists.txt
Now saved to variable.
2023-12-17 00:32:21 +03:00
evo
e85c8ada54 Fix ECHO_OUTPUT_VARIABLE 2023-12-17 00:23:51 +03:00
evo
2c84476c77 [CMP0153](https://cmake.org/cmake/help/latest/policy/CMP0153.html) 2023-12-12 16:28:41 +03:00
Rolf Eike Beer
c4a615a052 CMake: request all policies up to CMake 3.12 being set to NEW 2023-09-05 14:31:24 +02:00
Rolf Eike Beer
990acb4e19 CMake: remove needless policy setting
These policies were all introduced before CMake 3.9, so they will automatically
be initialized to the new behavior when requesting a minimum version of 3.9.
2023-09-05 12:14:46 +02:00
Eric Haszlakiewicz
502522a93d Update the master branch to version 0.17.99 2023-08-12 19:08:59 +00:00
Eric Hawicz
1ee12100b6 PR #679: add workaround for old compilers w/o stdint.h (i.e. VS2008 and earlier) 2023-08-05 22:11:30 -04:00
Sergey Sharshunov
bef40a342e Added option to disable app build 2023-08-04 19:46:50 +05:00
Eric Hawicz
efc530594b Create a json_pointer_private.h and move a few things there, fix test warnings, note array_list_insert_idx is private. 2023-07-31 22:18:03 -04:00
Alexandru Ardelean
538b046884 json_patch: add first implementation only with patch application
Initially I wanted to also do a function that generates the JSON patch from
two JSON documents, but even just applying the JSON patch was a bit of
work, especially when needing to satisfy all the test-cases.

This change defines all the operation in the RFC6902. The addition isn't
too big (for the json_patch_apply() function), as part of the heavy lifting
is also done by JSON pointer logic.

All the ops were tested with the test-cases defined at:
  https://github.com/json-patch/json-patch-tests

RFC6902: https://tools.ietf.org/html/rfc6902

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2023-07-31 22:18:01 -04:00
Eric Hawicz
71d845e819 Issue #668: add the option to specify "cmake -DUSELOCALE_NEEDS_FREELOCALE=1" to work around a bug in older versions of FreeBSD (<12.4). 2023-07-30 13:38:15 -04:00
Eric Hawicz
c8b0a90e95 Issue #808: turn off -Wshorten-64-to-32 for clang builds (aka iOS builds) to workaround "implicit conversion loses integer precision" warnings. 2023-07-30 11:38:01 -04:00
Eric Hawicz
bdfdb5fe10 Skip apps when we're included in someone else's build. Inspired by ssrlive in PR #813. 2023-07-06 20:56:49 -04:00
Eric Haszlakiewicz
d0f32a5a43 Stop linking a copy of _json_c_strerror() (strerror_override.c) into the tests.
That hasn't been needed since since commit 6068d3f, which changed that code to
 check an env var instead ("_JSON_C_STRERROR_ENABLE").
Fixes issue #812, about dup symbols in static builds with clang.
2023-03-28 23:08:39 +00:00
Eric Haszlakiewicz
d1716fe431 Bump up the minimum cmake version to 3.9.
This gets us up to a version that supports features we're already using
(i.e. add_compile_options), but stops short of a cmake that requires
c++11, which some OSes still don't support.
Closes issue #774
2023-02-23 01:01:14 +00:00
Eric Hawicz
343f24f920 Merge pull request #804 from yrashk/cmp-0042
Problem: cmake 3.25.1 warns about CMP0042 not being set
2022-12-27 09:32:33 -05:00
Yurii Rashkovskii
3cc0c47221 Problem: cmake 3.25.1 warns about CMP0042 not being set
Solution: set it explictly to OLD behavior
2022-12-23 15:05:46 -08:00
Yurii Rashkovskii
debe8b70b7 Problem: modern CMake warns about version 2.8
The warning is as follows:

```
Compatibility with CMake < 2.8.12 will be removed from a future version of CMake.
```

Solution: set it at 2.8.12
2022-12-23 14:33:31 -08:00
Eric Haszlakiewicz
253a5fa99d Issue #705: disable locale handling when building for a uClibc system because its duplocale() function (intentionally) crashes. 2022-07-30 20:27:35 +00:00
Eric Haszlakiewicz
d28ac67dde Fix issue #775 - use a loop instead of list(TRANSFORM ...) to support cmake < 3.12. 2022-06-27 02:15:24 +00:00
Eric Haszlakiewicz
2f0942bdd7 Specify dependent libraries, including -lbsd, in a more consistent way so linking against a static json-c works better. Related issue #766
Use target_link_libraries, plus fill in Libs.private in json-c.pc so pkg-config --static --libs works appropriately.
Also, only link against libbsd when arc4random is actually found there.
2022-05-30 15:30:11 +00:00
Eric Haszlakiewicz
6ba1adf8ef Include the tests and apps directories at the _end_, since order in the
cmake rules matters, and fix compile warnings now that we're building
those sources with all the regular flags.
2022-05-30 14:33:16 +00:00
Eric Haszlakiewicz
de5a64888a Update the master branch to version 16.99 2022-04-14 12:29:39 +00:00
Tobias Stoeckmann
543a8eb5f9 Fix typos
Mostly found with codespell and during code review.
2022-03-06 16:07:36 +01:00
Eric Haszlakiewicz
a5c2e11460 Cause the cmake include dirs to also have ${CMAKE_INSTALL_INCLUDEDIR}/json-c, so downstream packages that use cmake to link against json-c can choose whether to include headers as just e.g. #include <json_object.h>, if they care to do so.
Update the README to better explain this, and make a few other tweaks.
2021-12-22 02:52:37 +00:00
Robert Bielik
21f767f63f Add target include dirs for static library as well 2021-11-11 09:37:53 +01:00
DeX77
d6d4b71d7d * don't assume includedir
This change syncs the public header include install location with what gets written into pkgconfig file.
2021-10-15 11:12:39 +02:00
Pawday
e91e4cc9fb Setted cmake "uninstall" target to exist in unix like operating systems only 2021-07-26 18:52:29 +03:00
Eric Haszlakiewicz
8c727e5ce1 Only define an "uninstall" target if it's not already defined (e.g. by projects that include json-c) 2021-07-25 15:11:11 +00:00
Eric Haszlakiewicz
75bf657cc2 If inttypes.h is present, use it, even on Windows. 2021-06-13 21:12:22 +00:00
Eric Hawicz
cd7109f767 Merge pull request #696 from ssrlive/master
To avoid target exe file export JSON functions.
2021-05-01 15:21:31 -04:00
Alexandru Ardelean
8abeebc9b2 json_pointer: allow the feature to be disabled
Some users may not want to included it in their build/system. So allow a
cmake symbol to disable it.

A user can do 'cmake -DDISABLE_JSON_POINTER=ON <json_c_root_dir>' and
disable the json_pointer functionality. That saves about 17 KB (on an
x86_64) machine. This may be useful on smaller embedded systems; even
though the saving would be fewer kilobytes.

One thing that also needs to change a bit, is that the 'json.h' be
autogenerated via cmake, in order to conditionally include that
"json_pointer.h" file.

Signed-off-by: Alexandru Ardelean <ardeleanalex@gmail.com>
2021-04-16 11:49:38 +03:00
ssrlive
ba181548bc To avoid target exe file export JSON functions. 2021-03-02 14:27:40 +08:00
Eric Haszlakiewicz
041cef434a Add a DISABLE_EXTRA_LIBS option to skip using libbsd, per @neheb's request on issue #692/commit 0f61f692. 2021-02-15 20:19:56 +00:00
Eric Haszlakiewicz
0f61f6921b Iesue #692: use arc4random() if it's available (in libc on BSD systems, and libbsd on Linux). 2021-01-13 01:57:25 +00:00