[tomlplusplus] Install CMake config (#44838)

This commit is contained in:
Kai Pastor 2025-04-05 09:59:21 +02:00 committed by GitHub
parent 66fc0d0d67
commit 3eb5dfe6b4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 91 additions and 8 deletions

View File

@ -11,13 +11,29 @@ vcpkg_from_github(
vcpkg_configure_meson(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-Dgenerate_cmake_config=false
-Dbuild_tests=false
-Dbuild_examples=false
)
vcpkg_install_meson()
vcpkg_fixup_pkgconfig()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/tomlplusplus)
# Fixup link lib name and multi-config
find_library(lib NAMES tomlplusplus PATHS "${CURRENT_PACKAGES_DIR}/lib" NO_DEFAULT_PATH REQUIRED)
cmake_path(GET lib FILENAME name)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/tomlplusplus/tomlplusplusConfig.cmake"
[[(IMPORTED_LOCATION "..PACKAGE_PREFIX_DIR./lib/)[^"]*"]]
" \\1${name}\""
REGEX
)
if(NOT VCPKG_BUILD_TYPE)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/share/tomlplusplus/tomlplusplusConfig.cmake"
[[IMPORTED_LOCATION ("..PACKAGE_PREFIX_DIR.)(/lib/[^"]*")]]
[[IMPORTED_CONFIGURATIONS "DEBUG;RELEASE"
IMPORTED_LOCATION_DEBUG \1/debug\2
IMPORTED_LOCATION_RELEASE \1\2]]
REGEX
)
endif()
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

View File

@ -1,5 +0,0 @@
The package tomlplusplus can be imported via CMake FindPkgConfig module:
find_package(PkgConfig REQUIRED)
pkg_check_modules(tomlplusplus REQUIRED IMPORTED_TARGET tomlplusplus)
target_link_libraries(main PkgConfig::tomlplusplus)

View File

@ -1,11 +1,16 @@
{
"name": "tomlplusplus",
"version": "3.4.0",
"port-version": 1,
"description": "Header-only TOML config file parser and serializer for modern C++.",
"homepage": "https://marzer.github.io/tomlplusplus/",
"license": "MIT",
"supports": "!uwp",
"dependencies": [
{
"name": "vcpkg-cmake-config",
"host": true
},
{
"name": "vcpkg-tool-meson",
"host": true

View File

@ -0,0 +1,10 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
vcpkg_find_acquire_program(PKGCONFIG)
vcpkg_cmake_configure(
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
)
vcpkg_cmake_build()

View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.30)
project(tomlplusplus-test CXX)
find_package(tomlplusplus CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE tomlplusplus::tomlplusplus)
find_package(PkgConfig REQUIRED)
pkg_check_modules(tomlplusplus_pc tomlplusplus REQUIRED IMPORTED_TARGET)
add_executable(main-pkconfig main.cpp)
target_compile_features(main-pkconfig PRIVATE cxx_std_17)
target_link_libraries(main-pkconfig PRIVATE PkgConfig::tomlplusplus_pc)

View File

@ -0,0 +1,22 @@
#include <iostream>
#include <toml++/toml.hpp>
int main(int argc, char** argv)
{
if (argc < 2)
return 1;
try
{
toml::table tbl;
tbl = toml::parse_file(argv[1]);
std::cout << tbl << "\n";
}
catch (const toml::parse_error& err)
{
std::cerr << "Parsing failed: " << err << "\n";
return 2;
}
return 0;
}

View File

@ -0,0 +1,14 @@
{
"name": "vcpkg-ci-tomlplusplus",
"version-string": "ci",
"description": "Port to force features of tomlplusplus within CI",
"homepage": "https://github.com/microsoft/vcpkg",
"license": "MIT",
"dependencies": [
"tomlplusplus",
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View File

@ -9366,7 +9366,7 @@
},
"tomlplusplus": {
"baseline": "3.4.0",
"port-version": 0
"port-version": 1
},
"tomsolver": {
"baseline": "1.0.1",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "c89c408f778aebf69ac0bbbb3d19db57c97d664c",
"version": "3.4.0",
"port-version": 1
},
{
"git-tree": "9866e66fa79aa1addd508e672062392313fc6085",
"version": "3.4.0",