[jsonrpcpp] Add new port (v1.4.0) (#52045)

Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
曹梦轩 2026-05-30 16:43:25 +08:00 committed by GitHub
parent e40cf469e3
commit 93e969cf5d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 132 additions and 0 deletions

View File

@ -0,0 +1,45 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a682679..bdcf1b3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -29,11 +29,37 @@ if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
PATH "Output directory for header files")
endif()
-include_directories(
- "include"
+find_package(nlohmann_json CONFIG REQUIRED)
+
+add_library(jsonrpcpp INTERFACE)
+target_include_directories(jsonrpcpp INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
+)
+target_link_libraries(jsonrpcpp INTERFACE nlohmann_json::nlohmann_json)
+
+include(CMakePackageConfigHelpers)
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/unofficial-jsonrpcpp-config.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/unofficial-jsonrpcpp-config.cmake"
+ INSTALL_DESTINATION "share/unofficial-jsonrpcpp"
+)
+install(
+ FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-jsonrpcpp-config.cmake"
+ DESTINATION "share/unofficial-jsonrpcpp"
+)
+
+install(TARGETS jsonrpcpp
+ EXPORT unofficial-jsonrpcpp-targets
+ INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
+)
+install(EXPORT unofficial-jsonrpcpp-targets
+ FILE unofficial-jsonrpcpp-targets.cmake
+ NAMESPACE unofficial::jsonrpcpp::
+ DESTINATION share/unofficial-jsonrpcpp
)
-install(FILES include/jsonrpcpp.hpp include/json.hpp
+install(FILES include/jsonrpcpp.hpp
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/jsonrpcpp")
if(MSVC)

View File

@ -0,0 +1,13 @@
diff --git a/include/jsonrpcpp.hpp b/include/jsonrpcpp.hpp
index 1cea0ac..236850c 100644
--- a/include/jsonrpcpp.hpp
+++ b/include/jsonrpcpp.hpp
@@ -23,7 +23,7 @@
#define JSON_RPC_HPP
// nlohmann-json
-#include <json.hpp>
+#include <nlohmann/json.hpp>
// standard headers
#include <cstring>

View File

@ -0,0 +1,30 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO badaix/jsonrpcpp
REF "v${VERSION}"
SHA512 d6c1ff8113f1b8581c258acdc7f59a3669e43636b06d73db1c4396da4a7797dc9b1d7e3a9f81039cc06c2970806b9b5a565cb2d9c8f0041866067dfcded93fff
HEAD_REF master
PATCHES
fix-include-path.patch
add-cmake-targets.patch
)
# Remove bundled json.hpp
file(REMOVE "${SOURCE_PATH}/include/json.hpp")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-jsonrpcpp-config.cmake.in" DESTINATION "${SOURCE_PATH}")
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DBUILD_EXAMPLE=OFF
-DBUILD_TESTS=OFF
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-jsonrpcpp CONFIG_PATH share/unofficial-jsonrpcpp)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

View File

@ -0,0 +1,9 @@
@PACKAGE_INIT@
include(CMakeFindDependencyMacro)
find_dependency(nlohmann_json CONFIG)
include("${CMAKE_CURRENT_LIST_DIR}/unofficial-jsonrpcpp-targets.cmake")
check_required_components(jsonrpcpp)

4
ports/jsonrpcpp/usage Normal file
View File

@ -0,0 +1,4 @@
jsonrpcpp is a header-only library and can be used from CMake via:
find_package(unofficial-jsonrpcpp CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::jsonrpcpp::jsonrpcpp)

View File

@ -0,0 +1,18 @@
{
"name": "jsonrpcpp",
"version-semver": "1.4.0",
"description": "C++ JSON-RPC 2.0 library",
"homepage": "https://github.com/badaix/jsonrpcpp",
"license": "MIT",
"dependencies": [
"nlohmann-json",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

View File

@ -4224,6 +4224,10 @@
"baseline": "0.21.0",
"port-version": 1
},
"jsonrpcpp": {
"baseline": "1.4.0",
"port-version": 0
},
"juce": {
"baseline": "8.0.7",
"port-version": 0

View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "ddf721d7d6a21fb7f624448bb768738bf7018a38",
"version-semver": "1.4.0",
"port-version": 0
}
]
}