Skip to content

Commit

Permalink
Add benchmark_main.pc to link main() containing library (#1779)
Browse files Browse the repository at this point in the history
This is similar to the addition in google/googletest@8604c4a#diff-eb8e49bdf5e9aafb996777a4f4302ad1efd281222bf3202eb9b77ce47496c345
that added pkg-config support in GTest. Without this, users
need to manually find the library containing `main()`.
  • Loading branch information
SoapGentoo committed Apr 14, 2024
1 parent d6ce145 commit c010560
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 7 additions & 0 deletions cmake/benchmark_main.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@

Name: @PROJECT_NAME@
Description: Google microbenchmark framework (with main() function)
Version: @VERSION@
Requires: benchmark
Libs: -L${libdir} -lbenchmark_main
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ set(generated_dir "${PROJECT_BINARY_DIR}")
set(version_config "${generated_dir}/${PROJECT_NAME}ConfigVersion.cmake")
set(project_config "${generated_dir}/${PROJECT_NAME}Config.cmake")
set(pkg_config "${generated_dir}/${PROJECT_NAME}.pc")
set(pkg_config_main "${generated_dir}/${PROJECT_NAME}_main.pc")
set(targets_to_export benchmark benchmark_main)
set(targets_export_name "${PROJECT_NAME}Targets")

Expand All @@ -105,6 +106,7 @@ write_basic_package_version_file(
)

configure_file("${PROJECT_SOURCE_DIR}/cmake/benchmark.pc.in" "${pkg_config}" @ONLY)
configure_file("${PROJECT_SOURCE_DIR}/cmake/benchmark_main.pc.in" "${pkg_config_main}" @ONLY)

export (
TARGETS ${targets_to_export}
Expand Down Expand Up @@ -133,7 +135,7 @@ if (BENCHMARK_ENABLE_INSTALL)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")

install(
FILES "${pkg_config}"
FILES "${pkg_config}" "${pkg_config_main}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")

install(
Expand Down

0 comments on commit c010560

Please sign in to comment.