[hdr-histogram] Fix pkgconfig [vcpkg-ci-hdr-histogram] New ci port (#52652)

Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Weihang Ding 2026-07-01 10:27:54 +08:00 committed by GitHub
parent 72104607dd
commit a95a91883b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 110 additions and 1 deletions

View File

@ -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}

View File

@ -8,6 +8,8 @@ vcpkg_from_github(
REF ${VERSION}
SHA512 f631876dd1871d5e90989523f198d93b8dc561c513e86724149fefd52603064c3687d57e60c77e5ccbdc5a54ab9e7397a8db7a34e23cc68948c6c1361de62031
HEAD_REF main
PATCHES
001-fix-pkgconfig.patch
)
if("log" IN_LIST FEATURES)

View File

@ -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",

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,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 $<IF:$<TARGET_EXISTS:hdr_histogram::hdr_histogram>,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)

View File

@ -0,0 +1,14 @@
#include <hdr/hdr_histogram.h>
#include <hdr/hdr_thread.h>
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;
}

View File

@ -0,0 +1,12 @@
{
"name": "vcpkg-ci-hdr-histogram",
"version-string": "ci",
"description": "Validates hdr-histogram",
"dependencies": [
"hdr-histogram",
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View File

@ -3786,7 +3786,7 @@
},
"hdr-histogram": {
"baseline": "0.11.10",
"port-version": 0
"port-version": 1
},
"healpix": {
"baseline": "3.83",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "53068d224496e327c528fccce3cea76a0b9a4aab",
"version-semver": "0.11.10",
"port-version": 1
},
{
"git-tree": "f26c8c20182c8861fa8784d84ede1719a90ada37",
"version-semver": "0.11.10",