Skip to content

Commit 08e2812

Browse files
timosachsenbergtimosachsenbergclaudetimosachsenberg
authored
build: add libcurl to contrib build system (#173)
* build: add libcurl to contrib build system - Add CURL to BUILD_TYPE/VALID_BUILD_TYPES - Add curl-8.12.1 source archive config (SHA256 validated) - Add curl.cmake build macro with platform-native TLS backends (Schannel on Windows, SecureTransport on macOS, OpenSSL on Linux) - Add libcurl-dev packages to Dockerfiles - Disable LDAP and libpsl in curl build Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address PR review — fix curl build, integrate curl into Arrow S3 - Fix ZIP_ARGS quoting in curl.cmake (fixes Windows CI extraction failure) - Use ${BUILD_SHARED_LIBRARIES} instead of hardcoded BUILD_SHARED_LIBS=ON - Move CURL build before ARROW so Arrow can find contrib-built curl - Enable ARROW_S3 with AWSSDK_SOURCE=BUNDLED to use contrib curl - Align BUILD_TYPE help string with VALID_BUILD_TYPES (add EIGEN, HDF5) - Consolidate Dockerfile yum installs with cache cleanup Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: timosachsenberg <sachsenb@ibminode05.Cs.Uni-Tuebingen.De> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: timosachsenberg <sachsenb@ibminode06.Cs.Uni-Tuebingen.De>
1 parent 52b8eca commit 08e2812

7 files changed

Lines changed: 172 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@
9191
## - however: exec_process seems to handle our arguments incorrectly (at least on Windows). Check functionality before you commit!
9292

9393
# Determine what to build (all or single library)
94-
set( BUILD_TYPE LIST CACHE STRING "Can be used to restrict building to a single library: ALL,LIBSVM,XERCESC,BOOST,COINOR,BZIP2,ZLIB,GLPK,KISSFFT,OPENMP,ARROW,LIBZIP")
95-
set( VALID_BUILD_TYPES "ALL" "LIBSVM" "XERCESC" "BOOST" "COINOR" "BZIP2" "ZLIB" "GLPK" "EIGEN" "KISSFFT" "HDF5" "OPENMP" "ARROW" "LIBZIP")
94+
set( BUILD_TYPE LIST CACHE STRING "Can be used to restrict building to a single library: ALL,LIBSVM,XERCESC,BOOST,COINOR,BZIP2,ZLIB,GLPK,EIGEN,KISSFFT,HDF5,OPENMP,ARROW,LIBZIP,CURL")
95+
set( VALID_BUILD_TYPES "ALL" "LIBSVM" "XERCESC" "BOOST" "COINOR" "BZIP2" "ZLIB" "GLPK" "EIGEN" "KISSFFT" "HDF5" "OPENMP" "ARROW" "LIBZIP" "CURL")
9696

9797
# check build type
9898
if (BUILD_TYPE STREQUAL "HELP" OR BUILD_TYPE STREQUAL "LIST")
@@ -198,6 +198,7 @@ set(HDF5_DIR ${CONTRIB_BIN_SOURCE_DIR}/hdfsrc)
198198
set(OPENMP_DIR ${CONTRIB_BIN_SOURCE_DIR}/openmp-12.0.1.src)
199199
set(ARROW_DIR ${CONTRIB_BIN_SOURCE_DIR}/arrow-apache-arrow-23.0.0/cpp)
200200
set(LIBZIP_DIR ${CONTRIB_BIN_SOURCE_DIR}/libzip-1.11.4)
201+
set(CURL_DIR ${CONTRIB_BIN_SOURCE_DIR}/curl-8.12.1)
201202

202203
## source(archive) paths
203204
## PLEASE upload all source archives to
@@ -212,7 +213,7 @@ set(LIBZIP_DIR ${CONTRIB_BIN_SOURCE_DIR}/libzip-1.11.4)
212213
## set(ARCHIVE_ZLIB_SHA256 "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855")
213214
## NOTE: for local development you can simply place the *.tar.gz in the binary
214215
## directory to prevent the download and sha256 verification
215-
## LIBRARIES: BZIP2, ZLIB, BOOST, XERCES, LIBSVM, GLPK, COINOR, EIGEN, KISSFFT, HDF5, OPENMP, ARROW, LIBZIP
216+
## LIBRARIES: BZIP2, ZLIB, BOOST, XERCES, LIBSVM, GLPK, COINOR, EIGEN, KISSFFT, HDF5, OPENMP, ARROW, LIBZIP, CURL
216217

217218
set(ARCHIVE_BZIP2 bzip2-1.0.5.tar.gz)
218219
set(ARCHIVE_BZIP2_TAR bzip2-1.0.5.tar)
@@ -266,6 +267,10 @@ set(ARCHIVE_LIBZIP libzip-1.11.4.tar.gz)
266267
set(ARCHIVE_LIBZIP_TAR libzip-1.11.4.tar)
267268
set(ARCHIVE_LIBZIP_SHA256 "82e9f2f2421f9d7c2466bbc3173cd09595a88ea37db0d559a9d0a2dc60dc722e")
268269

270+
set(ARCHIVE_CURL curl-8.12.1.tar.gz)
271+
set(ARCHIVE_CURL_TAR curl-8.12.1.tar)
272+
set(ARCHIVE_CURL_SHA256 "7b40ea64947e0b440716a4d7f0b7aa56230a5341c8377d7b609649d4aea8dbcf")
273+
269274
## necessary for clean up .. change if install process of library changes
270275
set(INCLUDE_DIR_BOOST ${CONTRIB_BIN_INCLUDE_DIR}/boost)
271276
set(INCLUDE_DIR_XERCES ${CONTRIB_BIN_INCLUDE_DIR}/xercesc)
@@ -275,6 +280,7 @@ set(INCLUDE_DIR_EIGEN ${CONTRIB_BIN_INCLUDE_DIR}/eigen3)
275280
set(INCLUDE_DIR_KISSFFT ${CONTRIB_BIN_INCLUDE_DIR}/kissfft)
276281
set(INCLUDE_DIR_OPENMP ${CONTRIB_BIN_INCLUDE_DIR}/openmp.src)
277282
set(INCLUDE_DIR_ARROW ${CONTRIB_BIN_INCLUDE_DIR}/arrow)
283+
set(INCLUDE_DIR_CURL ${CONTRIB_BIN_INCLUDE_DIR}/curl)
278284

279285
## hack for simple libs that do not have include directories
280286
set(INCLUDE_FILES_LIBSVM ${CONTRIB_BIN_INCLUDE_DIR}/svm.h)
@@ -490,6 +496,7 @@ include ("${CMAKE_SOURCE_DIR}/libraries.cmake/hdf5.cmake")
490496
include ("${CMAKE_SOURCE_DIR}/libraries.cmake/openmp.cmake")
491497
include ("${CMAKE_SOURCE_DIR}/libraries.cmake/arrow.cmake")
492498
include ("${CMAKE_SOURCE_DIR}/libraries.cmake/libzip.cmake")
499+
include ("${CMAKE_SOURCE_DIR}/libraries.cmake/curl.cmake")
493500

494501
## build mac os x specific C/C++ flags
495502
set( OPENMS_CONTRIB_MACOSX_MIXED_MODE 0 CACHE INTERNAL "building multiple architectures on MacOSX" FORCE)
@@ -544,6 +551,15 @@ if (BUILD_TYPE STREQUAL "ALL" OR "BOOST" IN_LIST BUILD_TYPE)
544551
OPENMS_CONTRIB_BUILD_BOOST()
545552
endif()
546553

554+
##################################################
555+
### CURL ###
556+
##################################################
557+
if (BUILD_TYPE STREQUAL "ALL" OR "CURL" IN_LIST BUILD_TYPE)
558+
OPENMS_CLEAN_LIB("CURL")
559+
OPENMS_CONTRIB_BUILD_CURL()
560+
OPENMS_COPY_LIBS("CURL")
561+
endif()
562+
547563
##################################################
548564
### ARROW ###
549565
##################################################

dockerfiles/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ RUN apt-get -y update \
3131
libqt5opengl5-dev \
3232
libeigen3-dev \
3333
coinor-libcoinmp-dev \
34+
libcurl4-openssl-dev \
3435
&& rm -rf /var/lib/apt/lists/* \
3536
&& update-ca-certificates
3637

dockerfiles/pyopenms/manylinux/ARM64_Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ ARG OPENMS_VERSION="latest"
77
# Make source files from context available in docker
88
COPY . /contrib
99

10-
RUN yum install -y wget
11-
RUN yum install -y xz qt6-qtbase-devel qt6-qtsvg-devel
12-
RUN yum install -y libtool cmake3
10+
RUN yum install -y \
11+
wget \
12+
xz qt6-qtbase-devel qt6-qtsvg-devel \
13+
libtool cmake3 libcurl-devel \
14+
&& yum clean all \
15+
&& rm -rf /var/cache/yum
1316

1417
# Build contrib for the current checked out branch
1518
# During cleanup: removes archives

dockerfiles/pyopenms/manylinux/Dockerfile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ ARG OPENMS_VERSION="latest"
77
# Make source files from context available in docker
88
COPY . /contrib
99

10-
RUN yum install -y wget
11-
RUN yum install -y xz qt6-qtbase-devel qt6-qtsvg-devel
12-
RUN yum install -y libtool cmake3
10+
RUN yum install -y \
11+
wget \
12+
xz qt6-qtbase-devel qt6-qtsvg-devel \
13+
libtool cmake3 libcurl-devel \
14+
&& yum clean all \
15+
&& rm -rf /var/cache/yum
1316

1417
# Build contrib for the current checked out branch
1518
# During cleanup: removes archives
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Design: Integrate curl into Arrow's dependency chain
2+
3+
## Problem
4+
5+
jpfeuffer's review on PR #173 asks that the dependency chain
6+
curl -> aws-sdk -> arrow/parquet uses the same curl built by contrib.
7+
8+
Currently:
9+
- CURL is built after Arrow (wrong order)
10+
- Arrow has no S3/curl options enabled
11+
- Arrow does not bundle curl — it requires it via `find_package(CURL)`
12+
13+
## Approach
14+
15+
Build CURL before ARROW and configure Arrow to use it via the existing
16+
`CMAKE_PREFIX_PATH` mechanism (same pattern used for boost, zlib, bzip2).
17+
18+
## Changes
19+
20+
### 1. CMakeLists.txt — Reorder build
21+
22+
Move the CURL build block before ARROW. New order:
23+
... -> BOOST -> CURL -> ARROW -> ...
24+
25+
### 2. libraries.cmake/arrow.cmake — Enable S3 with bundled AWS SDK
26+
27+
Add to both Windows and Linux/macOS cmake invocations:
28+
- `-DARROW_S3=ON` — enables S3 filesystem, triggers AWS SDK + curl
29+
- `-DAWSSDK_SOURCE=BUNDLED` — Arrow builds AWS SDK from source, using our curl
30+
31+
Curl is found automatically via `CMAKE_PREFIX_PATH=${PROJECT_BINARY_DIR}`
32+
which is already set in arrow.cmake. No extra flags needed.
33+
34+
### 3. No other changes needed
35+
36+
- curl.cmake already installs to `${PROJECT_BINARY_DIR}`
37+
- Dockerfiles already have `libcurl-dev`
38+
- No new dependency resolution mechanism required
39+
40+
## Key facts
41+
42+
- Arrow 23.0.0 does NOT support `CURL_SOURCE=BUNDLED` — curl must be a system/pre-built dependency
43+
- Arrow finds curl via standard `find_package(CURL REQUIRED)` in its `find_curl()` macro
44+
- AWS SDK can be BUNDLED by Arrow, but still requires external curl

libraries.cmake/arrow.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ if (MSVC)
4242
-D ARROW_WITH_BZIP2=ON
4343
-D ARROW_WITH_ZSTD=ON
4444
-D ARROW_WITH_SNAPPY=ON
45+
-D ARROW_S3=ON
46+
-D AWSSDK_SOURCE=BUNDLED
4547
-D Snappy_SOURCE=BUNDLED
4648
-D zstd_SOURCE=BUNDLED
4749
-D Thrift_SOURCE=BUNDLED
@@ -147,6 +149,8 @@ else() ## Linux/MacOS
147149
"-DARROW_WITH_BZIP2=ON"
148150
"-DARROW_WITH_ZSTD=ON"
149151
"-DARROW_WITH_SNAPPY=ON"
152+
"-DARROW_S3=ON"
153+
"-DAWSSDK_SOURCE=BUNDLED"
150154
"-DSnappy_SOURCE=BUNDLED"
151155
"-Dzstd_SOURCE=BUNDLED"
152156
"-DThrift_SOURCE=BUNDLED"

libraries.cmake/curl.cmake

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
##################################################
2+
### libcurl ###
3+
##################################################
4+
5+
MACRO( OPENMS_CONTRIB_BUILD_CURL )
6+
OPENMS_LOGHEADER_LIBRARY("curl")
7+
8+
if(MSVC)
9+
set(ZIP_ARGS x -y -osrc)
10+
else()
11+
set(ZIP_ARGS xzf)
12+
endif()
13+
OPENMS_SMARTEXTRACT(ZIP_ARGS ARCHIVE_CURL "CURL" "CMakeLists.txt")
14+
15+
# curl doesn't allow insource builds
16+
set(_CURL_BUILD_DIR "${CURL_DIR}/build")
17+
file(TO_NATIVE_PATH "${_CURL_BUILD_DIR}" _CURL_NATIVE_BUILD_DIR)
18+
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_CURL_NATIVE_BUILD_DIR})
19+
20+
# Platform-specific TLS backend
21+
if(MSVC)
22+
set(_CURL_TLS_OPTION "-DCURL_USE_SCHANNEL=ON")
23+
elseif(APPLE)
24+
set(_CURL_TLS_OPTION "-DCURL_USE_SECTRANSP=ON")
25+
else()
26+
set(_CURL_TLS_OPTION "-DCURL_USE_OPENSSL=ON")
27+
endif()
28+
29+
if(APPLE)
30+
set(_CURL_EXTRA_ARGS
31+
"-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}"
32+
"-DCMAKE_OSX_SYSROOT=${CMAKE_OSX_SYSROOT}"
33+
"-DCMAKE_MACOSX_RPATH=TRUE"
34+
)
35+
else()
36+
set(_CURL_EXTRA_ARGS "")
37+
endif()
38+
39+
message(STATUS "Generating curl build system .. ")
40+
execute_process(COMMAND ${CMAKE_COMMAND}
41+
-G "${CMAKE_GENERATOR}"
42+
${ARCHITECTURE_OPTION_CMAKE}
43+
-D CMAKE_BUILD_TYPE=Release
44+
-D CMAKE_INSTALL_PREFIX=${PROJECT_BINARY_DIR}
45+
-D BUILD_SHARED_LIBS=${BUILD_SHARED_LIBRARIES}
46+
-D BUILD_CURL_EXE=OFF
47+
-D BUILD_TESTING=OFF
48+
-D CURL_DISABLE_LDAP=ON
49+
-D CURL_USE_LIBPSL=OFF
50+
${_CURL_TLS_OPTION}
51+
${_CURL_EXTRA_ARGS}
52+
${CURL_DIR}
53+
WORKING_DIRECTORY ${_CURL_NATIVE_BUILD_DIR}
54+
OUTPUT_VARIABLE _CURL_CMAKE_OUT
55+
ERROR_VARIABLE _CURL_CMAKE_ERR
56+
RESULT_VARIABLE _CURL_CMAKE_SUCCESS)
57+
58+
# output to logfile
59+
file(APPEND ${LOGFILE} ${_CURL_CMAKE_OUT})
60+
file(APPEND ${LOGFILE} ${_CURL_CMAKE_ERR})
61+
62+
if (NOT _CURL_CMAKE_SUCCESS EQUAL 0)
63+
message(FATAL_ERROR "Generating curl build system .. failed")
64+
else()
65+
message(STATUS "Generating curl build system .. done")
66+
endif()
67+
68+
# the install target on windows has a different name than on mac/lnx
69+
if(MSVC)
70+
set(_CURL_INSTALL_TARGET "INSTALL")
71+
else()
72+
set(_CURL_INSTALL_TARGET "install")
73+
endif()
74+
75+
message(STATUS "Building curl (Release) .. ")
76+
execute_process(COMMAND ${CMAKE_COMMAND} --build ${_CURL_NATIVE_BUILD_DIR} --target ${_CURL_INSTALL_TARGET} --config Release
77+
WORKING_DIRECTORY ${_CURL_NATIVE_BUILD_DIR}
78+
OUTPUT_VARIABLE _CURL_BUILD_OUT
79+
ERROR_VARIABLE _CURL_BUILD_ERR
80+
RESULT_VARIABLE _CURL_BUILD_SUCCESS)
81+
82+
# output to logfile
83+
file(APPEND ${LOGFILE} ${_CURL_BUILD_OUT})
84+
file(APPEND ${LOGFILE} ${_CURL_BUILD_ERR})
85+
86+
if (NOT _CURL_BUILD_SUCCESS EQUAL 0)
87+
message(FATAL_ERROR "Building curl (Release) .. failed")
88+
else()
89+
message(STATUS "Building curl (Release) .. done")
90+
endif()
91+
92+
ENDMACRO( OPENMS_CONTRIB_BUILD_CURL )

0 commit comments

Comments
 (0)