From dcab21d8be1b6505cfed14e69c70d668204e0034 Mon Sep 17 00:00:00 2001 From: dbolduc Date: Thu, 27 Oct 2022 00:36:33 -0400 Subject: [PATCH] address some review comments --- ci/cloudbuild/builds/cmake-install.sh | 1 - ci/verify_current_targets/CMakeLists.txt | 1 + cmake/AddPkgConfig.cmake | 33 ++++++++++++++++--- google/cloud/pubsub/CMakeLists.txt | 11 +++---- ...g-mocks.cmake.in => mocks-config.cmake.in} | 4 +-- 5 files changed, 37 insertions(+), 13 deletions(-) rename google/cloud/pubsub/{config-mocks.cmake.in => mocks-config.cmake.in} (93%) diff --git a/ci/cloudbuild/builds/cmake-install.sh b/ci/cloudbuild/builds/cmake-install.sh index 5bbd7aa488d7..dcaadf9efa8f 100755 --- a/ci/cloudbuild/builds/cmake-install.sh +++ b/ci/cloudbuild/builds/cmake-install.sh @@ -110,7 +110,6 @@ expected_dirs+=( ./lib64/cmake/google_cloud_cpp_googleapis ./lib64/cmake/google_cloud_cpp_grafeas ./lib64/cmake/google_cloud_cpp_grpc_utils - ./lib64/cmake/google_cloud_cpp_pubsub ./lib64/cmake/google_cloud_cpp_pubsub_mocks ./lib64/cmake/google_cloud_cpp_rest_internal ./lib64/cmake/google_cloud_cpp_rest_protobuf_internal diff --git a/ci/verify_current_targets/CMakeLists.txt b/ci/verify_current_targets/CMakeLists.txt index f5252017493c..a40d8d8fa7a7 100644 --- a/ci/verify_current_targets/CMakeLists.txt +++ b/ci/verify_current_targets/CMakeLists.txt @@ -30,6 +30,7 @@ set(ga_libraries iam logging pubsub + pubsub_mocks spanner storage) diff --git a/cmake/AddPkgConfig.cmake b/cmake/AddPkgConfig.cmake index f1964270fd6a..360771cfade8 100644 --- a/cmake/AddPkgConfig.cmake +++ b/cmake/AddPkgConfig.cmake @@ -35,16 +35,16 @@ macro (google_cloud_cpp_set_pkgconfig_paths) endmacro () # -# Create the pkgconfig configuration file (aka *.pc file) and the rules to -# install it. +# Implementation to create the pkgconfig configuration file (aka *.pc file) and +# the rules to install it. # # * library: the name of the library, such as `storage`, or `spanner` # * ARGN: the names of any pkgconfig modules the generated module depends on # -function (google_cloud_cpp_add_pkgconfig library name description) +function (google_cloud_cpp_add_pkgconfig_impl library name description pc_libs) set(GOOGLE_CLOUD_CPP_PC_NAME "${name}") set(GOOGLE_CLOUD_CPP_PC_DESCRIPTION "${description}") - set(GOOGLE_CLOUD_CPP_PC_LIBS "-lgoogle_cloud_cpp_${library}") + set(GOOGLE_CLOUD_CPP_PC_LIBS "${pc_libs}") string(CONCAT GOOGLE_CLOUD_CPP_PC_REQUIRES ${ARGN}) google_cloud_cpp_set_pkgconfig_paths() @@ -56,3 +56,28 @@ function (google_cloud_cpp_add_pkgconfig library name description) DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig" COMPONENT google_cloud_cpp_development) endfunction () + +# +# Create the pkgconfig configuration file (aka *.pc file) and the rules to +# install it. +# +# * library: the name of the library, such as `storage`, or `spanner` +# * ARGN: the names of any pkgconfig modules the generated module depends on +# +function (google_cloud_cpp_add_pkgconfig library name description) + google_cloud_cpp_add_pkgconfig_impl("${library}" "${name}" "${description}" + "-lgoogle_cloud_cpp_${library}" ${ARGN}) +endfunction () + +# +# Create the pkgconfig configuration file (aka *.pc file) and the rules to +# install it for an interface library. These libraries only contain headers, so +# they do not generate lib files to link against with `-l`. +# +# * library: the name of the library, such as `storage`, or `spanner` +# * ARGN: the names of any pkgconfig modules the generated module depends on +# +function (google_cloud_cpp_add_pkgconfig_interface library name description) + google_cloud_cpp_add_pkgconfig_impl("${library}" "${name}" "${description}" + "" ${ARGN}) +endfunction () diff --git a/google/cloud/pubsub/CMakeLists.txt b/google/cloud/pubsub/CMakeLists.txt index a09a44ce208e..a008ff4a7a43 100644 --- a/google/cloud/pubsub/CMakeLists.txt +++ b/google/cloud/pubsub/CMakeLists.txt @@ -426,14 +426,13 @@ install( DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_pubsub" COMPONENT google_cloud_cpp_development) -google_cloud_cpp_add_pkgconfig( - pubsub_mocks "Mocks for the Google Cloud Pub/Sub C++ Client Library" - "Provides mock classes for the Google Cloud Pub/Sub C++ APIs." - "google_cloud_cpp_pubsub" " gtest") +google_cloud_cpp_add_pkgconfig_interface( + pubsub_mocks "Google Cloud C++ Pub/Sub Mocks" + "Mocks for the Google Cloud Pub/Sub C++ Client Library" + "google_cloud_cpp_pubsub" " gmock_main") # Create and install the CMake configuration files. -include(CMakePackageConfigHelpers) -configure_file("config-mocks.cmake.in" +configure_file("mocks-config.cmake.in" "google_cloud_cpp_pubsub_mocks-config.cmake" @ONLY) write_basic_package_version_file( "google_cloud_cpp_pubsub_mocks-config-version.cmake" diff --git a/google/cloud/pubsub/config-mocks.cmake.in b/google/cloud/pubsub/mocks-config.cmake.in similarity index 93% rename from google/cloud/pubsub/config-mocks.cmake.in rename to google/cloud/pubsub/mocks-config.cmake.in index cb9254e586ba..456c837f571c 100644 --- a/google/cloud/pubsub/config-mocks.cmake.in +++ b/google/cloud/pubsub/mocks-config.cmake.in @@ -1,4 +1,4 @@ -# Copyright 2020 Google LLC +# Copyright 2022 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -14,6 +14,6 @@ include(CMakeFindDependencyMacro) find_dependency(google_cloud_cpp_pubsub) -find_dependency(gtest) +find_dependency(GTest) include("${CMAKE_CURRENT_LIST_DIR}/pubsub_mocks-targets.cmake")