- there is no need for _ref_count to be uint_fast32_t (the compiler
might decide to use a 64-bit int). make it uint32_t instead.
- reorder the 32-bit integer fields (o_type and _ref_count) so that
there is no wasted 4-byte gap after each of them.
Now json-c can be bundled to any cmake-based project and used with
couple lines of code:
add_subdirectory(json-c EXCLUDE_FROM_ALL)
target_link_libraries(MyProject json-c)
This changes allows to use #include <json-c/json.h>
instead of just #include <json.h>
This is normally possible but in some tricky case
this usage is broken without this change.
Here is the case that I encountered. I had to
compile json-c fresh version for some investigations
on newer versions. Then I installed it on my local
environment using option --prefix. After that I
had 2 versions:
- the system wide version in usual locations
/usr/lib and /usr/include
- mine in my HOME directory
Then, as I'm used to include <json-c/json.h>, the
included iheder's version was the system wide one
whereas the linked lib was mine.
Signed-off-by: Jose Bollo <jose.bollo@iot.bzh>
This patch provides a CMakeLists.txt file to build JSON-C library without relying on auto-tools support. This makes the build a bit more portable and cleaner.
It can detect headers and symbols and generate config.h header file based on those detections. It cannot yet handle ctest(1) as the testing itself depends on comparing the output against files. Testing would need some creative abuse of CMake :) This will be provided a few patches later and may possibly involve refactoring test cases.
The patch has been tested on GCC 4.8.5 (Linux), GCC 7.2.0 (MinGW) and Microsoft Visual C++ 16.0 (2010?) locally. Also, compiles correctly on Travis CI and AppVeyor without errors.
When building the project using cmake then installing it. The
definitions in `json_object_iterator.h` are required but not installed
by the cmake install rule. This patch adds the `json_object_iterator.h`
file to the list of files to install.
Signed-off-by: Keith Holman <keith.holman@windriver.com>
1. The windows dll will output the lib and dll, and rename the static
lib will have conflict on windows.
2. Delete rename code to dismiss the conflict.