Skip to content

Commit a382a1b

Browse files
koupitrou
andauthored
GH-45614: [C++] Use Boost's CMake packages instead of FindBoost.cmake in CMake (#45623)
### Rationale for this change It seems that `FindBoost.cmake` in CMake may not set dependencies correctly. Furthermore, it has been removed in CMake 4.0. ### What changes are included in this PR? Enable `CMP0167` to use Boost's CMake packages instead of `FindBoost.cmake` in CMake. ### Are these changes tested? Yes. ### Are there any user-facing changes? No. * GitHub Issue: #45614 * Closes: #45966 Lead-authored-by: Sutou Kouhei <kou@clear-code.com> Co-authored-by: Antoine Pitrou <antoine@python.org> Signed-off-by: Antoine Pitrou <antoine@python.org>
1 parent e1bb018 commit a382a1b

8 files changed

Lines changed: 42 additions & 128 deletions

File tree

.github/workflows/cpp.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,6 @@ jobs:
400400
ARROW_WITH_SNAPPY: ON
401401
ARROW_WITH_ZLIB: ON
402402
ARROW_WITH_ZSTD: ON
403-
# Don't use preinstalled Boost by empty BOOST_ROOT
404-
BOOST_ROOT: ""
405403
ARROW_CMAKE_ARGS: >-
406404
-DARROW_PACKAGE_PREFIX=/${{ matrix.msystem_lower}}
407405
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON

