Commit Graph

112 Commits

Author SHA1 Message Date
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
Rosen Penev
987d3b2c86 fix compilation with clang
Fixes the following warning:

json_pointer.c:230:7: warning: implicit declaration of function
    'vasprintf' is invalid in C99 [-Wimplicit-function-declaration]
            rc = vasprintf(&path_copy, path_fmt, args);
2020-12-17 19:59:37 -08:00
Alan Coopersmith
6cf4847796 Use getrandom() if available in json_c_get_random_seed
Lower overhead than opening & reading from /dev/urandom, and works
in chroots and other situtations where /dev/urandom is not available.
Falls back to existing methods when kernel doesn't support the syscall.
2020-07-31 08:28:07 -07:00
Eric Haszlakiewicz
de02d09c32 Update the master branch to version 0.15.99 2020-07-26 15:26:53 +00:00
Eric Haszlakiewicz
730e3d044f Issue #594 - provide an OVERRIDE_GET_RANDOM_SEED cmake variable to override json_c_get_random_seed() for embedded platforms where time(NULL) doesn't work.
Example:
mkdir build && cd build
cmake -DOVERRIDE_GET_RANDOM_SEED='do { extern uint32_t getMsTicks(void); int ms = getMsTicks() * 433494437; return ms; } while(0)' ..
2020-07-22 02:25:03 +00:00
Simon McVittie
c2c94024f5 build: Add symbol versions to all exported symbols
With this version script, newly-linked binaries that depend on the
json-c shared library will refer to its symbols in a versioned form,
preventing their references from being resolved to a symbol of the same
name exported by json-glib or libjansson if those libraries appear in
dependency search order before json-c, which will usually result in
a crash. This is necessary because ELF symbol resolution normally uses
a single flat namespace, not a tree like Windows symbol resolution.
At least one symbol (json_object_iter_next()) is exported by all three
JSON libraries.

Linking with -Bsymbolic is not enough to have this effect in all cases,
because -Bsymbolic only affects symbol lookup within a shared object,
for example when json_object_set_serializer() calls
json_object_set_userdata(). It does not affect calls from external
code into json-c, unless json-c was statically linked into the
external caller.

This change will also not prevent code that depends on json-glib or
libjansson from finding json-c's symbols and crashing; to prevent
that, a corresponding change in json-glib or libjansson would be needed.

Adding a symbol-version is a backwards-compatible change, but once
added, removing or changing the symbol-version on a symbol would be an
incompatible change that requires a SONAME bump.

Resolves: https://github.com/json-c/json-c/issues/621
(when combined with an equivalent change to libjansson).

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-07-01 18:24:26 +01:00
Eric Hawicz
99bb2121c6 Merge pull request #632 from json-c/json_object-split
Json object split
2020-06-20 13:04:32 -04:00
Micah Snyder
60494684a1 Issue #508: -fPIC to link libjson-c.a with libs
json-c has symbol collisions with other popular C JSON libraries.
To prevent random crashes in downstream applications that may use a
library which depends on json-c, the solution is to statically link
libjson-c.a into those libraries.

`-fPIC`/`-fPIE` is required when building a `.a` so it can be linked
into a `.so`.
2020-06-14 12:35:49 -04:00
Eric Haszlakiewicz
0a16b23adf Fix typo in previous commit to check for SSIZE_T on MSVC. 2020-06-07 15:19:29 +00:00
Eric Haszlakiewicz
eab1375123 Change CMakeLists.txt to look for SSIZE_T on MSVC too. 2020-06-07 03:36:59 +00:00
Eric Haszlakiewicz
0fc9d91277 Kick json_type_string out of struct json_object.
The default is now that string data is stored inline at the end of json_object, though to allow for json_object_set_string() to set a _longer_ string, we still need to allow for the possibility of a separate char * pointer.
All json types have been split out now, next step it cleanup.
2020-06-07 02:56:59 +00:00
Eric Haszlakiewicz
fe308b8862 Issue #626: Restore compatibility with cmake 2.8 by adjusting quoting and explicitly defining the PROJECT_VERSION* variables. 2020-05-30 19:37:46 +00:00
Björn Esser
1e94da779a CMake: Fix grammar: written -> wrote. 2020-05-18 20:36:16 +02:00
Björn Esser
61e2bae511 doc: Move Doxyfile into doc subdir 2020-05-18 20:36:16 +02:00
Björn Esser
8f3592b3d5 CMake: Fix out-of-tree build for Doxygen documentation. 2020-05-18 18:20:33 +02:00
Björn Esser
76dd99abb2 CMake: Re-format config-option block and re-order it alphabetically. 2020-05-18 12:34:08 +02:00
Björn Esser
78642dcb9b CMake: Add an option to disable the use of thread-local storage.
Using thread-local storage may not be desired in all environments
and/or use-cases, thus there should be an option to disable its use
on purpose.

