json-schema-validator: Upgrade 2.2.0 -> 2.3.0 to allow CMake 4+ compatibility

- Drop patches because all of them fixed in the newer version.

A few explanation for 0001-Set-Json_validator-Install-off-if-it-finds-it-via-li.patch:

For newer version CMakeLists.txt, this logic is now handled automatically using the PROJECT_IS_TOP_LEVEL variable. The JSON_VALIDATOR_INSTALL option is set to ON only when the project is being built as the top-level project, and it is automatically disabled when included as a dependency.

As a result, the patch is no longer needed and the behavior it intended to provide is already covered by the new build system logic.

Changelog:

- Some bugfixes, but mainly a big re-work of the CMakeLists.txt making it
use and usable for FetchContent-users.

Fix:

| CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
|   Compatibility with CMake < 3.5 has been removed from CMake.
|
|   Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
|   to tell CMake that the project requires at least <min> but has been updated
|   to work with policies introduced by <max> or earlier.
|
|   Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.
|
|
| -- Configuring incomplete, errors occurred!

Signed-off-by: Alper Ak <alperyasinak1@gmail.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Alper Ak 2025-07-08 01:54:07 +03:00 committed by Khem Raj
parent de3c8d3ff2
commit f751ae8b44
No known key found for this signature in database
GPG Key ID: BB053355919D3314
5 changed files with 3 additions and 193 deletions

View File

