[llvm] 484b1aa - [llvm] [Debuginfod] Add cpp-httplib optional dependency.

Noah Shutty via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 6 11:41:00 PDT 2022


Author: Noah Shutty
Date: 2022-07-06T18:40:56Z
New Revision: 484b1aa611caa70c8a80b46060cc340bbeee8306

URL: https://github.com/llvm/llvm-project/commit/484b1aa611caa70c8a80b46060cc340bbeee8306
DIFF: https://github.com/llvm/llvm-project/commit/484b1aa611caa70c8a80b46060cc340bbeee8306.diff

LOG: [llvm] [Debuginfod] Add cpp-httplib optional dependency.

Adds optional dependency on cpp-httplib, a lightweight header-only HTTP server.

Reviewed By: phosek

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

Added: 
    

Modified: 
    llvm/CMakeLists.txt
    llvm/cmake/config-ix.cmake
    llvm/include/llvm/Config/llvm-config.h.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 645ab26dce46c..53c4158866edc 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -200,7 +200,7 @@ if(LLVM_CCACHE_BUILD)
       # RULE_LAUNCH_COMPILE should work with Ninja but currently has issues
       # with cmd.exe and some MSVC tools other than cl.exe
       set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
-      set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})     
+      set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
     endif()
   else()
     message(FATAL_ERROR "Unable to find the program ccache. Set LLVM_CCACHE_BUILD to OFF")
@@ -440,6 +440,8 @@ set(LLVM_ENABLE_ZLIB "ON" CACHE STRING "Use zlib for compression/decompression i
 
 set(LLVM_ENABLE_CURL "OFF" CACHE STRING "Use libcurl for the HTTP client if available. Can be ON, OFF, or FORCE_ON")
 
+set(LLVM_ENABLE_HTTPLIB "OFF" CACHE STRING "Use cpp-httplib HTTP server library if available. Can be ON, OFF, or FORCE_ON")
+
 set(LLVM_Z3_INSTALL_DIR "" CACHE STRING "Install directory of the Z3 solver.")
 
 option(LLVM_ENABLE_Z3_SOLVER

diff  --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake
index 9a375a62059ab..d75d2f8421a9e 100644
--- a/llvm/cmake/config-ix.cmake
+++ b/llvm/cmake/config-ix.cmake
@@ -6,6 +6,7 @@ endif()
 include(CheckIncludeFile)
 include(CheckLibraryExists)
 include(CheckSymbolExists)
+include(CheckCXXSymbolExists)
 include(CheckFunctionExists)
 include(CheckStructHasMember)
 include(CheckCCompilerFlag)
@@ -177,6 +178,26 @@ if(LLVM_ENABLE_CURL)
   set(LLVM_ENABLE_CURL "${HAVE_CURL}")
 endif()
 
+if(LLVM_ENABLE_HTTPLIB)
+  if(LLVM_ENABLE_HTTPLIB STREQUAL FORCE_ON)
+    find_package(httplib REQUIRED)
+  else()
+    find_package(httplib)
+  endif()
+  if(HTTPLIB_FOUND)
+    # Check if the "httplib" we found is usable; for example there may be another
+    # library with the same name.
+    cmake_push_check_state()
+    list(APPEND CMAKE_REQUIRED_LIBRARIES ${HTTPLIB_LIBRARY})
+    check_cxx_symbol_exists(CPPHTTPLIB_HTTPLIB_H ${HTTPLIB_HEADER_PATH} HAVE_HTTPLIB)
+    cmake_pop_check_state()
+    if(LLVM_ENABLE_HTTPLIB STREQUAL FORCE_ON AND NOT HAVE_HTTPLIB)
+      message(FATAL_ERROR "Failed to configure cpp-httplib")
+    endif()
+  endif()
+  set(LLVM_ENABLE_HTTPLIB "${HAVE_HTTPLIB}")
+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.*")

diff  --git a/llvm/include/llvm/Config/llvm-config.h.cmake b/llvm/include/llvm/Config/llvm-config.h.cmake
index 875a47030d345..3355f12337203 100644
--- a/llvm/include/llvm/Config/llvm-config.h.cmake
+++ b/llvm/include/llvm/Config/llvm-config.h.cmake
@@ -89,6 +89,9 @@
 /* Define if we have curl and want to use it */
 #cmakedefine LLVM_ENABLE_CURL ${LLVM_ENABLE_CURL}
 
+/* Define if we have cpp-httplib and want to use it */
+#cmakedefine LLVM_ENABLE_HTTPLIB ${LLVM_ENABLE_HTTPLIB}
+
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 


        


More information about the llvm-commits mailing list