[PATCH] D111238: [Support][llvm] Add optional libCURL dependency to llvm build configuration
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 6 14:26:49 PDT 2021
phosek added a comment.
This logic should go into `config-ix.cmake`. I'd recommend following the same model we use for zlib here: https://github.com/llvm/llvm-project/blob/main/llvm/cmake/config-ix.cmake#L119. So this should look something like this:
if(LLVM_ENABLE_CURL)
if(LLVM_ENABLE_CURL STREQUAL FORCE_ON)
find_package(CURL REQUIRED)
elseif()
find_package(CURL)
endif()
if(CURL_FOUND)
# Check if curl we found is usable; for example, we may have found a 32-bit
# library on a 64-bit system which would result in a link-time failure.
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_INCLUDES ${CURL_INCLUDE_DIRS})
list(APPEND CMAKE_REQUIRED_LIBRARIES ${CURL_LIBRARY})
check_symbol_exists(curl_easy_init curl.h HAVE_CURL)
cmake_pop_check_state()
if(LLVM_ENABLE_CURL STREQUAL FORCE_ON AND NOT HAVE_CURL)
message(FATAL_ERROR "Failed to configure curl")
endif()
endif()
set(LLVM_ENABLE_CURL "${HAVE_CURL}")
endif()
To use it, you'd include `CURL::libcurl` as a dependency in you target, but only if `LLVM_ENABLE_CURL` is set. See https://github.com/llvm/llvm-project/blob/fd9a5b911d5e85c5184e9ed6907f53f23b41cd99/llvm/lib/Support/CMakeLists.txt#L25 for a zlib example.
================
Comment at: llvm/CMakeLists.txt:405
+if (LLVM_ENABLE_DEBUGINFOD_CLIENT)
+ set(LLVM_WITH_CURL 1)
----------------
Rather than having a `LLVM_ENABLE_DEBUGINFOD_CLIENT` variable, I'd prefer `LLVM_ENABLE_CURL` to control whether to search for curl or not. Whether debuginfod client should be built or not could be conditionalized on that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D111238/new/
https://reviews.llvm.org/D111238
More information about the llvm-commits
mailing list