Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(pubsub): install pubsub_mocks pkg #10008

Merged
merged 3 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ci/cloudbuild/builds/cmake-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ 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_mocks
./lib64/cmake/google_cloud_cpp_rest_internal
./lib64/cmake/google_cloud_cpp_rest_protobuf_internal
./lib64/cmake/google_cloud_cpp_spanner
Expand Down
1 change: 1 addition & 0 deletions ci/verify_current_targets/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set(ga_libraries
iam
logging
pubsub
pubsub_mocks
spanner
storage)

Expand Down
33 changes: 29 additions & 4 deletions cmake/AddPkgConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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 ()
28 changes: 27 additions & 1 deletion google/cloud/pubsub/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,15 @@ install(
google_cloud_cpp_install_headers("google_cloud_cpp_pubsub"
"include/google/cloud/pubsub")

# Export the CMake targets to make it easy to create configuration files.
install(
EXPORT pubsub_mocks-targets
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_pubsub_mocks"
COMPONENT google_cloud_cpp_development)

install(
TARGETS google_cloud_cpp_pubsub_mocks
EXPORT pubsub-targets
EXPORT pubsub_mocks-targets
COMPONENT google_cloud_cpp_development)
install(
FILES ${google_cloud_cpp_pubsub_mocks_hdrs}
Expand Down Expand Up @@ -419,3 +425,23 @@ install(
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_pubsub-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_pubsub"
COMPONENT google_cloud_cpp_development)

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.
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"
VERSION ${PROJECT_VERSION}
COMPATIBILITY ExactVersion)

install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_pubsub_mocks-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_pubsub_mocks-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_pubsub_mocks"
COMPONENT google_cloud_cpp_development)
19 changes: 19 additions & 0 deletions google/cloud/pubsub/mocks-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include(CMakeFindDependencyMacro)
find_dependency(google_cloud_cpp_pubsub)
find_dependency(GTest)

include("${CMAKE_CURRENT_LIST_DIR}/pubsub_mocks-targets.cmake")