From 71f4218c1abf471eed27ccfbf98055a90ace39f6 Mon Sep 17 00:00:00 2001 From: Chris Cotter Date: Wed, 3 Jul 2024 14:16:43 -0400 Subject: [PATCH] Add -lkstat to the .pc for Solaris (#1801) * Add -lkstat to the .pc for Solaris This fixes linking for projects that rely on pkg-config to generate the link line on Solaris. Test plan: Built the project locally on Solaris and verified -kstat appears in the .pc file ``` $ cat lib/pkgconfig/benchmark.pc | grep Libs.private Libs.private: -lpthread -lkstat ``` * Use BENCHMARK_PRIVATE_LINK_LIBRARIES --- cmake/benchmark.pc.in | 2 +- src/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/benchmark.pc.in b/cmake/benchmark.pc.in index 9dae881c..043f2fc7 100644 --- a/cmake/benchmark.pc.in +++ b/cmake/benchmark.pc.in @@ -8,5 +8,5 @@ Description: Google microbenchmark framework Version: @VERSION@ Libs: -L${libdir} -lbenchmark -Libs.private: -lpthread +Libs.private: -lpthread @BENCHMARK_PRIVATE_LINK_LIBRARIES@ Cflags: -I${includedir} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5551099b..d17964f9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,6 +64,7 @@ endif() # We need extra libraries on Solaris if(${CMAKE_SYSTEM_NAME} MATCHES "SunOS") target_link_libraries(benchmark PRIVATE kstat) + set(BENCHMARK_PRIVATE_LINK_LIBRARIES -lkstat) endif() if (NOT BUILD_SHARED_LIBS)