Skip to content

Commit 83515b8

Browse files
timosachsenbergclaude
authored andcommitted
build: add libcurl to contrib build system
- Add curl.cmake build script (CMake-based, uses platform-native TLS) - Add curl-8.12.1 archive definition - Update download base URL to current contrib-sources release (3.6.0) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4bc4c41 commit 83515b8

3 files changed

Lines changed: 110 additions & 3 deletions

File tree

CMakeLists.txt

Lines changed: 18 additions & 2 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")
95-
set( VALID_BUILD_TYPES "ALL" "LIBSVM" "XERCESC" "BOOST" "COINOR" "BZIP2" "ZLIB" "GLPK" "EIGEN" "KISSFFT" "HDF5" "OPENMP")
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,CURL")
95+
set( VALID_BUILD_TYPES "ALL" "LIBSVM" "XERCESC" "BOOST" "COINOR" "BZIP2" "ZLIB" "GLPK" "EIGEN" "KISSFFT" "HDF5" "OPENMP" "CURL")
9696

9797
# check build type
9898
if (BUILD_TYPE STREQUAL "HELP" OR BUILD_TYPE STREQUAL "LIST")
@@ -196,6 +196,7 @@ set(EIGEN_DIR ${CONTRIB_BIN_SOURCE_DIR}/eigen-3.4.0)
196196
set(KISSFFT_DIR ${CONTRIB_BIN_SOURCE_DIR}/kissfft)
197197
set(HDF5_DIR ${CONTRIB_BIN_SOURCE_DIR}/hdfsrc)
198198
set(OPENMP_DIR ${CONTRIB_BIN_SOURCE_DIR}/openmp-12.0.1.src)
199+
set(CURL_DIR ${CONTRIB_BIN_SOURCE_DIR}/curl-8.12.1)
199200

200201
## source(archive) paths
201202
## PLEASE upload all source archives to
@@ -275,6 +276,10 @@ set(ARCHIVE_OPENMP openmp-12.0.1.src.tar.xz)
275276
set(ARCHIVE_OPENMP_tar openmp-12.0.1.src.tar)
276277
set(ARCHIVE_OPENMP_SHA1 "7c051f6050ff23763b253a757927774b5eeaf644")
277278

279+
set(ARCHIVE_CURL curl-8.12.1.tar.gz)
280+
set(ARCHIVE_CURL_TAR curl-8.12.1.tar)
281+
set(ARCHIVE_CURL_SHA1 "03a503613a10a0f51ecd620cdc825ced4c5cc193")
282+
278283
## necessary for clean up .. change if install process of library changes
279284
set(INCLUDE_DIR_BOOST ${CONTRIB_BIN_INCLUDE_DIR}/boost)
280285
set(INCLUDE_DIR_XERCES ${CONTRIB_BIN_INCLUDE_DIR}/xercesc)
@@ -283,6 +288,7 @@ set(INCLUDE_DIR_COINOR ${CONTRIB_BIN_INCLUDE_DIR}/coin)
283288
set(INCLUDE_DIR_EIGEN ${CONTRIB_BIN_INCLUDE_DIR}/eigen3)
284289
set(INCLUDE_DIR_KISSFFT ${CONTRIB_BIN_INCLUDE_DIR}/kissfft)
285290
set(INCLUDE_DIR_OPENMP ${CONTRIB_BIN_INCLUDE_DIR}/openmp.src)
291+
set(INCLUDE_DIR_CURL ${CONTRIB_BIN_INCLUDE_DIR}/curl)
286292

287293
## hack for simple libs that do not have include directories
288294
set(INCLUDE_FILES_LIBSVM ${CONTRIB_BIN_INCLUDE_DIR}/svm.h)
@@ -491,6 +497,7 @@ include ("${CMAKE_SOURCE_DIR}/libraries.cmake/eigen.cmake")
491497
include ("${CMAKE_SOURCE_DIR}/libraries.cmake/kissfft.cmake")
492498
include ("${CMAKE_SOURCE_DIR}/libraries.cmake/hdf5.cmake")
493499
include ("${CMAKE_SOURCE_DIR}/libraries.cmake/openmp.cmake")
500+
include ("${CMAKE_SOURCE_DIR}/libraries.cmake/curl.cmake")
494501

