[PATCH] D120418: [LLVM] Support histedit.h and libedit.a in non-standard locations

Riyaz V Puthiyapurayil via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 23 09:14:33 PST 2022


RVP updated this revision to Diff 410849.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120418/new/

https://reviews.llvm.org/D120418

Files:
  llvm/cmake/config-ix.cmake
  llvm/lib/LineEditor/CMakeLists.txt


Index: llvm/lib/LineEditor/CMakeLists.txt
===================================================================
--- llvm/lib/LineEditor/CMakeLists.txt
+++ llvm/lib/LineEditor/CMakeLists.txt
@@ -1,5 +1,8 @@
 if(HAVE_LIBEDIT)
-  set(link_libs edit)
+  set(link_libs ${LIBEDIT_LIBRARY})
+endif()
+if(HAVE_HISTEDIT_H)
+  include_directories(${HISTEDIT_DIR})
 endif()
 
 add_llvm_component_library(LLVMLineEditor
Index: llvm/cmake/config-ix.cmake
===================================================================
--- llvm/cmake/config-ix.cmake
+++ llvm/cmake/config-ix.cmake
@@ -63,7 +63,6 @@
 check_symbol_exists(FE_INEXACT "fenv.h" HAVE_DECL_FE_INEXACT)
 
 check_include_file(mach/mach.h HAVE_MACH_MACH_H)
-check_include_file(histedit.h HAVE_HISTEDIT_H)
 check_include_file(CrashReporterClient.h HAVE_CRASHREPORTERCLIENT_H)
 if(APPLE)
   include(CheckCSourceCompiles)
@@ -186,9 +185,18 @@
   # Don't look for these libraries on Windows.
   if (NOT PURE_WINDOWS)
     # Skip libedit if using ASan as it contains memory leaks.
-    if (LLVM_ENABLE_LIBEDIT AND HAVE_HISTEDIT_H AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
-      check_library_exists(edit el_init "" HAVE_LIBEDIT)
+    if (LLVM_ENABLE_LIBEDIT AND NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
+      # If histedit.h is in a non-standard path, find it in CMAKE_INCLUDE_PATH
+      find_file(HISTEDIT_FILE histedit.h)
+      get_filename_component(HISTEDIT_DIR "${HISTEDIT_FILE}" DIRECTORY CACHE)
+      check_include_file(histedit.h HAVE_HISTEDIT_H "-I${HISTEDIT_DIR}")
+
+      # If libedit.a is in a non-standard path, find it in CMAKE_LIBRARY_PATH
+      find_library(LIBEDIT_LIBRARY libedit.a)
+      get_filename_component(LIBEDIT_DIR "${LIBEDIT_LIBRARY}" DIRECTORY CACHE)
+      check_library_exists(edit el_init "${LIBEDIT_DIR}" HAVE_LIBEDIT)
     else()
+      set(HAVE_HISTEDIT_H 0)
       set(HAVE_LIBEDIT 0)
     endif()
     if(LLVM_ENABLE_TERMINFO)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120418.410849.patch
Type: text/x-patch
Size: 1926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220223/ef163093/attachment.bin>


More information about the llvm-commits mailing list