Fixes #451.
2020-05-18 12:27:19 +02:00
Eric Haszlakiewicz
06742d6277 Issue #600: don't rename the static library on Windows, it _needs_ to have a different name because the dll build also creates a "json-c.lib" file. 2020-05-10 03:58:51 +00:00
Eric Haszlakiewicz
4f43a077a4 Issue #598: avoid building static libraries twice. 2020-05-10 03:48:45 +00:00
hofnarr
558ef8609c cmake: change variable name 2020-05-08 02:19:38 +03:00
hofnarr
929d74512a cmake: add list for build targets 2020-05-08 02:16:52 +03:00
dota17
e97fc20bfd update 2020-05-07 14:50:43 +08:00
dota17
952db0f397 support to build both static and shared libraries 2020-05-06 14:46:47 +08:00
Eric Haszlakiewicz
00272292a7 The json_parse command line app doesn't build on Windows, disable it. 2020-04-21 21:35:41 +00:00
Eric Haszlakiewicz
55d053118e Add an apps directory, and a json_parse program to parse an input file and report on memory usage.
This is intended to provide a way, during development, to test out the memory
and performance impacts of a change.
2020-04-21 03:57:56 +00:00
Eric Haszlakiewicz
fa6bc1e2d7 Issue #471: always create directories with mode 0755, regardless of umask. 2020-04-21 03:19:17 +00:00
Eric Haszlakiewicz
8b511c402b Issue #585: don't install config.h 2020-04-21 01:13:21 +00:00
Eric Haszlakiewicz
2babb5b780 Update the master branch to version 0.0.14.99 2020-04-19 03:57:08 +00:00
Jehan
8c33d1c3c9 CMakeLists: do not enforce strict prototypes on Windows.
On Windows, or at least when cross-built with Mingw-w64, build fails
because strict prototype fails on an included file (thus nothing we can
do about in json-c code):

> from /home/jehan/dev/src/json-c/json_util.c:44:
> /home/jehan/.local/share/crossroad/roads/w64/json-c/include/minwindef.h:196:3: error: function declaration isn't a prototype [-Werror=strict-prototypes]
>   196 |   typedef INT_PTR (WINAPI *FARPROC) ();
>       |   ^~~~~~~
> /home/jehan/.local/share/crossroad/roads/w64/json-c/include/minwindef.h:197:3: error: function declaration isn't a prototype [-Werror=strict-prototypes]
>   197 |   typedef INT_PTR (WINAPI *NEARPROC) ();
>       |   ^~~~~~~
> /home/jehan/.local/share/crossroad/roads/w64/json-c/include/minwindef.h:198:3: error: function declaration isn't a prototype [-Werror=strict-prototypes]
>   198 |   typedef INT_PTR (WINAPI *PROC) ();
>       |   ^~~~~~~

Let's just disable the errors for Windows build.
2020-04-15 13:03:11 +02:00
Björn Esser
053eaa61d7 Fix CMake tests for enforced strict prototypes. 2020-04-14 20:42:32 +02:00
Björn Esser
d0dc3489dc Enforce strict prototypes. 2020-04-13 11:29:52 +02:00
Björn Esser
165e6f58fc CMake: Install pkgconfig file in proper location by default
The default location for pkconfig files on most systems is:
  ${CMAKE_INSTALL_LIBDIR}/pkgconfig

Thus the file should get installed in there by default.
2020-04-12 19:21:54 +02:00
Björn Esser
78cd37fb18 Clean trailing white-space. 2020-04-11 09:41:04 +02:00
Björn Esser
e756777c92 CMake: Check whether BSYMBOLIC is supported by the linker.
Linking with '-Bsymbolic-functions' is supported for ELF-binaries, only.
2020-04-10 17:29:35 +02:00
Björn Esser
58670ec64e CMake: Build Doxygen documentation out-of-tree. 2020-04-10 14:20:57 +02:00
Björn Esser
a989651bd4 CMake: Fix appending of linker flags.
There was a typo in `CMAKE_SHARED_LINKER_FLAGS`.
2020-04-10 14:16:02 +02:00
Eric Haszlakiewicz
545464322b Issue #568: fix the strtoll and strtoull handing so config.h ends up creating defines for those only when needed, which should exclude mingw environments. 2020-04-09 20:58:28 +00:00
Eric Haszlakiewicz
19bbf2c069 Add includes and split off json_types.h to help ensure that headers can be included in any order. 2020-04-06 13:55:27 +00:00
dota17
1204a1fded modify the doc target message 2020-03-19 10:27:27 +08:00
Eric Haszlakiewicz
e94eb90f9f Merge pull request #546 from dota17/make_unistall
Add uninstall target in cmake
2020-03-10 22:12:13 -05:00