[llvm] 2de43d4 - [CMake] Add optional libCURL dependency to llvm build configuration

Petr Hosek via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 13 10:58:49 PDT 2021


Author: Noah Shutty
Date: 2021-10-13T10:58:10-07:00
New Revision: 2de43d4202a3caea894f6b91de4604fd2a7501fe

URL: https://github.com/llvm/llvm-project/commit/2de43d4202a3caea894f6b91de4604fd2a7501fe
DIFF: https://github.com/llvm/llvm-project/commit/2de43d4202a3caea894f6b91de4604fd2a7501fe.diff

LOG: [CMake] Add optional libCURL dependency to llvm build configuration

This finds the curl libraries if LLVM_ENABLE_CURL is set. This is needed
to implement the debuginfod client library in LLVM.

Patch By: noajshu

Differential Revision: https://reviews.llvm.org/D111238

Added: 
    

Modified: 
    llvm/cmake/config-ix.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 3569c2d1389af..c81b7e47ac788 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -159,6 +159,27 @@ if(LLVM_ENABLE_LIBXML2)
   set(LLVM_ENABLE_LIBXML2 "${HAVE_LIBXML2}")
 endif()
 
+if(LLVM_ENABLE_CURL)
+  if(LLVM_ENABLE_CURL STREQUAL FORCE_ON)
+    find_package(CURL REQUIRED)
+  else()
+    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/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()
+
 # Don't look for these libraries if we're using MSan, since uninstrumented third
 # party code may call MSan interceptors like strlen, leading to false positives.
 if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")


        


More information about the llvm-commits mailing list