From a95a91883b87fdc0ac4d499664692bf84a8cbf6b Mon Sep 17 00:00:00 2001 From: Weihang Ding <798047000@qq.com> Date: Wed, 1 Jul 2026 10:27:54 +0800 Subject: [PATCH] [hdr-histogram] Fix pkgconfig [vcpkg-ci-hdr-histogram] New ci port (#52652) Co-authored-by: Billy Robert O'Neal III Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- ports/hdr-histogram/001-fix-pkgconfig.patch | 48 +++++++++++++++++++ ports/hdr-histogram/portfile.cmake | 2 + ports/hdr-histogram/vcpkg.json | 1 + .../vcpkg-ci-hdr-histogram/portfile.cmake | 10 ++++ .../project/CMakeLists.txt | 17 +++++++ .../vcpkg-ci-hdr-histogram/project/main.c | 14 ++++++ .../vcpkg-ci-hdr-histogram/vcpkg.json | 12 +++++ versions/baseline.json | 2 +- versions/h-/hdr-histogram.json | 5 ++ 9 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 ports/hdr-histogram/001-fix-pkgconfig.patch create mode 100644 scripts/test_ports/vcpkg-ci-hdr-histogram/portfile.cmake create mode 100644 scripts/test_ports/vcpkg-ci-hdr-histogram/project/CMakeLists.txt create mode 100644 scripts/test_ports/vcpkg-ci-hdr-histogram/project/main.c create mode 100644 scripts/test_ports/vcpkg-ci-hdr-histogram/vcpkg.json diff --git a/ports/hdr-histogram/001-fix-pkgconfig.patch b/ports/hdr-histogram/001-fix-pkgconfig.patch new file mode 100644 index 0000000000..9cc3721e5e --- /dev/null +++ b/ports/hdr-histogram/001-fix-pkgconfig.patch @@ -0,0 +1,48 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 152273d..b90ede6 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -113,6 +113,31 @@ if(${ZLIB_FOUND}) + else() + set(PC_REQUIRES_PRIVATE_ZLIB "") + endif() ++ ++if(HDR_HISTOGRAM_BUILD_STATIC) ++ set(PROJECT_LIB_FILE_NAME "${PROJECT_NAME}_static") ++else() ++ set(PROJECT_LIB_FILE_NAME "${PROJECT_NAME}") ++endif() ++ ++set(PKGCONFIG_LIBS_PRIVATE) ++if(WIN32) ++ string(APPEND PKGCONFIG_LIBS_PRIVATE " -lws2_32") ++else() ++ find_package(Threads REQUIRED) ++ string(APPEND PKGCONFIG_LIBS_PRIVATE " -pthread") ++ ++ check_library_exists(rt clock_gettime "" HAVE_LIBRT) ++ if(HAVE_LIBRT) ++ string(APPEND PKGCONFIG_LIBS_PRIVATE " -lrt") ++ endif() ++ ++ check_library_exists(m pow "" HAVE_LIBM) ++ if(HAVE_LIBM) ++ string(APPEND PKGCONFIG_LIBS_PRIVATE " -lm") ++ endif() ++endif() ++ + configure_file( + ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc +diff --git a/hdr_histogram.pc.in b/hdr_histogram.pc.in +index 1151ab3..1249178 100644 +--- a/hdr_histogram.pc.in ++++ b/hdr_histogram.pc.in +@@ -8,5 +8,5 @@ URL: @CMAKE_PROJECT_HOMEPAGE_URL@ + Version: @PROJECT_VERSION@ + Requires.private: @PC_REQUIRES_PRIVATE_ZLIB@ + Cflags: -I${includedir} +-Libs: -L${libdir} -l@PROJECT_NAME@ +-Libs.private: -pthread -lm -lrt -L${libdir} ++Libs: -L${libdir} -l@PROJECT_LIB_FILE_NAME@ ++Libs.private: @PKGCONFIG_LIBS_PRIVATE@ -L${libdir} diff --git a/ports/hdr-histogram/portfile.cmake b/ports/hdr-histogram/portfile.cmake index 9c1ab2d731..98306b5a00 100644 --- a/ports/hdr-histogram/portfile.cmake +++ b/ports/hdr-histogram/portfile.cmake @@ -8,6 +8,8 @@ vcpkg_from_github( REF ${VERSION} SHA512 f631876dd1871d5e90989523f198d93b8dc561c513e86724149fefd52603064c3687d57e60c77e5ccbdc5a54ab9e7397a8db7a34e23cc68948c6c1361de62031 HEAD_REF main + PATCHES + 001-fix-pkgconfig.patch ) if("log" IN_LIST FEATURES) diff --git a/ports/hdr-histogram/vcpkg.json b/ports/hdr-histogram/vcpkg.json index 65739ac401..647915bb92 100644 --- a/ports/hdr-histogram/vcpkg.json +++ b/ports/hdr-histogram/vcpkg.json @@ -1,6 +1,7 @@ { "name": "hdr-histogram", "version-semver": "0.11.10", + "port-version": 1, "description": "'C' port of High Dynamic Range (HDR) Histogram", "homepage": "https://github.com/HdrHistogram/HdrHistogram_c", "license": "CC0-1.0", diff --git a/scripts/test_ports/vcpkg-ci-hdr-histogram/portfile.cmake b/scripts/test_ports/vcpkg-ci-hdr-histogram/portfile.cmake new file mode 100644 index 0000000000..dd25706120 --- /dev/null +++ b/scripts/test_ports/vcpkg-ci-hdr-histogram/portfile.cmake @@ -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() diff --git a/scripts/test_ports/vcpkg-ci-hdr-histogram/project/CMakeLists.txt b/scripts/test_ports/vcpkg-ci-hdr-histogram/project/CMakeLists.txt new file mode 100644 index 0000000000..a7cd885f7d --- /dev/null +++ b/scripts/test_ports/vcpkg-ci-hdr-histogram/project/CMakeLists.txt @@ -0,0 +1,17 @@ +cmake_minimum_required(VERSION 3.16) +project(vcpkg-ci-hdr-histogram) + +################################################################################ +# Use cmake config # +################################################################################ +find_package(hdr_histogram CONFIG REQUIRED) +add_executable(vcpkg-ci-hdr-histogram main.c) +target_link_libraries(vcpkg-ci-hdr-histogram PRIVATE $,hdr_histogram::hdr_histogram,hdr_histogram::hdr_histogram_static>) + +################################################################################ +# Use pkg-config # +################################################################################ +find_package(PkgConfig) +pkg_check_modules(hdr_histogram REQUIRED IMPORTED_TARGET hdr_histogram) +add_executable(vcpkg-ci-hdr-histogram-pc main.c) +target_link_libraries(vcpkg-ci-hdr-histogram-pc PRIVATE PkgConfig::hdr_histogram) diff --git a/scripts/test_ports/vcpkg-ci-hdr-histogram/project/main.c b/scripts/test_ports/vcpkg-ci-hdr-histogram/project/main.c new file mode 100644 index 0000000000..1e2310fb60 --- /dev/null +++ b/scripts/test_ports/vcpkg-ci-hdr-histogram/project/main.c @@ -0,0 +1,14 @@ +#include +#include + +int main() { + struct hdr_histogram* histogram = NULL; + int rc = hdr_init(1, 1000000, 3, &histogram); + if (rc != 0) { + return 1; + } + hdr_record_value(histogram, 42); + hdr_usleep(1); + hdr_close(histogram); + return 0; +} diff --git a/scripts/test_ports/vcpkg-ci-hdr-histogram/vcpkg.json b/scripts/test_ports/vcpkg-ci-hdr-histogram/vcpkg.json new file mode 100644 index 0000000000..4489277cc2 --- /dev/null +++ b/scripts/test_ports/vcpkg-ci-hdr-histogram/vcpkg.json @@ -0,0 +1,12 @@ +{ + "name": "vcpkg-ci-hdr-histogram", + "version-string": "ci", + "description": "Validates hdr-histogram", + "dependencies": [ + "hdr-histogram", + { + "name": "vcpkg-cmake", + "host": true + } + ] +} diff --git a/versions/baseline.json b/versions/baseline.json index 96df2fdb7d..cd4c71fe36 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -3786,7 +3786,7 @@ }, "hdr-histogram": { "baseline": "0.11.10", - "port-version": 0 + "port-version": 1 }, "healpix": { "baseline": "3.83", diff --git a/versions/h-/hdr-histogram.json b/versions/h-/hdr-histogram.json index 2ca8c54292..c158580630 100644 --- a/versions/h-/hdr-histogram.json +++ b/versions/h-/hdr-histogram.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "53068d224496e327c528fccce3cea76a0b9a4aab", + "version-semver": "0.11.10", + "port-version": 1 + }, { "git-tree": "f26c8c20182c8861fa8784d84ede1719a90ada37", "version-semver": "0.11.10",