Skip to content

Commit

Permalink
Use nlohmann-json for the overlay test, to not collide with spdlog
Browse files Browse the repository at this point in the history
  • Loading branch information
vector-of-bool committed Nov 11, 2021
1 parent f9fa2ae commit 806aec6
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 96 deletions.
6 changes: 3 additions & 3 deletions tests/ci/vcpkg-overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ message(STATUS "PMM URL is ${PMM_URL}")
include(${PMM_INCLUDE})
pmm(VCPKG
REVISION 2021.05.12
REQUIRES spdlog-pmm[test-feature]
REQUIRES nlohmann-json[test-feature]
OVERLAY custom-ports/ custom-ports2/
DEBUG
)

find_package(spdlog REQUIRED CONFIG)
find_package(nlohmann_json REQUIRED CONFIG)

add_executable(dummy main.cpp)
target_link_libraries(dummy PRIVATE spdlog::spdlog fmt::fmt)
target_link_libraries(dummy PRIVATE nlohmann_json::nlohmann_json)
48 changes: 48 additions & 0 deletions tests/ci/vcpkg-overlay/custom-ports2/nlohmann-json/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO nlohmann/json
REF v3.10.4
SHA512 f78592db6218165cbc74c10bcba40366f1bfea84405b7ee25fe97a056d5b7a15aeeb956d93296673928dcbd6e26ffcfb152f885b4a44d5d55751396ccf090835
HEAD_REF master
)

vcpkg_cmake_configure(
SOURCE_PATH ${SOURCE_PATH}
OPTIONS
-DJSON_Install=ON
-DJSON_MultipleHeaders=ON
-DJSON_BuildTests=OFF
)
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)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
test-feature TEST_FEATURE_WAS_SPECIFIED
)

if(NOT TEST_FEATURE_WAS_SPECIFIED)
message(FATAL_ERROR "Test feature was not specified")
endif()

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SPDLOG_BUILD_SHARED)
21 changes: 21 additions & 0 deletions tests/ci/vcpkg-overlay/custom-ports2/nlohmann-json/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "nlohmann-json",
"version-semver": "3.10.4",
"description": "JSON for Modern C++",
"homepage": "https://github.com/nlohmann/json",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"test-feature": {
"description": "Just a feature to test port overlays"
}
}
}
57 changes: 0 additions & 57 deletions tests/ci/vcpkg-overlay/custom-ports2/spdlog-pmm/portfile.cmake

This file was deleted.

30 changes: 0 additions & 30 deletions tests/ci/vcpkg-overlay/custom-ports2/spdlog-pmm/vcpkg.json

This file was deleted.

8 changes: 2 additions & 6 deletions tests/ci/vcpkg-overlay/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
#include <spdlog/sinks/stdout_color_sinks.h>
#include <spdlog/spdlog.h>
#include <nlohmann/json.hpp>

int main() {
auto console = spdlog::stdout_color_mt("console");
console->info("Hello!");
}
int main() { auto array = nlohmann::json::parse("[1, 2, 3]"); }

0 comments on commit 806aec6

Please sign in to comment.