[nlohmann-json] Add option to control implicit conversions behaviour (#22409)

* [nlohmann-json] Add "implicit-conversions" triplet variable

* [nlohmann-json] Customize usage to document triplet var

* [nlohmann-json] Update version files
This commit is contained in:
Thomas Gwynne-Timothy 2022-03-23 16:57:59 -03:00 committed by GitHub
parent e3d66251c9
commit 6ad0750a86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 1 deletions

View File

@ -6,12 +6,17 @@ vcpkg_from_github(
HEAD_REF master HEAD_REF master
) )
if(NOT DEFINED nlohmann-json_IMPLICIT_CONVERSIONS)
set(nlohmann-json_IMPLICIT_CONVERSIONS ON)
endif()
vcpkg_cmake_configure( vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH} SOURCE_PATH ${SOURCE_PATH}
OPTIONS OPTIONS
-DJSON_Install=ON -DJSON_Install=ON
-DJSON_MultipleHeaders=ON -DJSON_MultipleHeaders=ON
-DJSON_BuildTests=OFF -DJSON_BuildTests=OFF
-DJSON_ImplicitConversions=${nlohmann-json_IMPLICIT_CONVERSIONS}
) )
vcpkg_cmake_install() vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME "nlohmann_json" CONFIG_PATH "lib/cmake/nlohmann_json") vcpkg_cmake_config_fixup(PACKAGE_NAME "nlohmann_json" CONFIG_PATH "lib/cmake/nlohmann_json")
@ -35,3 +40,6 @@ file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/nlohmann_json.natvis")
# Handle copyright # Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE.MIT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) file(INSTALL "${SOURCE_PATH}/LICENSE.MIT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
# Handle usage
file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

12
ports/nlohmann-json/usage Normal file
View File

@ -0,0 +1,12 @@
The package nlohmann-json provides CMake targets:
find_package(nlohmann_json CONFIG REQUIRED)
target_link_libraries(main PRIVATE nlohmann_json::nlohmann_json)
The package nlohmann-json can be configured to not provide implicit conversions via a custom triplet file:
set(nlohmann_json_JSON_ImplicitConversions OFF)
For more information, see the docs here:
https://json.nlohmann.me/features/macros/#json_use_implicit_conversions

View File

@ -1,6 +1,7 @@
{ {
"name": "nlohmann-json", "name": "nlohmann-json",
"version-semver": "3.10.5", "version-semver": "3.10.5",
"port-version": 1,
"description": "JSON for Modern C++", "description": "JSON for Modern C++",
"homepage": "https://github.com/nlohmann/json", "homepage": "https://github.com/nlohmann/json",
"dependencies": [ "dependencies": [

View File

@ -4814,7 +4814,7 @@
}, },
"nlohmann-json": { "nlohmann-json": {
"baseline": "3.10.5", "baseline": "3.10.5",
"port-version": 0 "port-version": 1
}, },
"nlopt": { "nlopt": {
"baseline": "2.7.0", "baseline": "2.7.0",

View File

@ -1,5 +1,10 @@
{ {
"versions": [ "versions": [
{
"git-tree": "fa0a087d0444a7f2c79a44bce91c51550d5f2e47",
"version-semver": "3.10.5",
"port-version": 1
},
{ {
"git-tree": "d1fe747457714c4c43b12502de05b2d006b440d4", "git-tree": "d1fe747457714c4c43b12502de05b2d006b440d4",
"version-semver": "3.10.5", "version-semver": "3.10.5",