Skip to content

Commit baa135c

Browse files
committed
Try something that is probably wrong
1 parent 67ec696 commit baa135c

File tree

2 files changed

+187
-3
lines changed

2 files changed

+187
-3
lines changed

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,9 +3052,8 @@ function(build_absl)
30523052
# This is due to upstream absl::cctz issue
30533053
# https://github.com/abseil/abseil-cpp/issues/283
30543054
find_library(CoreFoundation CoreFoundation)
3055-
# When ABSL_ENABLE_INSTALL is ON, the real target is "time" not "absl_time"
3056-
# Cannot use set_property on alias targets (absl::time is an alias)
3057-
set_property(TARGET time
3055+
# The time target (for absl::time) needs CoreFoundation on macOS
3056+
set_property(TARGET absl_time
30583057
APPEND
30593058
PROPERTY INTERFACE_LINK_LIBRARIES ${CoreFoundation})
30603059
endif()
@@ -3396,8 +3395,31 @@ function(build_google_cloud_cpp_storage)
33963395
# For now, force its inclusion from the underlying system or fail.
33973396
find_curl()
33983397

3398+
# Apply patch to add GOOGLE_CLOUD_CPP_ENABLE_INSTALL option so it does not install
3399+
# unconditionally when embedded via FetchContent. Otherwise, we would have to install
3400+
# dependecies like absl, crc32c, nlohmann_json, etc. which is not desirable.
3401+
set(GOOGLE_CLOUD_CPP_PATCH_COMMAND)
3402+
find_program(PATCH patch)
3403+
if(PATCH)
3404+
list(APPEND
3405+
GOOGLE_CLOUD_CPP_PATCH_COMMAND
3406+
${PATCH}
3407+
-p1
3408+
-i)
3409+
else()
3410+
find_program(GIT git)
3411+
if(GIT)
3412+
list(APPEND GOOGLE_CLOUD_CPP_PATCH_COMMAND ${GIT} apply)
3413+
endif()
3414+
endif()
3415+
if(GOOGLE_CLOUD_CPP_PATCH_COMMAND)
3416+
list(APPEND GOOGLE_CLOUD_CPP_PATCH_COMMAND
3417+
${CMAKE_CURRENT_LIST_DIR}/google-cloud-cpp-disable-install.patch)
3418+
endif()
3419+
33993420
fetchcontent_declare(google_cloud_cpp
34003421
${FC_DECLARE_COMMON_OPTIONS}
3422+
PATCH_COMMAND ${GOOGLE_CLOUD_CPP_PATCH_COMMAND}
34013423
URL ${google_cloud_cpp_storage_SOURCE_URL}
34023424
URL_HASH "SHA256=${ARROW_GOOGLE_CLOUD_CPP_BUILD_SHA256_CHECKSUM}")
34033425

@@ -3409,6 +3431,8 @@ function(build_google_cloud_cpp_storage)
34093431
# See also: https://github.com/googleapis/google-cloud-cpp/issues/8544
34103432
set(GOOGLE_CLOUD_CPP_ENABLE_WERROR OFF)
34113433
set(GOOGLE_CLOUD_CPP_WITH_MOCKS OFF)
3434+
# Disable installation when embedded via FetchContent
3435+
set(GOOGLE_CLOUD_CPP_ENABLE_INSTALL OFF)
34123436
set(BUILD_TESTING OFF)
34133437
# Unity build causes some build errors.
34143438
set(CMAKE_UNITY_BUILD FALSE)
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
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

Comments
 (0)