vcpkg/ports/nlohmann-json/portfile.cmake
Thomas Gwynne-Timothy 6ad0750a86
[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
2022-03-23 12:57:59 -07:00

46 lines
1.6 KiB
CMake

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO nlohmann/json
REF v3.10.5
SHA512 4a9d6416f383e76bf95425fc02a4e12c605fcbcae910b704e354396a493454cf8a1ffbecba11f231e020ffd2842908df7e67dbc09f62d1202d40b6815c24cfd2
HEAD_REF master
)
if(NOT DEFINED nlohmann-json_IMPLICIT_CONVERSIONS)
set(nlohmann-json_IMPLICIT_CONVERSIONS ON)
endif()
vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DJSON_Install=ON
-DJSON_MultipleHeaders=ON
-DJSON_BuildTests=OFF
-DJSON_ImplicitConversions=${nlohmann-json_IMPLICIT_CONVERSIONS}
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME "nlohmann_json" CONFIG_PATH "lib/cmake/nlohmann_json")
vcpkg_fixup_pkgconfig()
vcpkg_replace_string(
"${CURRENT_PACKAGES_DIR}/share/nlohmann_json/nlohmann_jsonTargets.cmake"
"{_IMPORT_PREFIX}/nlohmann_json.natvis"
"{_IMPORT_PREFIX}/share/nlohmann_json/nlohmann_json.natvis"
)
if(EXISTS ${CURRENT_PACKAGES_DIR}/nlohmann_json.natvis)
file(RENAME
"${CURRENT_PACKAGES_DIR}/nlohmann_json.natvis"
"${CURRENT_PACKAGES_DIR}/share/nlohmann_json/nlohmann_json.natvis"
)
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(REMOVE "${CURRENT_PACKAGES_DIR}/debug/nlohmann_json.natvis")
# Handle 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}")