.github/workflows/ruby.yml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -234,12 +234,8 @@ jobs:
234234
ARROW_WITH_SNAPPY: ON
235235
ARROW_WITH_ZLIB: ON
236236
ARROW_WITH_ZSTD: ON
237-
# Don't use preinstalled Boost by empty BOOST_ROOT and
238-
# -DBoost_NO_BOOST_CMAKE=ON
239-
BOOST_ROOT: ""
240237
ARROW_CMAKE_ARGS: >-
241238
-DARROW_PACKAGE_PREFIX=/ucrt${{ matrix.mingw-n-bits }}
242-
-DBoost_NO_BOOST_CMAKE=ON
243239
-DCMAKE_FIND_PACKAGE_PREFER_CONFIG=ON
244240
CMAKE_UNITY_BUILD: ON
245241
steps:
@@ -318,9 +314,9 @@ jobs:
318314
319315
windows-msvc:
320316
name: AMD64 Windows MSVC GLib
321-
runs-on: windows-2019
317+
runs-on: windows-2022
322318
if: ${{ !contains(github.event.pull_request.title, 'WIP') }}
323-
timeout-minutes: 90
319+
timeout-minutes: 240
324320
strategy:
325321
fail-fast: false
326322
env:
@@ -356,10 +352,8 @@ jobs:
356352
CMAKE_CXX_STANDARD: "17"
357353
CMAKE_GENERATOR: Ninja
358354
CMAKE_INSTALL_PREFIX: "${{ github.workspace }}/dist"
359-
CMAKE_UNITY_BUILD: ON
360355
VCPKG_BINARY_SOURCES: 'clear;nuget,GitHub,readwrite'
361-
VCPKG_ROOT: "${{ github.workspace }}/vcpkg"
362-
VCPKG_TRIPLET: x64-windows
356+
VCPKG_DEFAULT_TRIPLET: x64-windows
363357
permissions:
364358
packages: write
365359
steps:
@@ -376,10 +370,6 @@ jobs:
376370
with:
377371
fetch-depth: 0
378372
submodules: recursive
379-
- name: Install vcpkg
380-
shell: bash
381-
run: |
382-
ci/scripts/install_vcpkg.sh "${VCPKG_ROOT}"
383373
- name: Install meson
384374
run: |
385375
python -m pip install meson
@@ -408,29 +398,23 @@ jobs:
408398
- name: Setup NuGet credentials for vcpkg caching
409399
shell: bash
410400
run: |
411-
$(vcpkg/vcpkg.exe fetch nuget | tail -n 1) \
401+
$(vcpkg fetch nuget | tail -n 1) \
412402
sources add \
413403
-source "https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json" \
414404
-storepasswordincleartext \
415405
-name "GitHub" \
416406
-username "$GITHUB_REPOSITORY_OWNER" \
417407
-password "${{ secrets.GITHUB_TOKEN }}"
418-
$(vcpkg/vcpkg.exe fetch nuget | tail -n 1) \
408+
$(vcpkg fetch nuget | tail -n 1) \
419409
setapikey "${{ secrets.GITHUB_TOKEN }}" \
420410
-source "https://nuget.pkg.github.com/$GITHUB_REPOSITORY_OWNER/index.json"
421-
- name: Build C++ vcpkg dependencies
422-
run: |
423-
vcpkg\vcpkg.exe install `
424-
--triplet $env:VCPKG_TRIPLET `
425-
--x-manifest-root cpp `
426-
--x-install-root build\cpp\vcpkg_installed
427411
- name: Build C++
428412
shell: cmd
429413
run: |
430-
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
414+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
431415
bash -c "ci/scripts/cpp_build.sh $(pwd) $(pwd)/build"
432416
- name: Build GLib
433417
shell: cmd
434418
run: |
435-
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
419+
call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64
436420
bash -c "ci/scripts/c_glib_build.sh $(pwd) $(pwd)/build"

c_glib/vcpkg.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,19 @@
55
"glib",
66
"gobject-introspection",
77
"pkgconf"
8+
],
9+
"$comment": "2025.02.14",
10+
"builtin-baseline": "d5ec528843d29e3a52d745a64b469f810b2cedbf",
11+
"overrides": [
12+
{
13+
"$comment":
14+
"We need gobject-introspection 1.80.0 or later for GLib 2.80.0 but vcpkg doesn't provide it yet.",
15+
"name": "glib",
16+
"version": "2.78.4"
17+
},
18+
{
19+
"name": "vcpkg-tool-meson",
20+
"version": "1.3.2"
21+
}
822
]
923
}

ci/scripts/c_glib_build.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ meson_pkg_config_path="${ARROW_HOME}/lib/pkgconfig"
4141

4242
mkdir -p "${build_dir}"
4343

44-
if [ -n "${VCPKG_ROOT:-}" ] && [ -n "${VCPKG_TRIPLET:-}" ]; then
44+
if [ -n "${VCPKG_DEFAULT_TRIPLET:-}" ]; then
4545
vcpkg_install_root="${build_root}/vcpkg_installed"
46-
"${VCPKG_ROOT}/vcpkg" install \
46+
vcpkg install \
4747
--x-manifest-root="${source_dir}" \
4848
--x-install-root="${vcpkg_install_root}"
49-
PKG_CONFIG="${vcpkg_install_root}/${VCPKG_TRIPLET}/tools/pkgconf/pkgconf.exe"
49+
PKG_CONFIG="${vcpkg_install_root}/${VCPKG_DEFAULT_TRIPLET}/tools/pkgconf/pkgconf.exe"
5050
export PKG_CONFIG
51-
meson_pkg_config_path="${vcpkg_install_root}/${VCPKG_TRIPLET}/lib/pkgconfig:${meson_pkg_config_path}"
51+
meson_pkg_config_path="${vcpkg_install_root}/${VCPKG_DEFAULT_TRIPLET}/lib/pkgconfig:${meson_pkg_config_path}"
5252
# Configure PATH for libraries required by the gobject-introspection generated binary
5353
cpp_vcpkg_install_root="${build_root}/cpp/vcpkg_installed"
54-
PATH="${cpp_vcpkg_install_root}/${VCPKG_TRIPLET}/debug/bin:${PATH}"
55-
PATH="${cpp_vcpkg_install_root}/${VCPKG_TRIPLET}/bin:${PATH}"
56-
PATH="${vcpkg_install_root}/${VCPKG_TRIPLET}/bin:${PATH}"
54+
PATH="${cpp_vcpkg_install_root}/${VCPKG_DEFAULT_TRIPLET}/debug/bin:${PATH}"
55+
PATH="${cpp_vcpkg_install_root}/${VCPKG_DEFAULT_TRIPLET}/bin:${PATH}"
56+
PATH="${vcpkg_install_root}/${VCPKG_DEFAULT_TRIPLET}/bin:${PATH}"
5757
fi
5858

5959
if [ -n "${VCToolsInstallDir:-}" ] && [ -n "${MSYSTEM:-}" ]; then

cpp/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,13 @@ if(POLICY CMP0135)
7171
cmake_policy(SET CMP0135 NEW)
7272
endif()
7373

74+
# https://cmake.org/cmake/help/latest/policy/CMP0167.html
75+
#
76+
# Use Boost's CMake packages instead of FindBoost.cmake in CMake.
77+
if(POLICY CMP0167)
78+
cmake_policy(SET CMP0167 NEW)
79+
endif()
80+
7481
# https://cmake.org/cmake/help/latest/policy/CMP0170.html
7582
#
7683
# CMP0170 is for enforcing dependency populations by users with

cpp/cmake_modules/ThirdpartyToolchain.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2743,6 +2743,10 @@ if(ARROW_WITH_ZSTD)
27432743
else()
27442744
set(ARROW_ZSTD_LIBZSTD zstd::libzstd_static)
27452745
endif()
2746+
# vcpkg uses zstd::libzstd
2747+
if(NOT TARGET ${ARROW_ZSTD_LIBZSTD} AND TARGET zstd::libzstd)
2748+
set(ARROW_ZSTD_LIBZSTD zstd::libzstd)
2749+
endif()
27462750
if(NOT TARGET ${ARROW_ZSTD_LIBZSTD})
27472751
message(FATAL_ERROR "Zstandard target doesn't exist: ${ARROW_ZSTD_LIBZSTD}")
27482752
endif()

cpp/cmake_modules/Usevcpkg.cmake

Lines changed: 0 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -116,52 +116,9 @@ if(NOT DEFINED VCPKG_MANIFEST_MODE AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg
116116
CACHE BOOL "Use vcpkg.json manifest")
117117
message(STATUS "vcpkg.json manifest found. Using VCPKG_MANIFEST_MODE: ON")
118118
endif()
119-
# vcpkg can install packages in three different places
120-
set(_INST_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}/vcpkg_installed") # try here first
121-
set(_INST_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/vcpkg_installed") # try here second
122-
set(_INST_VCPKG_ROOT "${VCPKG_ROOT}/installed")
123-
# Iterate over the places
124-
foreach(_INST_DIR ${_INST_BUILD_DIR} ${_INST_SOURCE_DIR} ${_INST_VCPKG_ROOT} "notfound")
125-
if(_INST_DIR STREQUAL "notfound")
126-
message(FATAL_ERROR "vcpkg installed libraries directory not found. "
127-
"Install packages with vcpkg before executing cmake.")
128-
elseif(NOT EXISTS "${_INST_DIR}")
129-
continue()
130-
elseif((_INST_DIR STREQUAL _INST_BUILD_DIR OR _INST_DIR STREQUAL _INST_SOURCE_DIR)
131-
AND NOT VCPKG_MANIFEST_MODE)
132-
# Do not look for packages in the build or source dirs if manifest mode is off
133-
message(STATUS "Skipped looking for installed packages in ${_INST_DIR} "
134-
"because -DVCPKG_MANIFEST_MODE=OFF")
135-
continue()
136-
else()
137-
message(STATUS "Looking for installed packages in ${_INST_DIR}")
138-
endif()
139-
if(DEFINED VCPKG_TARGET_TRIPLET)
140-
# Check if a subdirectory named VCPKG_TARGET_TRIPLET
141-
# exists in the vcpkg installed directory
142-
if(EXISTS "${_INST_DIR}/${VCPKG_TARGET_TRIPLET}")
143-
set(_VCPKG_INSTALLED_DIR "${_INST_DIR}")
144-
break()
145-
endif()
146-
else()
147-
# Infer VCPKG_TARGET_TRIPLET from the name of the
148-
# subdirectory in the vcpkg installed directory
149-
list_subdirs(_VCPKG_TRIPLET_SUBDIRS "${_INST_DIR}")
150-
list(REMOVE_ITEM _VCPKG_TRIPLET_SUBDIRS "vcpkg")
151-
list(LENGTH _VCPKG_TRIPLET_SUBDIRS _NUM_VCPKG_TRIPLET_SUBDIRS)
152-
if(_NUM_VCPKG_TRIPLET_SUBDIRS EQUAL 1)
153-
list(GET _VCPKG_TRIPLET_SUBDIRS 0 VCPKG_TARGET_TRIPLET)
154-
set(_VCPKG_INSTALLED_DIR "${_INST_DIR}")
155-
break()
156-
endif()
157-
endif()
158-
endforeach()
159119
if(NOT DEFINED VCPKG_TARGET_TRIPLET)
160120
message(FATAL_ERROR "Could not infer VCPKG_TARGET_TRIPLET. "
161121
"Specify triplet with -DVCPKG_TARGET_TRIPLET.")
162-
elseif(NOT DEFINED _VCPKG_INSTALLED_DIR)
163-
message(FATAL_ERROR "Could not find installed vcpkg packages for triplet ${VCPKG_TARGET_TRIPLET}. "
164-
"Install packages with vcpkg before executing cmake.")
165122
endif()
166123

167124
set(VCPKG_TARGET_TRIPLET
@@ -201,52 +158,3 @@ set(ARROW_VCPKG
201158
set(ARROW_DEPENDENCY_SOURCE
202159
"SYSTEM"
203160
CACHE STRING "The specified value VCPKG is implemented internally as SYSTEM" FORCE)
204-
205-
set(BOOST_ROOT
206-
"${ARROW_VCPKG_PREFIX}"
207-
CACHE STRING "")
208-
set(BOOST_INCLUDEDIR
209-
"${ARROW_VCPKG_PREFIX}/include/boost"
210-
CACHE STRING "")
211-
set(BOOST_LIBRARYDIR
212-
"${ARROW_VCPKG_PREFIX}/lib"
213-
CACHE STRING "")
214-
set(OPENSSL_INCLUDE_DIR
215-
"${ARROW_VCPKG_PREFIX}/include"
216-
CACHE STRING "")
217-
set(OPENSSL_LIBRARIES
218-
"${ARROW_VCPKG_PREFIX}/lib"
219-
CACHE STRING "")
220-
set(OPENSSL_ROOT_DIR
221-
"${ARROW_VCPKG_PREFIX}"
222-
CACHE STRING "")
223-
set(Thrift_ROOT
224-
"${ARROW_VCPKG_PREFIX}/lib"
225-
CACHE STRING "")
226-
set(ZSTD_INCLUDE_DIR
227-
"${ARROW_VCPKG_PREFIX}/include"
228-
CACHE STRING "")
229-
set(ZSTD_ROOT
230-
"${ARROW_VCPKG_PREFIX}"
231-
CACHE STRING "")
232-
set(BROTLI_ROOT
233-
"${ARROW_VCPKG_PREFIX}"
234-
CACHE STRING "")
235-
set(LZ4_ROOT
236-
"${ARROW_VCPKG_PREFIX}"
237-
CACHE STRING "")
238-
239-
if(CMAKE_HOST_WIN32)
240-
set(LZ4_MSVC_LIB_PREFIX
241-
""
242-
CACHE STRING "")
243-
set(LZ4_MSVC_STATIC_LIB_SUFFIX
244-
""
245-
CACHE STRING "")
246-
set(ZSTD_MSVC_LIB_PREFIX
247-
""
248-
CACHE STRING "")
249-
set(ZSTD_MSVC_STATIC_LIB_SUFFIX
250-
""
251-
CACHE STRING "")
252-
endif()

cpp/vcpkg.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
]
1616
},
1717
"benchmark",
18+
"boost-cmake",
1819
"boost-crc",
1920
"boost-filesystem",
2021
"boost-multiprecision",
@@ -51,8 +52,6 @@
5152
"zlib",
5253
"zstd"
5354
],
54-
"overrides": [
55-
{ "name": "gtest", "version": "1.10.0", "port-version": 4 }
56-
],
57-
"builtin-baseline": "3d8f78171a2a37d461077bf8d063256b63e25a4f"
55+
"$comment": "2025.02.14",
56+
"builtin-baseline": "d5ec528843d29e3a52d745a64b469f810b2cedbf"
5857
}

0 commit comments

Comments
 (0)