Skip to content

Commit de7f1dc

Browse files
authored
chore: add support to customize download url of vendored dependencies (#319)
Fixes #239
1 parent 68eeb2c commit de7f1dc

File tree

2 files changed

+113
-16
lines changed

2 files changed

+113
-16
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,28 @@ C++ implementation of [Apache Iceberg™](https://iceberg.apache.org/).
3131
- CMake 3.25 or higher
3232
- C++23 compliant compiler
3333

34+
## Customizing Dependency URLs
35+
36+
If you experience network issues when downloading dependencies, you can customize the download URLs using environment variables.
37+
38+
The following environment variables can be set to customize dependency URLs:
39+
40+
- `ICEBERG_ARROW_URL`: Apache Arrow tarball URL
41+
- `ICEBERG_AVRO_URL`: Apache Avro tarball URL
42+
- `ICEBERG_AVRO_GIT_URL`: Apache Avro git repository URL
43+
- `ICEBERG_NANOARROW_URL`: Nanoarrow tarball URL
44+
- `ICEBERG_CROARING_URL`: CRoaring tarball URL
45+
- `ICEBERG_NLOHMANN_JSON_URL`: nlohmann-json tarball URL
46+
- `ICEBERG_SPDLOG_URL`: spdlog tarball URL
47+
- `ICEBERG_CPR_URL`: cpr tarball URL
48+
49+
Example usage:
50+
51+
```bash
52+
export ICEBERG_ARROW_URL="https://your-mirror.com/apache-arrow-22.0.0.tar.gz"
53+
cmake -S . -B build
54+
```
55+
3456
## Build
3557

3658
### Build, Run Test and Install Core Libraries

cmake_modules/IcebergThirdpartyToolchain.cmake

Lines changed: 91 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,22 @@ set(ICEBERG_ARROW_INSTALL_INTERFACE_LIBS)
2222

2323
# ----------------------------------------------------------------------
2424
# Versions and URLs for toolchain builds
25+
#
26+
# The following environment variables can be set to customize dependency URLs:
27+
#
28+
# ICEBERG_ARROW_URL - Apache Arrow tarball URL
29+
# ICEBERG_AVRO_URL - Apache Avro tarball URL
30+
# ICEBERG_AVRO_GIT_URL - Apache Avro git repository URL
31+
# ICEBERG_NANOARROW_URL - Nanoarrow tarball URL
32+
# ICEBERG_CROARING_URL - CRoaring tarball URL
33+
# ICEBERG_NLOHMANN_JSON_URL - nlohmann-json tarball URL
34+
# ICEBERG_SPDLOG_URL - spdlog tarball URL
35+
# ICEBERG_CPR_URL - cpr tarball URL
36+
#
37+
# Example usage:
38+
# export ICEBERG_ARROW_URL="https://your-mirror.com/apache-arrow-22.0.0.tar.gz"
39+
# cmake -S . -B build
40+
#
2541

2642
set(ICEBERG_ARROW_BUILD_VERSION "22.0.0")
2743
set(ICEBERG_ARROW_BUILD_SHA256_CHECKSUM
@@ -164,17 +180,42 @@ function(resolve_avro_dependency)
164180
OFF
165181
CACHE BOOL "" FORCE)
166182

167-
fetchcontent_declare(avro-cpp
168-
${FC_DECLARE_COMMON_OPTIONS}
169-
# TODO: switch to Apache Avro 1.13.0 once released.
170-
GIT_REPOSITORY https://github.com/apache/avro.git
171-
GIT_TAG e6c308780e876b4c11a470b9900995947f7b0fb5
172-
SOURCE_SUBDIR
173-
lang/c++
174-
FIND_PACKAGE_ARGS
175-
NAMES
176-
avro-cpp
177-
CONFIG)
183+
if(DEFINED ENV{ICEBERG_AVRO_URL})
184+
# Support custom tarball URL
185+
fetchcontent_declare(avro-cpp
186+
${FC_DECLARE_COMMON_OPTIONS}
187+
URL $ENV{ICEBERG_AVRO_URL}
188+
SOURCE_SUBDIR
189+
lang/c++
190+
FIND_PACKAGE_ARGS
191+
NAMES
192+
avro-cpp
193+
CONFIG)
194+
elseif(DEFINED ENV{ICEBERG_AVRO_GIT_URL})
195+
# Support custom git URL for mirrors
196+
fetchcontent_declare(avro-cpp
197+
${FC_DECLARE_COMMON_OPTIONS}
198+
GIT_REPOSITORY $ENV{ICEBERG_AVRO_GIT_URL}
199+
GIT_TAG e6c308780e876b4c11a470b9900995947f7b0fb5
200+
SOURCE_SUBDIR
201+
lang/c++
202+
FIND_PACKAGE_ARGS
203+
NAMES
204+
avro-cpp
205+
CONFIG)
206+
else()
207+
# Default to GitHub - uses unreleased version
208+
fetchcontent_declare(avro-cpp
209+
${FC_DECLARE_COMMON_OPTIONS}
210+
GIT_REPOSITORY https://github.com/apache/avro.git
211+
GIT_TAG e6c308780e876b4c11a470b9900995947f7b0fb5
212+
SOURCE_SUBDIR
213+
lang/c++
214+
FIND_PACKAGE_ARGS
215+
NAMES
216+
avro-cpp
217+
CONFIG)
218+
endif()
178219

179220
fetchcontent_makeavailable(avro-cpp)
180221

@@ -221,9 +262,17 @@ endfunction()
221262
function(resolve_nanoarrow_dependency)
222263
prepare_fetchcontent()
223264

265+
if(DEFINED ENV{ICEBERG_NANOARROW_URL})
266+
set(NANOARROW_URL "$ENV{ICEBERG_NANOARROW_URL}")
267+
else()
268+
set(NANOARROW_URL
269+
"https://dlcdn.apache.org/arrow/apache-arrow-nanoarrow-0.7.0/apache-arrow-nanoarrow-0.7.0.tar.gz"
270+
)
271+
endif()
272+
224273
fetchcontent_declare(nanoarrow
225274
${FC_DECLARE_COMMON_OPTIONS}
226-
URL "https://dlcdn.apache.org/arrow/apache-arrow-nanoarrow-0.7.0/apache-arrow-nanoarrow-0.7.0.tar.gz"
275+
URL ${NANOARROW_URL}
227276
FIND_PACKAGE_ARGS
228277
NAMES
229278
nanoarrow
@@ -270,9 +319,16 @@ function(resolve_croaring_dependency)
270319
set(ENABLE_ROARING_TESTS OFF)
271320
set(ENABLE_ROARING_MICROBENCHMARKS OFF)
272321

322+
if(DEFINED ENV{ICEBERG_CROARING_URL})
323+
set(CROARING_URL "$ENV{ICEBERG_CROARING_URL}")
324+
else()
325+
set(CROARING_URL
326+
"https://github.com/RoaringBitmap/CRoaring/archive/refs/tags/v4.3.11.tar.gz")
327+
endif()
328+
273329
fetchcontent_declare(croaring
274330
${FC_DECLARE_COMMON_OPTIONS}
275-
URL "https://github.com/RoaringBitmap/CRoaring/archive/refs/tags/v4.3.11.tar.gz"
331+
URL ${CROARING_URL}
276332
FIND_PACKAGE_ARGS
277333
NAMES
278334
roaring
@@ -318,9 +374,16 @@ function(resolve_nlohmann_json_dependency)
318374
OFF
319375
CACHE BOOL "" FORCE)
320376

377+
if(DEFINED ENV{ICEBERG_NLOHMANN_JSON_URL})
378+
set(NLOHMANN_JSON_URL "$ENV{ICEBERG_NLOHMANN_JSON_URL}")
379+
else()
380+
set(NLOHMANN_JSON_URL
381+
"https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz")
382+
endif()
383+
321384
fetchcontent_declare(nlohmann_json
322385
${FC_DECLARE_COMMON_OPTIONS}
323-
URL "https://github.com/nlohmann/json/releases/download/v3.11.3/json.tar.xz"
386+
URL ${NLOHMANN_JSON_URL}
324387
FIND_PACKAGE_ARGS
325388
NAMES
326389
nlohmann_json
@@ -378,9 +441,15 @@ function(resolve_spdlog_dependency)
378441
ON
379442
CACHE BOOL "" FORCE)
380443

444+
if(DEFINED ENV{ICEBERG_SPDLOG_URL})
445+
set(SPDLOG_URL "$ENV{ICEBERG_SPDLOG_URL}")
446+
else()
447+
set(SPDLOG_URL "https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz")
448+
endif()
449+
381450
fetchcontent_declare(spdlog
382451
${FC_DECLARE_COMMON_OPTIONS}
383-
URL "https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz"
452+
URL ${SPDLOG_URL}
384453
FIND_PACKAGE_ARGS
385454
NAMES
386455
spdlog
@@ -440,9 +509,15 @@ function(resolve_cpr_dependency)
440509
set(CPR_ENABLE_SSL ON)
441510
set(CPR_USE_SYSTEM_CURL ON)
442511

512+
if(DEFINED ENV{ICEBERG_CPR_URL})
513+
set(CPR_URL "$ENV{ICEBERG_CPR_URL}")
514+
else()
515+
set(CPR_URL "https://github.com/libcpr/cpr/archive/refs/tags/1.12.0.tar.gz")
516+
endif()
517+
443518
fetchcontent_declare(cpr
444519
${FC_DECLARE_COMMON_OPTIONS}
445-
URL https://github.com/libcpr/cpr/archive/refs/tags/1.12.0.tar.gz
520+
URL ${CPR_URL}
446521
FIND_PACKAGE_ARGS
447522
NAMES
448523
cpr

0 commit comments

Comments
 (0)