Skip to content

Commit

Permalink
impl(compute): add google_cloud_cpp_compute INTERFACE cmake target (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
scotthart authored Sep 29, 2023
1 parent 731402e commit 30e9646
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
17 changes: 15 additions & 2 deletions google/cloud/compute/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ foreach (dir IN LISTS service_dirs)
list(APPEND compute_lib_targets "google_cloud_cpp_compute_${short_dir}")
endforeach ()

add_library(google_cloud_cpp_compute INTERFACE)
target_link_libraries(
google_cloud_cpp_compute
PUBLIC
INTERFACE ${compute_lib_targets})
set_target_properties(google_cloud_cpp_compute
PROPERTIES EXPORT_NAME "google-cloud-cpp::compute")
add_library(google-cloud-cpp::compute ALIAS google_cloud_cpp_compute)

# Create a header-only library for the mocks. We use a CMake `INTERFACE` library
# for these, a regular library would not work on macOS (where the library needs
# at least one .o file). Unfortunately INTERFACE libraries are a bit weird in
Expand Down Expand Up @@ -288,8 +297,8 @@ install(
# Install the libraries and headers in the locations determined by
# GNUInstallDirs
install(
TARGETS ${compute_lib_targets} ${compute_operation_lib_targets}
${compute_proto_lib_targets}
TARGETS google_cloud_cpp_compute ${compute_lib_targets}
${compute_operation_lib_targets} ${compute_proto_lib_targets}
google_cloud_cpp_compute_internal_protos
EXPORT google_cloud_cpp_compute-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
Expand Down Expand Up @@ -357,3 +366,7 @@ foreach (dir IN LISTS service_dirs)
"google_cloud_cpp_compute_zone_operations"
"google_cloud_cpp_compute_${short_dir}_protos")
endforeach ()

google_cloud_cpp_add_pkgconfig(
"compute" "The Cloud Compute API C++ Client Library"
"Provides C++ APIs to use the Cloud Compute API." ${compute_lib_targets})
2 changes: 1 addition & 1 deletion google/cloud/compute/quickstart/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ endif ()

# Define your targets.
add_executable(quickstart quickstart.cc)
target_link_libraries(quickstart google-cloud-cpp::compute_disks)
target_link_libraries(quickstart google-cloud-cpp::compute)
2 changes: 1 addition & 1 deletion google/cloud/compute/quickstart/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ all: $(BIN)/quickstart

# Configuration variables to compile and link against the Compute Engine API C++
# client library.
CLIENT_MODULE := google_cloud_cpp_compute_disks
CLIENT_MODULE := google_cloud_cpp_compute
CLIENT_CXXFLAGS := $(shell pkg-config $(CLIENT_MODULE) --cflags)
CLIENT_CXXLDFLAGS := $(shell pkg-config $(CLIENT_MODULE) --libs-only-L)
CLIENT_LIBS := $(shell pkg-config $(CLIENT_MODULE) --libs-only-l)
Expand Down

0 comments on commit 30e9646

Please sign in to comment.