495502
## build mac os x specific C/C++ flags
496503
set( OPENMS_CONTRIB_MACOSX_MIXED_MODE 0 CACHE INTERNAL "building multiple architectures on MacOSX" FORCE)
@@ -629,6 +636,15 @@ if ("OPENMP" IN_LIST BUILD_TYPE)
629636
OPENMS_COPY_LIBS("OPENMP")
630637
endif()
631638

639+
##################################################
640+
### CURL ###
641+
##################################################
642+
if (BUILD_TYPE STREQUAL "ALL" OR "CURL" IN_LIST BUILD_TYPE)
643+
OPENMS_CLEAN_LIB("CURL")
644+
OPENMS_CONTRIB_BUILD_CURL()
645+
OPENMS_COPY_LIBS("CURL")
646+
endif()
647+
632648
## finally copy README.txt to project-binary directory to mark process complete
633649
configure_file("${PROJECT_SOURCE_DIR}/README.md" "${PROJECT_BINARY_DIR}/README_contrib.txt" COPYONLY)
634650

libraries.cmake/curl.cmake

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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=ON
46+
-D BUILD_CURL_EXE=OFF
47+
-D BUILD_TESTING=OFF
48+
-D CURL_DISABLE_LDAP=ON
49+
${_CURL_TLS_OPTION}
50+
${_CURL_EXTRA_ARGS}
51+
${CURL_DIR}
52+
WORKING_DIRECTORY ${_CURL_NATIVE_BUILD_DIR}
53+
OUTPUT_VARIABLE _CURL_CMAKE_OUT
54+
ERROR_VARIABLE _CURL_CMAKE_ERR
55+
RESULT_VARIABLE _CURL_CMAKE_SUCCESS)
56+
57+
# output to logfile
58+
file(APPEND ${LOGFILE} ${_CURL_CMAKE_OUT})
59+
file(APPEND ${LOGFILE} ${_CURL_CMAKE_ERR})
60+
61+
if (NOT _CURL_CMAKE_SUCCESS EQUAL 0)
62+
message(FATAL_ERROR "Generating curl build system .. failed")
63+
else()
64+
message(STATUS "Generating curl build system .. done")
65+
endif()
66+
67+
# the install target on windows has a different name than on mac/lnx
68+
if(MSVC)
69+
set(_CURL_INSTALL_TARGET "INSTALL")
70+
else()
71+
set(_CURL_INSTALL_TARGET "install")
72+
endif()
73+
74+
message(STATUS "Building curl (Release) .. ")
75+
execute_process(COMMAND ${CMAKE_COMMAND} --build ${_CURL_NATIVE_BUILD_DIR} --target ${_CURL_INSTALL_TARGET} --config Release
76+
WORKING_DIRECTORY ${_CURL_NATIVE_BUILD_DIR}
77+
OUTPUT_VARIABLE _CURL_BUILD_OUT
78+
ERROR_VARIABLE _CURL_BUILD_ERR
79+
RESULT_VARIABLE _CURL_BUILD_SUCCESS)
80+
81+
# output to logfile
82+
file(APPEND ${LOGFILE} ${_CURL_BUILD_OUT})
83+
file(APPEND ${LOGFILE} ${_CURL_BUILD_ERR})
84+
85+
if (NOT _CURL_BUILD_SUCCESS EQUAL 0)
86+
message(FATAL_ERROR "Building curl (Release) .. failed")
87+
else()
88+
message(STATUS "Building curl (Release) .. done")
89+
endif()
90+
91+
ENDMACRO( OPENMS_CONTRIB_BUILD_CURL )

macros.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ endmacro()
7878
## downloads the archive for the given library
7979
## @param libname The library that should be downloaded
8080
macro(download_contrib_archive libname)
81-
set(_BASE_URL "https://github.com/OpenMS/contrib-sources/releases/download/2024-04-29-000000/")
81+
set(_BASE_URL "https://github.com/OpenMS/contrib-sources/releases/download/3.6.0/")
8282

8383
# the files/folders where downloads are stored
8484
set(_archive_folder "${PROJECT_BINARY_DIR}/archives")

0 commit comments

Comments
 (0)