Skip to content

Commit abd021c

Browse files
assignUserkou
authored andcommitted
GH-44606: [C++] Add find module for abseil that handles missing version (#44613)
### Rationale for this change Abseil's recommended usage is to build from trunk, this version does not provide a package version in CMake which breaks `resolve_dependency`. ### What changes are included in this PR? Add `FindabslAlt.cmake` that adds a big version if it is missing to compare against our minimal version requirements. ### Are these changes tested? CI ### Are there any user-facing changes? Abseil build from head should now work without workaround. * GitHub Issue: #44606 Lead-authored-by: Jacob Wujciak-Jens <[email protected]> Co-authored-by: Sutou Kouhei <[email protected]> Signed-off-by: Jacob Wujciak-Jens <[email protected]>
1 parent 7e26edf commit abd021c

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

Diff for: cpp/cmake_modules/FindabslAlt.cmake

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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+
if(abslAlt_FOUND)
19+
return()
20+
endif()
21+
22+
set(find_package_args)
23+
24+
if(abslAlt_FIND_QUIETLY)
25+
list(APPEND find_package_args QUIET)
26+
endif()
27+
if(abslAlt_FIND_REQUIRED)
28+
list(APPEND find_package_args REQUIRED)
29+
endif()
30+
31+
find_package(absl ${find_package_args})
32+
33+
if(NOT DEFINED absl_VERSION)
34+
# Abseil does not define a version when build 'live at head'.
35+
# As this is their recommended path we need to define a large version to pass version checks.
36+
# CMake removes the '_head' suffix for version comparison but it will show up in the logs
37+
# and matches the abseil-cpp.pc version of 'head'
38+
set(absl_VERSION 99999999_head)
39+
endif()
40+
41+
set(abslAlt_VERSION ${absl_VERSION})
42+
43+
find_package_handle_standard_args(
44+
abslAlt
45+
REQUIRED_VARS absl_FOUND
46+
VERSION_VAR abslAlt_VERSION)

Diff for: cpp/cmake_modules/ThirdpartyToolchain.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -4169,7 +4169,7 @@ if(ARROW_WITH_GOOGLE_CLOUD_CPP OR ARROW_WITH_GRPC)
41694169
ARROW_PC_PACKAGE_NAME
41704170
${ARROW_ABSL_PC_PACKAGE_NAME}
41714171
HAVE_ALT
4172-
FALSE
4172+
TRUE
41734173
FORCE_ANY_NEWER_VERSION
41744174
TRUE
41754175
REQUIRED_VERSION

0 commit comments

Comments
 (0)