aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Marshall <xandan@gmail.com>2019-02-06 16:45:47 +0000
committerRobert Schumacher <roschuma@microsoft.com>2019-02-06 08:45:47 -0800
commit2a7ad32ee8e09b33fa207aa3596c4cc77ceb36d6 (patch)
treea467cd7b13aee014051778030682772d8b774592
parent52f165ef3b162a4910b3e873d547ca994435e751 (diff)
downloadvcpkg-2a7ad32ee8e09b33fa207aa3596c4cc77ceb36d6.tar.gz
vcpkg-2a7ad32ee8e09b33fa207aa3596c4cc77ceb36d6.zip
[nlohmann-json] Added cmake targets (#5258)
* Added cmake targets for nlohmann-json * [nlohmann-json] Use vcpkg_from_github() * [nlohmann-json] Enable find_package(nlohmann_json) * Removed unneeded renaming * [nlohmann-json] Revert use of vcpkg_from_github() due to archive size of >100MB * [nlohmann-json] Fix missing natvis
-rw-r--r--ports/nlohmann-json/CONTROL2
-rw-r--r--ports/nlohmann-json/portfile.cmake55
2 files changed, 46 insertions, 11 deletions
diff --git a/ports/nlohmann-json/CONTROL b/ports/nlohmann-json/CONTROL
index 6d8f59edc..d1d9b689b 100644
--- a/ports/nlohmann-json/CONTROL
+++ b/ports/nlohmann-json/CONTROL
@@ -1,3 +1,3 @@
Source: nlohmann-json
-Version: 3.5.0
+Version: 3.5.0-5
Description: JSON for Modern C++
diff --git a/ports/nlohmann-json/portfile.cmake b/ports/nlohmann-json/portfile.cmake
index 66096ce89..ea95cad97 100644
--- a/ports/nlohmann-json/portfile.cmake
+++ b/ports/nlohmann-json/portfile.cmake
@@ -1,18 +1,53 @@
include(vcpkg_common_functions)
set(SOURCE_VERSION 3.5.0)
+set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/nlohmann-json-v${SOURCE_VERSION})
-vcpkg_download_distfile(HEADER
- URLS "https://github.com/nlohmann/json/releases/download/v${SOURCE_VERSION}/json.hpp"
- FILENAME "nlohmann-json-${SOURCE_VERSION}.hpp"
- SHA512 6e8df9c0a8b5e74cc03f1c7620820215d43b642e213d30481830e5608c8196455dab5a5b604758c25dc6f45bd394fc0be6c8f8712a6498e96b3fd2e7d388d3c0
+file(MAKE_DIRECTORY ${SOURCE_PATH})
+
+function(download_src SUBPATH SHA512)
+ vcpkg_download_distfile(FILE
+ URLS "https://github.com/nlohmann/json/raw/v${SOURCE_VERSION}/${SUBPATH}"
+ FILENAME "nlohmann-json-v${SOURCE_VERSION}/${SUBPATH}"
+ SHA512 ${SHA512}
+ )
+ get_filename_component(SUBPATH_DIR "${SOURCE_PATH}/${SUBPATH}" DIRECTORY)
+ file(COPY ${FILE} DESTINATION ${SUBPATH_DIR})
+endfunction()
+
+download_src(CMakeLists.txt c763a16ff8026f049041e4461040416278d51751a6ac37ed1f4bfb565c748f2307e121fa6f71c2420d30ceb231cfb68b3f502cb8c3750371c1bf90e1f651578f)
+download_src(LICENSE.MIT 0fdb404547467f4523579acde53066badf458504d33edbb6e39df0ae145ed27d48a720189a60c225c0aab05f2aa4ce4050dcb241b56dc693f7ee9f54c8728a75)
+download_src(nlohmann_json.natvis 9bce6758db0e54777394a4e718e60a281952b15f0c6dc6a6ad4a6d023c958b5515b2d39b7d4c66c03f0d3fdfdc1d6c23afb8b8419f1345c9d44d7b9a9ee2582b)
+download_src(cmake/config.cmake.in 7caab6166baa891f77f5b632ac4a920e548610ec41777b885ec51fe68d3665ffe91984dd2881caf22298b5392dfbd84b526fda252467bb66de9eb90e6e6ade5a)
+download_src(single_include/nlohmann/json.hpp 6e8df9c0a8b5e74cc03f1c7620820215d43b642e213d30481830e5608c8196455dab5a5b604758c25dc6f45bd394fc0be6c8f8712a6498e96b3fd2e7d388d3c0)
+
+vcpkg_configure_cmake(
+ SOURCE_PATH ${SOURCE_PATH}
+ PREFER_NINJA
+ OPTIONS -DJSON_BuildTests=0
+)
+
+vcpkg_install_cmake()
+
+vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/nlohmann_json TARGET_PATH share/nlohmann_json)
+
+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"
)
-vcpkg_download_distfile(LICENSE
- URLS "https://github.com/nlohmann/json/raw/v${SOURCE_VERSION}/LICENSE.MIT"
- FILENAME "nlohmann-json-LICENSE-${SOURCE_VERSION}.txt"
- SHA512 0fdb404547467f4523579acde53066badf458504d33edbb6e39df0ae145ed27d48a720189a60c225c0aab05f2aa4ce4050dcb241b56dc693f7ee9f54c8728a75
+file(REMOVE_RECURSE
+ ${CURRENT_PACKAGES_DIR}/debug
+ ${CURRENT_PACKAGES_DIR}/lib
)
-file(INSTALL ${HEADER} DESTINATION ${CURRENT_PACKAGES_DIR}/include/nlohmann RENAME json.hpp)
-file(INSTALL ${LICENSE} DESTINATION ${CURRENT_PACKAGES_DIR}/share/nlohmann-json RENAME copyright)
+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()
+
+# Handle copyright
+file(INSTALL ${SOURCE_PATH}/LICENSE.MIT DESTINATION ${CURRENT_PACKAGES_DIR}/share/nlohmann-json RENAME copyright)