|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +diff --git a/CMakeLists.txt b/CMakeLists.txt |
| 19 | +index 3816333816..3e620b20a7 100644 |
| 20 | +--- a/CMakeLists.txt |
| 21 | ++++ b/CMakeLists.txt |
| 22 | +@@ -52,6 +52,11 @@ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") |
| 23 | + endif () |
| 24 | + endif () |
| 25 | + |
| 26 | ++option(GOOGLE_CLOUD_CPP_ENABLE_INSTALL |
| 27 | ++ "Enable installation of google-cloud-cpp headers and libraries" |
| 28 | ++ ON) |
| 29 | ++mark_as_advanced(GOOGLE_CLOUD_CPP_ENABLE_INSTALL) |
| 30 | ++ |
| 31 | + list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) |
| 32 | + include(SelectMSVCRuntime) |
| 33 | + |
| 34 | +diff --git a/cmake/GoogleCloudCppLibrary.cmake b/cmake/GoogleCloudCppLibrary.cmake |
| 35 | +index caee116a3a..5cbb03f697 100644 |
| 36 | +--- a/cmake/GoogleCloudCppLibrary.cmake |
| 37 | ++++ b/cmake/GoogleCloudCppLibrary.cmake |
| 38 | +@@ -87,6 +87,7 @@ function (google_cloud_cpp_add_library_protos library) |
| 39 | + set(library_target "google_cloud_cpp_${library}") |
| 40 | + |
| 41 | + # Export the CMake targets to make it easy to create configuration files. |
| 42 | ++ if(GOOGLE_CLOUD_CPP_ENABLE_INSTALL) |
| 43 | + install( |
| 44 | + EXPORT ${library_target}-targets |
| 45 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${library_target}" |
| 46 | +@@ -104,6 +105,7 @@ function (google_cloud_cpp_add_library_protos library) |
| 47 | + NAMELINK_COMPONENT google_cloud_cpp_development |
| 48 | + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 49 | + COMPONENT google_cloud_cpp_development) |
| 50 | ++ endif() |
| 51 | + |
| 52 | + # Create and install the CMake configuration files. |
| 53 | + include(CMakePackageConfigHelpers) |
| 54 | +@@ -115,12 +117,14 @@ function (google_cloud_cpp_add_library_protos library) |
| 55 | + VERSION ${PROJECT_VERSION} |
| 56 | + COMPATIBILITY ExactVersion) |
| 57 | + |
| 58 | ++ if(GOOGLE_CLOUD_CPP_ENABLE_INSTALL) |
| 59 | + install( |
| 60 | + FILES |
| 61 | + "${CMAKE_CURRENT_BINARY_DIR}/${library_target}-config.cmake" |
| 62 | + "${CMAKE_CURRENT_BINARY_DIR}/${library_target}-config-version.cmake" |
| 63 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${library_target}" |
| 64 | + COMPONENT google_cloud_cpp_development) |
| 65 | ++ endif() |
| 66 | + endfunction () |
| 67 | + |
| 68 | + # |
| 69 | +@@ -257,6 +261,8 @@ function (google_cloud_cpp_add_gapic_library library display_name) |
| 70 | + include(GNUInstallDirs) |
| 71 | + |
| 72 | + # Export the CMake targets to make it easy to create configuration files. |
| 73 | ++ |
| 74 | ++ if(GOOGLE_CLOUD_CPP_ENABLE_INSTALL) |
| 75 | + install( |
| 76 | + EXPORT ${library_target}-targets |
| 77 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${library_target}" |
| 78 | +@@ -275,6 +281,7 @@ function (google_cloud_cpp_add_gapic_library library display_name) |
| 79 | + NAMELINK_COMPONENT google_cloud_cpp_development |
| 80 | + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 81 | + COMPONENT google_cloud_cpp_development) |
| 82 | ++ endif() |
| 83 | + |
| 84 | + google_cloud_cpp_install_headers("${library_target}" |
| 85 | + "include/google/cloud/${library}") |
| 86 | +@@ -311,12 +318,14 @@ function (google_cloud_cpp_add_gapic_library library display_name) |
| 87 | + VERSION ${PROJECT_VERSION} |
| 88 | + COMPATIBILITY ExactVersion) |
| 89 | + |
| 90 | ++ if(GOOGLE_CLOUD_CPP_ENABLE_INSTALL) |
| 91 | + install( |
| 92 | + FILES |
| 93 | + "${CMAKE_CURRENT_BINARY_DIR}/${library_target}-config.cmake" |
| 94 | + "${CMAKE_CURRENT_BINARY_DIR}/${library_target}-config-version.cmake" |
| 95 | + DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${library_target}" |
| 96 | + COMPONENT google_cloud_cpp_development) |
| 97 | ++ endif() |
| 98 | + |
| 99 | + if (GOOGLE_CLOUD_CPP_WITH_MOCKS) |
| 100 | + # Create a header-only library for the mocks. We use a CMake `INTERFACE` |
| 101 | +diff --git a/google/cloud/google_cloud_cpp_common.cmake b/google/cloud/google_cloud_cpp_common.cmake |
| 102 | +index 5bbc510e18..bd931c17d2 100644 |
| 103 | +--- a/google/cloud/google_cloud_cpp_common.cmake |
| 104 | ++++ b/google/cloud/google_cloud_cpp_common.cmake |
| 105 | +@@ -218,6 +218,7 @@ add_library(google-cloud-cpp::common ALIAS google_cloud_cpp_common) |
| 106 | + |
| 107 | + create_bazel_config(google_cloud_cpp_common YEAR 2018) |
| 108 | + |
| 109 | ++if(GOOGLE_CLOUD_CPP_ENABLE_INSTALL) |
| 110 | + # Export the CMake targets to make it easy to create configuration files. |
| 111 | + install( |
| 112 | + EXPORT google_cloud_cpp_common-targets |
| 113 | +@@ -238,6 +239,7 @@ install( |
| 114 | + COMPONENT google_cloud_cpp_development) |
| 115 | + |
| 116 | + google_cloud_cpp_install_headers(google_cloud_cpp_common include/google/cloud) |
| 117 | ++endif() |
| 118 | + |
| 119 | + google_cloud_cpp_add_pkgconfig( |
| 120 | + "common" |
| 121 | +diff --git a/google/cloud/google_cloud_cpp_rest_internal.cmake b/google/cloud/google_cloud_cpp_rest_internal.cmake |
| 122 | +index 5da42523bf..3dcd7a9cc9 100644 |
| 123 | +--- a/google/cloud/google_cloud_cpp_rest_internal.cmake |
| 124 | ++++ b/google/cloud/google_cloud_cpp_rest_internal.cmake |
| 125 | +@@ -142,6 +142,7 @@ set_target_properties( |
| 126 | + add_library(google-cloud-cpp::rest_internal ALIAS |
| 127 | + google_cloud_cpp_rest_internal) |
| 128 | + |
| 129 | ++if(GOOGLE_CLOUD_CPP_ENABLE_INSTALL) |
| 130 | + # Export the CMake targets to make it easy to create configuration files. |
| 131 | + install( |
| 132 | + EXPORT google_cloud_cpp_rest_internal-targets |
| 133 | +@@ -163,6 +164,7 @@ install( |
| 134 | + |
| 135 | + google_cloud_cpp_install_headers(google_cloud_cpp_rest_internal |
| 136 | + include/google/cloud) |
| 137 | ++endif() |
| 138 | + |
| 139 | + google_cloud_cpp_add_pkgconfig( |
| 140 | + rest_internal "REST library for the Google Cloud C++ Client Library" |
| 141 | +diff --git a/google/cloud/storage/google_cloud_cpp_storage.cmake b/google/cloud/storage/google_cloud_cpp_storage.cmake |
| 142 | +index 8e69ad26b6..347250781c 100644 |
| 143 | +--- a/google/cloud/storage/google_cloud_cpp_storage.cmake |
| 144 | ++++ b/google/cloud/storage/google_cloud_cpp_storage.cmake |
| 145 | +@@ -296,6 +296,7 @@ add_library(google-cloud-cpp::storage ALIAS google_cloud_cpp_storage) |
| 146 | + |
| 147 | + create_bazel_config(google_cloud_cpp_storage) |
| 148 | + |
| 149 | ++if(GOOGLE_CLOUD_CPP_ENABLE_INSTALL) |
| 150 | + # Export the CMake targets to make it easy to create configuration files. |
| 151 | + install( |
| 152 | + EXPORT storage-targets |
| 153 | +@@ -312,6 +313,7 @@ install( |
| 154 | + NAMELINK_COMPONENT google_cloud_cpp_development |
| 155 | + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 156 | + COMPONENT google_cloud_cpp_development) |
| 157 | ++endif() |
| 158 | + |
| 159 | + google_cloud_cpp_install_headers(google_cloud_cpp_storage |
| 160 | + include/google/cloud/storage) |
0 commit comments