@ -1,29 +0,0 @@
From 35939115142db6cd366ab11b29692a0179338ddf Mon Sep 17 00:00:00 2001
From: Parian Golchin <Parian.Golchin@iris-sensing.com>
Date: Fri, 18 Aug 2023 15:54:25 +0200
Subject: [PATCH 1/3] Set Json_validator Install off if it finds it via linking
Upstream-Status: Inappropriate [newer version of cmake in main branch]
Signed-off-by: Parian Golchin <Parian.Golchin@iris-sensing.com>
---
CMakeLists.txt | 3 +++
1 file changed, 3 insertions(+)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f636734..9e4587f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -55,6 +55,9 @@ option(JSON_VALIDATOR_BUILD_EXAMPLES "Build examples" ${JSON_VALIDATOR_IS_TOP_LE
if(NOT TARGET nlohmann_json::nlohmann_json)
find_package(nlohmann_json REQUIRED)
+else()
+ message(STATUS "Found nlohmann_json::nlohmann_json-target - linking with it")
+ set(JSON_VALIDATOR_INSTALL OFF)
endif()
target_link_libraries(
--
2.25.1

View File

@ -1,71 +0,0 @@
From 2065015da40cf79dd8ec9e3f186538e17c3b592f Mon Sep 17 00:00:00 2001
From: Robert Joslyn <robert.joslyn@redrectangle.org>
Date: Wed, 30 Nov 2022 13:07:29 -0800
Subject: [PATCH 2/3] Fix assumed signed char
The code assumes that char is signed, but whether char is signed or
unsigned is implementation defined. On some architectures like PowerPC,
GCC treats char as unsigned resulting in compile errors:
smtp-address-validator.cpp:213:1: error: narrowing conversion of '-32' from 'int' to 'char' [-Wnarrowing]
Fix this by specifying signed char.
Upstream-Status: Backport [https://github.com/pboettch/json-schema-validator/commit/491ac44026e08f31790f5cacffa62e168bb35e32]
Signed-off-by: Parian Golchin <Parian.Golchin@iris-sensing.com>
---
src/smtp-address-validator.cpp | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/smtp-address-validator.cpp b/src/smtp-address-validator.cpp
index a63ead0..3903b51 100644
--- a/src/smtp-address-validator.cpp
+++ b/src/smtp-address-validator.cpp
@@ -63,7 +63,7 @@ static const short _address_key_offsets[] = {
1363, 1365, 1367, 1368, 1370, 1388, 0
};
-static const char _address_trans_keys[] = {
+static const signed char _address_trans_keys[] = {
-32, -19, -16, -12, 34, 45, 61, 63,
-62, -33, -31, -17, -15, -13, 33, 39,
42, 43, 47, 57, 65, 90, 94, 126,
@@ -711,7 +711,7 @@ bool is_address(const char* p, const char* pe)
{
int _klen;
unsigned int _trans = 0;
- const char * _keys;
+ const signed char * _keys;
const signed char * _acts;
unsigned int _nacts;
_resume: {}
@@ -728,9 +728,9 @@ bool is_address(const char* p, const char* pe)
_klen = (int)_address_single_lengths[cs];
if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_upper = _keys + _klen - 1;
- const char *_mid;
+ const signed char *_lower = _keys;
+ const signed char *_upper = _keys + _klen - 1;
+ const signed char *_mid;
while ( 1 ) {
if ( _upper < _lower ) {
_keys += _klen;
@@ -752,9 +752,9 @@ bool is_address(const char* p, const char* pe)
_klen = (int)_address_range_lengths[cs];
if ( _klen > 0 ) {
- const char *_lower = _keys;
- const char *_upper = _keys + (_klen<<1) - 2;
- const char *_mid;
+ const signed char *_lower = _keys;
+ const signed char *_upper = _keys + (_klen<<1) - 2;
+ const signed char *_mid;
while ( 1 ) {
if ( _upper < _lower ) {
_trans += (unsigned int)_klen;
--
2.25.1

View File

@ -1,41 +0,0 @@
From fa49c29942763285c51b7d2dea417d9f51e4961f Mon Sep 17 00:00:00 2001
From: Sven Fink <sven.fink@wipotec.com>
Date: Fri, 13 Jan 2023 09:15:42 +0100
Subject: [PATCH 3/3] For root value, use empty pointer
Upstream-Status: Backport [https://github.com/pboettch/json-schema-validator/commit/59c9d6200bf3cd54b4fc717ec1660c91eddb4d1a]
Signed-off-by: Parian Golchin <Parian.Golchin@iris-sensing.com>
---
src/json-validator.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/json-validator.cpp b/src/json-validator.cpp
index 7f34553..3c73d98 100644
--- a/src/json-validator.cpp
+++ b/src/json-validator.cpp
@@ -553,6 +553,9 @@ class type_schema : public schema
else_->validate(ptr, instance, patch, e);
}
}
+ if (instance.is_null()) {
+ patch.add(nlohmann::json::json_pointer{}, default_value_);
+ }
}
protected:
@@ -1134,6 +1137,11 @@ public:
propertyNames_ = schema::make(attr.value(), root, {"propertyNames"}, uris);
sch.erase(attr);
}
+
+ attr = sch.find("default");
+ if (attr != sch.end()) {
+ set_default_value(*attr);
+ }
}
};
--
2.25.1

View File

@ -1,43 +0,0 @@
From a42d374aa260caec5f683c75d0db322811e51ab9 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 19 Mar 2022 22:40:49 -0700
Subject: [PATCH] cmake: Use GNUInstallDirs
This helps it make it platform independent, some platforms e.g.
ppc64/linux use /usr/lib64 for system libraries
Upstream-Status: Submitted [https://github.com/pboettch/json-schema-validator/pull/197]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
CMakeLists.txt | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9e4587f..3eff234 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -93,11 +93,13 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
endif()
endif()
+include(GNUInstallDirs)
+
if(JSON_VALIDATOR_INSTALL)
install(TARGETS nlohmann_json_schema_validator
EXPORT ${PROJECT_NAME}Targets
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION ${LIBDIR}
+ ARCHIVE DESTINATION ${LIBDIR}
RUNTIME DESTINATION bin)
install(FILES src/nlohmann/json-schema.hpp
@@ -129,7 +131,7 @@ endif()
if(JSON_VALIDATOR_INSTALL)
# Set the install path to the cmake config files (Relative, so install works correctly under Hunter as well)
- set(INSTALL_CMAKE_DIR "lib/cmake/${PROJECT_NAME}")
+ set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
set(INSTALL_CMAKEDIR_ROOT share/cmake)
# Install Targets

View File

@ -2,19 +2,13 @@ SUMMARY = "JSON schema validator for JSON for Modern C++"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=c441d022da1b1663c70181a32225d006"
SRC_URI = "git://github.com/pboettch/json-schema-validator;branch=main;protocol=https \
file://0001-Set-Json_validator-Install-off-if-it-finds-it-via-li.patch \
file://0002-Fix-assumed-signed-char.patch \
file://0003-For-root-value-use-empty-pointer.patch \
file://0004-cmake-Use-GNUInstallDirs.patch \
"
SRCREV = "6b17782d6a5d1dee5d2c4fc5d25ffb1123913431"
SRC_URI = "git://github.com/pboettch/json-schema-validator;branch=main;protocol=https"
SRCREV = "349cba9f7e3cb423bbc1811bdd9f6770f520b468"
DEPENDS += "nlohmann-json"
inherit cmake
EXTRA_OECMAKE = "-DBUILD_SHARED_LIBS=ON -DJSON_VALIDATOR_BUILD_TESTS=OFF -DJSON_VALIDATOR_BUILD_EXAMPLES=OFF"
BBCLASSEXTEND = "native nativesdk"