diff --git a/external/googleapis/CMakeLists.txt b/external/googleapis/CMakeLists.txt index 3e415924a154b..7c27588161c4d 100644 --- a/external/googleapis/CMakeLists.txt +++ b/external/googleapis/CMakeLists.txt @@ -226,7 +226,6 @@ set(external_googleapis_installed_libraries_list google_cloud_cpp_iam_v1_policy_protos google_cloud_cpp_logging_protos google_cloud_cpp_longrunning_operations_protos - google_cloud_cpp_monitoring_protos google_cloud_cpp_pubsub_protos google_cloud_cpp_spanner_protos google_cloud_cpp_storage_protos) @@ -448,16 +447,6 @@ set_target_properties( target_link_libraries(google_cloud_cpp_logging_type_protos INTERFACE google-cloud-cpp::logging_type_type_protos) -google_cloud_cpp_load_protolist(monitoring_list "protolists/monitoring.list") -google_cloud_cpp_load_protodeps(monitoring_deps "protodeps/monitoring.deps") -google_cloud_cpp_grpcpp_library( - google_cloud_cpp_monitoring_protos ${monitoring_list} - PROTO_PATH_DIRECTORIES "${EXTERNAL_GOOGLEAPIS_SOURCE}" - "${PROTO_INCLUDE_DIR}") -external_googleapis_set_version_and_alias(monitoring_protos) -target_link_libraries(google_cloud_cpp_monitoring_protos - PUBLIC ${monitoring_deps}) - google_cloud_cpp_load_protolist(pubsub_list "protolists/pubsub.list") google_cloud_cpp_load_protodeps(pubsub_deps "protodeps/pubsub.deps") google_cloud_cpp_grpcpp_library( diff --git a/google/cloud/monitoring/CMakeLists.txt b/google/cloud/monitoring/CMakeLists.txt index e038bb531200e..b3b5ba6bddfa8 100644 --- a/google/cloud/monitoring/CMakeLists.txt +++ b/google/cloud/monitoring/CMakeLists.txt @@ -14,90 +14,11 @@ # limitations under the License. # ~~~ -include(GoogleapisConfig) -set(DOXYGEN_PROJECT_NAME "Cloud Monitoring API C++ Client") -set(DOXYGEN_PROJECT_BRIEF "A C++ Client Library for the Cloud Monitoring API") -set(DOXYGEN_PROJECT_NUMBER "${PROJECT_VERSION}") -set(DOXYGEN_EXCLUDE_SYMBOLS "internal") -set(DOXYGEN_EXAMPLE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/quickstart") +include(GoogleCloudCppLibrary) -unset(mocks_globs) -unset(source_globs) -set(service_dirs "" "dashboard/v1/" "metricsscope/v1/" "v3/") -foreach (dir IN LISTS service_dirs) - string(REPLACE "/" "_" ns "${dir}") - list(APPEND source_globs "${dir}*.h" "${dir}*.cc" "${dir}internal/*") - list(APPEND mocks_globs "${dir}mocks/*.h") - list(APPEND DOXYGEN_EXCLUDE_SYMBOLS "monitoring_${ns}internal") - if (NOT dir STREQUAL "") - list(APPEND DOXYGEN_EXAMPLE_PATH - "${CMAKE_CURRENT_SOURCE_DIR}/${dir}samples") - endif () -endforeach () +set(GOOGLE_CLOUD_CPP_SERVICE_DIRS "" "dashboard/v1/" "metricsscope/v1/" "v3/") -include(GoogleCloudCppDoxygen) -google_cloud_cpp_doxygen_targets("monitoring" DEPENDS cloud-docs - google-cloud-cpp::monitoring_protos) - -include(GoogleCloudCppCommon) - -include(CompileProtos) -google_cloud_cpp_find_proto_include_dir(PROTO_INCLUDE_DIR) - -file( - GLOB source_files - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${source_globs}) -list(SORT source_files) -add_library(google_cloud_cpp_monitoring ${source_files}) -target_include_directories( - google_cloud_cpp_monitoring - PUBLIC $ - $ - $) -target_link_libraries( - google_cloud_cpp_monitoring - PUBLIC google-cloud-cpp::grpc_utils google-cloud-cpp::common - google-cloud-cpp::monitoring_protos) -google_cloud_cpp_add_common_options(google_cloud_cpp_monitoring) -set_target_properties( - google_cloud_cpp_monitoring - PROPERTIES EXPORT_NAME google-cloud-cpp::monitoring - VERSION "${PROJECT_VERSION}" - SOVERSION "${PROJECT_VERSION_MAJOR}") -target_compile_options(google_cloud_cpp_monitoring - PUBLIC ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG}) - -add_library(google-cloud-cpp::monitoring ALIAS google_cloud_cpp_monitoring) - -# 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 -# that they need absolute paths for their sources. -file( - GLOB relative_mock_files - RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" - ${mocks_globs}) -list(SORT relative_mock_files) -set(mock_files) -foreach (file IN LISTS relative_mock_files) - list(APPEND mock_files "${CMAKE_CURRENT_SOURCE_DIR}/${file}") -endforeach () -add_library(google_cloud_cpp_monitoring_mocks INTERFACE) -target_sources(google_cloud_cpp_monitoring_mocks INTERFACE ${mock_files}) -target_link_libraries( - google_cloud_cpp_monitoring_mocks - INTERFACE google-cloud-cpp::monitoring GTest::gmock_main GTest::gmock - GTest::gtest) -set_target_properties(google_cloud_cpp_monitoring_mocks - PROPERTIES EXPORT_NAME google-cloud-cpp::monitoring_mocks) -target_include_directories( - google_cloud_cpp_monitoring_mocks - INTERFACE $ - $ - $) -target_compile_options(google_cloud_cpp_monitoring_mocks - INTERFACE ${GOOGLE_CLOUD_CPP_EXCEPTIONS_FLAG}) +google_cloud_cpp_add_ga_grpc_library(monitoring "Cloud Monitoring API") if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS) add_executable(monitoring_quickstart "quickstart/quickstart.cc") @@ -111,70 +32,3 @@ if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS) set_tests_properties(monitoring_quickstart PROPERTIES LABELS "integration-test;quickstart") endif () - -# Get the destination directories based on the GNU recommendations. -include(GNUInstallDirs) - -# Export the CMake targets to make it easy to create configuration files. -install( - EXPORT google_cloud_cpp_monitoring-targets - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_monitoring" - COMPONENT google_cloud_cpp_development) - -# Install the libraries and headers in the locations determined by -# GNUInstallDirs -install( - TARGETS google_cloud_cpp_monitoring - EXPORT google_cloud_cpp_monitoring-targets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - COMPONENT google_cloud_cpp_runtime - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT google_cloud_cpp_runtime - NAMELINK_SKIP - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT google_cloud_cpp_development) -# With CMake-3.12 and higher we could avoid this separate command (and the -# duplication). -install( - TARGETS google_cloud_cpp_monitoring - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT google_cloud_cpp_development - NAMELINK_ONLY - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} - COMPONENT google_cloud_cpp_development) - -google_cloud_cpp_install_headers("google_cloud_cpp_monitoring" - "include/google/cloud/monitoring") -google_cloud_cpp_install_headers("google_cloud_cpp_monitoring_mocks" - "include/google/cloud/monitoring") - -google_cloud_cpp_add_pkgconfig( - monitoring - "The Cloud Monitoring API C++ Client Library" - "Provides C++ APIs to use the Cloud Monitoring API." - "google_cloud_cpp_grpc_utils" - "google_cloud_cpp_common" - "google_cloud_cpp_monitoring_protos") - -# Create and install the CMake configuration files. -include(CMakePackageConfigHelpers) -configure_file("config.cmake.in" "google_cloud_cpp_monitoring-config.cmake" - @ONLY) -write_basic_package_version_file( - "google_cloud_cpp_monitoring-config-version.cmake" - VERSION ${PROJECT_VERSION} - COMPATIBILITY ExactVersion) - -install( - FILES - "${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_monitoring-config.cmake" - "${CMAKE_CURRENT_BINARY_DIR}/google_cloud_cpp_monitoring-config-version.cmake" - DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/google_cloud_cpp_monitoring" - COMPONENT google_cloud_cpp_development) - -# google-cloud-cpp::monitoring must be defined before we can add the samples. -foreach (dir IN LISTS service_dirs) - if (BUILD_TESTING AND GOOGLE_CLOUD_CPP_ENABLE_CXX_EXCEPTIONS) - google_cloud_cpp_add_samples_relative("monitoring" "${dir}samples/") - endif () -endforeach ()