From 609c5613541abb39c3258d056e2aa827bacb0fcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20Patrick=20Urbanke=20=28=E5=8A=89=E8=87=AA=E6=88=90?= =?UTF-8?q?=29?= Date: Fri, 6 Dec 2024 17:53:40 +0100 Subject: [PATCH] Use pkg-config for the TOML package (#291) --- .github/workflows/windows-msvc.yaml | 2 -- CMakeLists.txt | 14 +++----------- README.md | 13 +------------ docs/install.md | 4 ++++ tests/toml/CMakeLists.txt | 2 -- tests/ubjson/CMakeLists.txt | 2 -- vcpkg.json | 4 ++++ 7 files changed, 12 insertions(+), 29 deletions(-) diff --git a/.github/workflows/windows-msvc.yaml b/.github/workflows/windows-msvc.yaml index 66f901fe..2bf17440 100644 --- a/.github/workflows/windows-msvc.yaml +++ b/.github/workflows/windows-msvc.yaml @@ -6,8 +6,6 @@ env: VCPKG_BINARY_SOURCES: "clear;x-gha,readwrite" jobs: - windows-msvc-conan: - runs-on: windows-latest windows-msvc: runs-on: windows-latest steps: diff --git a/CMakeLists.txt b/CMakeLists.txt index 6018ce35..1063389f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,8 +58,6 @@ else() target_compile_options(reflectcpp PRIVATE $<$:-Wall -Wextra>) endif() -# target_compile_features(reflectcpp PUBLIC cxx_std_20) - set(REFLECT_CPP_SOURCES src/reflectcpp.cpp ) @@ -147,12 +145,9 @@ if (REFLECTCPP_TOML) src/reflectcpp_toml.cpp ) if(REFLECTCPP_USE_VCPKG) - target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") - if (MSVC) - target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/tomlplusplus${CMAKE_STATIC_LIBRARY_SUFFIX}") - else () - target_link_libraries(reflectcpp PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/lib/libtomlplusplus${CMAKE_STATIC_LIBRARY_SUFFIX}") - endif () + find_package(PkgConfig REQUIRED) + pkg_check_modules(tomlplusplus REQUIRED IMPORTED_TARGET tomlplusplus) + target_link_libraries(reflectcpp PUBLIC PkgConfig::tomlplusplus) else() find_package(tomlplusplus) target_link_libraries(reflectcpp PUBLIC tomlplusplus::tomlplusplus) @@ -163,9 +158,6 @@ if (REFLECTCPP_UBJSON) list(APPEND REFLECT_CPP_SOURCES src/reflectcpp_ubjson.cpp ) - if(REFLECTCPP_USE_VCPKG) - target_include_directories(reflectcpp SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") - endif() find_package(jsoncons CONFIG REQUIRED) endif () diff --git a/README.md b/README.md index 1d350ba4..6cfb786a 100644 --- a/README.md +++ b/README.md @@ -545,18 +545,7 @@ The following compilers are supported: ### Using vcpkg -```bash -vcpkg install reflectcpp -``` - -or: - -```bash -vcpkg add port reflectcpp -``` - -If the library cannot be found, please update vcpkg itself and/or update the `builtin-baseline` -tag in the *vcpkg.json* of your project. +https://vcpkg.io/en/package/reflectcpp ### Using Conan diff --git a/docs/install.md b/docs/install.md index 88f4cec1..63b7cd67 100644 --- a/docs/install.md +++ b/docs/install.md @@ -14,6 +14,10 @@ You can include the source files into your build or compile it using cmake and v ## Option 1: Using vcpkg +Refer to the following port: + +https://vcpkg.io/en/package/reflectcpp + ```bash vcpkg install reflectcpp ``` diff --git a/tests/toml/CMakeLists.txt b/tests/toml/CMakeLists.txt index 1e138f47..ddf21e26 100644 --- a/tests/toml/CMakeLists.txt +++ b/tests/toml/CMakeLists.txt @@ -8,8 +8,6 @@ add_executable( ) target_precompile_headers(reflect-cpp-toml-tests PRIVATE [["rfl.hpp"]] ) -target_include_directories(reflect-cpp-toml-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") - target_link_libraries( reflect-cpp-toml-tests PRIVATE diff --git a/tests/ubjson/CMakeLists.txt b/tests/ubjson/CMakeLists.txt index 160ade8e..aa62b2ad 100644 --- a/tests/ubjson/CMakeLists.txt +++ b/tests/ubjson/CMakeLists.txt @@ -8,8 +8,6 @@ add_executable( ) target_precompile_headers(reflect-cpp-ubjson-tests PRIVATE [["rfl.hpp"]] ) -target_include_directories(reflect-cpp-ubjson-tests SYSTEM PRIVATE "${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") - target_link_libraries( reflect-cpp-ubjson-tests PRIVATE diff --git a/vcpkg.json b/vcpkg.json index 2911e623..4c41c9e2 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -70,6 +70,10 @@ { "name": "vcpkg-cmake-config", "version>=": "2022-02-06#1" + }, + { + "name":"vcpkg-pkgconfig-get-modules", + "version>=": "2024-04-03" } ] }