Compare commits

..

7 commits

Author SHA1 Message Date
Petri Lehtinen
96d160df90
Merge pull request #692 from Andrew-Au/cmake_update/revised/merge
Some checks failed
tests / autotools (clang, no, macos-latest) (push) Has been cancelled
tests / autotools (clang, yes, macos-latest) (push) Has been cancelled
tests / autotools (gcc, no, macos-latest) (push) Has been cancelled
tests / autotools (gcc, yes, macos-latest) (push) Has been cancelled
tests / cmake (clang, macos-latest) (push) Has been cancelled
tests / cmake (gcc, macos-latest) (push) Has been cancelled
tests / cmake (msvc, windows-latest) (push) Has been cancelled
tests / lint (push) Failing after 4s
tests / autotools (clang, no, ubuntu-latest) (push) Failing after 3s
tests / autotools (clang, yes, ubuntu-latest) (push) Failing after 3s
tests / autotools (gcc, no, ubuntu-latest) (push) Failing after 3s
tests / autotools (gcc, yes, ubuntu-latest) (push) Failing after 3s
tests / cmake (clang, ubuntu-latest) (push) Successful in 23s
tests / cmake (gcc, ubuntu-latest) (push) Successful in 20s
tests / valgrind (push) Failing after 17m10s
Use target-based cmake settings
2025-04-04 07:18:04 +03:00
Petri Lehtinen
aef13f87f1 Set minimum cmake version to 3.10 2025-04-04 07:15:20 +03:00
Petri Lehtinen
c16ac732e4
Merge pull request #712 from akheron/fix-lint
Some checks failed
tests / lint (push) Failing after 31s
tests / autotools (clang, no, ubuntu-latest) (push) Failing after 30s
tests / autotools (clang, yes, ubuntu-latest) (push) Failing after 29s
tests / autotools (gcc, no, ubuntu-latest) (push) Failing after 30s
tests / autotools (gcc, yes, ubuntu-latest) (push) Failing after 28s
tests / cmake (clang, ubuntu-latest) (push) Failing after 39s
tests / cmake (gcc, ubuntu-latest) (push) Failing after 39s
tests / valgrind (push) Failing after 35s
tests / cmake (msvc, windows-latest) (push) Has been cancelled
tests / autotools (gcc, yes, macos-latest) (push) Has been cancelled
tests / cmake (clang, macos-latest) (push) Has been cancelled
tests / cmake (gcc, macos-latest) (push) Has been cancelled
tests / autotools (gcc, no, macos-latest) (push) Has been cancelled
tests / autotools (clang, no, macos-latest) (push) Has been cancelled
tests / autotools (clang, yes, macos-latest) (push) Has been cancelled
Fix code formatting
2025-03-23 22:39:12 +02:00
Petri Lehtinen
05a10aa8af Fix code formatting 2025-03-23 22:31:56 +02:00
Petri Lehtinen
4d7ac97b89
Merge pull request #710 from akheron/fix-readthedocs
Add readthedocs config
2025-03-23 21:59:36 +02:00
Petri Lehtinen
23905f372c Add readthedocs config 2025-03-23 21:58:05 +02:00
Andrew White
0f9c18dd12 Use target-based cmake settings
- Update minimum required to CMake version 3.5 (versions older than 3.5 are
deprecated as of 3.27)
- update add_definitions to target_compile_definitions
- use target_include_directories for public library includes
- add jansson::jansson alias
2024-07-10 10:31:49 +10:00
5 changed files with 31 additions and 11 deletions

View file

@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.1)
cmake_minimum_required (VERSION 3.10)
project(jansson C)
# Options
@ -266,18 +266,15 @@ configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_config.h.cmake
file (COPY ${CMAKE_CURRENT_SOURCE_DIR}/src/jansson.h
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/include/)
add_definitions(-DJANSSON_USING_CMAKE)
# configure the private config file
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/cmake/jansson_private_config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/private_include/jansson_private_config.h)
# and tell the source code to include it
add_definitions(-DHAVE_CONFIG_H)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories (${CMAKE_CURRENT_BINARY_DIR}/private_include)
# Configuration flags will be set on project later once we have defined the target
# Add the lib sources.
file(GLOB JANSSON_SRC src/*.c)
if (NOT USE_DTOA)
@ -356,6 +353,20 @@ else()
POSITION_INDEPENDENT_CODE true)
endif()
# Now target jansson is declared, set per-target values
target_compile_definitions(jansson PUBLIC JANSSON_USING_CMAKE)
target_compile_definitions(jansson PRIVATE HAVE_CONFIG_H)
target_include_directories(jansson
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
INTERFACE $<INSTALL_INTERFACE:include>
)
add_library( jansson::jansson ALIAS jansson )
if (JANSSON_EXAMPLES)
add_executable(simple_parse "${CMAKE_CURRENT_SOURCE_DIR}/examples/simple_parse.c")
target_link_libraries(simple_parse jansson)

9
doc/.readthedocs.yaml Normal file
View file

@ -0,0 +1,9 @@
version: 2
build:
os: ubuntu-22.04
tools:
python: "3.12"
sphinx:
configuration: doc/conf.py

View file

@ -26,7 +26,7 @@
#define MAX_INTEGER_STR_LENGTH 25
#define MAX_REAL_STR_LENGTH 25
#define FLAGS_TO_INDENT(f) ((f)&0x1F)
#define FLAGS_TO_INDENT(f) ((f) & 0x1F)
#define FLAGS_TO_PRECISION(f) (((f) >> 11) & 0x1F)
struct buffer {

View file

@ -379,14 +379,14 @@ json_t *json_load_callback(json_load_callback_t callback, void *data, size_t fla
/* encoding */
#define JSON_MAX_INDENT 0x1F
#define JSON_INDENT(n) ((n)&JSON_MAX_INDENT)
#define JSON_INDENT(n) ((n) & JSON_MAX_INDENT)
#define JSON_COMPACT 0x20
#define JSON_ENSURE_ASCII 0x40
#define JSON_SORT_KEYS 0x80
#define JSON_PRESERVE_ORDER 0x100
#define JSON_ENCODE_ANY 0x200
#define JSON_ESCAPE_SLASH 0x400
#define JSON_REAL_PRECISION(n) (((n)&0x1F) << 11)
#define JSON_REAL_PRECISION(n) (((n) & 0x1F) << 11)
#define JSON_EMBED 0x10000
typedef int (*json_dump_callback_t)(const char *buffer, size_t size, void *data);

View file

@ -16,7 +16,7 @@
#define STRBUFFER_MIN_SIZE 16
#define STRBUFFER_FACTOR 2
#define STRBUFFER_SIZE_MAX ((size_t)-1)
#define STRBUFFER_SIZE_MAX ((size_t)(-1))
int strbuffer_init(strbuffer_t *strbuff) {
strbuff->size = STRBUFFER_MIN_SIZE;