diff --git a/lldb/cmake/modules/FindLibEdit.cmake b/cmake/Modules/FindLibEdit.cmake rename from lldb/cmake/modules/FindLibEdit.cmake rename to cmake/Modules/FindLibEdit.cmake --- a/lldb/cmake/modules/FindLibEdit.cmake +++ b/cmake/Modules/FindLibEdit.cmake @@ -62,3 +62,10 @@ mark_as_advanced(LibEdit_INCLUDE_DIRS LibEdit_LIBRARIES) endif() +if (LibEdit_FOUND AND NOT TARGET LibEdit::LibEdit) + add_library(LibEdit::LibEdit UNKNOWN IMPORTED) + set_target_properties(LibEdit::LibEdit PROPERTIES + IMPORTED_LOCATION ${LibEdit_LIBRARIES} + INTERFACE_INCLUDE_DIRECTORIES ${LibEdit_INCLUDE_DIRS} + INTERFACE_LINK_LIBRARIES ${LibEdit_LIBRARIES}) +endif() \ No newline at end of file diff --git a/lldb/cmake/modules/LLDBConfig.cmake b/lldb/cmake/modules/LLDBConfig.cmake --- a/lldb/cmake/modules/LLDBConfig.cmake +++ b/lldb/cmake/modules/LLDBConfig.cmake @@ -56,7 +56,9 @@ message(STATUS "${description}: ${${variable}}") endmacro() -add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support in LLDB" LibEdit LibEdit_FOUND) +if(LLVM_ENABLE_LIBEDIT) + find_package(LibEdit REQUIRED) +endif() add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support in LLDB" CursesAndPanel CURSESANDPANEL_FOUND) add_optional_dependency(LLDB_ENABLE_LZMA "Enable LZMA compression support in LLDB" LibLZMA LIBLZMA_FOUND) add_optional_dependency(LLDB_ENABLE_LUA "Enable Lua scripting support in LLDB" LuaAndSwig LUAANDSWIG_FOUND) diff --git a/lldb/source/Core/CMakeLists.txt b/lldb/source/Core/CMakeLists.txt --- a/lldb/source/Core/CMakeLists.txt +++ b/lldb/source/Core/CMakeLists.txt @@ -103,10 +103,6 @@ # TODO: Remove once we have better layering set_target_properties(lldbCore PROPERTIES LINK_INTERFACE_MULTIPLICITY 5) -if (LLDB_ENABLE_LIBEDIT) - target_include_directories(lldbCore PRIVATE ${LibEdit_INCLUDE_DIRS}) -endif() - if (LLDB_ENABLE_CURSES) target_include_directories(lldbCore PRIVATE ${CURSES_INCLUDE_DIRS}) endif() diff --git a/lldb/source/Host/CMakeLists.txt b/lldb/source/Host/CMakeLists.txt --- a/lldb/source/Host/CMakeLists.txt +++ b/lldb/source/Host/CMakeLists.txt @@ -141,7 +141,7 @@ list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS}) endif() if (LLDB_ENABLE_LIBEDIT) - list(APPEND EXTRA_LIBS ${LibEdit_LIBRARIES}) + list(APPEND EXTRA_LIBS LibEdit::LibEdit) endif() if (LLDB_ENABLE_LZMA) list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES}) @@ -151,7 +151,7 @@ endif() if (LLDB_ENABLE_LIBEDIT) - list(APPEND LLDB_LIBEDIT_LIBS ${LibEdit_LIBRARIES}) + list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) if (LLVM_BUILD_STATIC) list(APPEND LLDB_SYSTEM_LIBS gpm) endif() @@ -171,6 +171,3 @@ Support ) -if (LLDB_ENABLE_LIBEDIT) - target_include_directories(lldbHost PUBLIC ${LibEdit_INCLUDE_DIRS}) -endif() diff --git a/lldb/source/Interpreter/CMakeLists.txt b/lldb/source/Interpreter/CMakeLists.txt --- a/lldb/source/Interpreter/CMakeLists.txt +++ b/lldb/source/Interpreter/CMakeLists.txt @@ -68,6 +68,3 @@ LLDBInterpreterPropertiesGen LLDBInterpreterPropertiesEnumGen) -if (LLDB_ENABLE_LIBEDIT) - target_include_directories(lldbInterpreter PRIVATE ${LibEdit_INCLUDE_DIRS}) -endif() diff --git a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt --- a/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt +++ b/lldb/source/Plugins/ScriptInterpreter/Python/CMakeLists.txt @@ -10,7 +10,7 @@ if (LLDB_ENABLE_LIBEDIT) - list(APPEND LLDB_LIBEDIT_LIBS ${LibEdit_LIBRARIES}) + list(APPEND LLDB_LIBEDIT_LIBS LibEdit::LibEdit) endif() add_lldb_library(lldbPluginScriptInterpreterPython PLUGIN @@ -35,9 +35,3 @@ LINK_COMPONENTS Support ) - -if (LLDB_ENABLE_LIBEDIT) - target_include_directories(lldbPluginScriptInterpreterPython PUBLIC - ${LibEdit_INCLUDE_DIRS} - ) -endif() diff --git a/llvm/cmake/config-ix.cmake b/llvm/cmake/config-ix.cmake --- a/llvm/cmake/config-ix.cmake +++ b/llvm/cmake/config-ix.cmake @@ -64,7 +64,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) @@ -184,10 +183,13 @@ # 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) - else() - set(HAVE_LIBEDIT 0) + if (LLVM_ENABLE_LIBEDIT) + if (LLVM_USE_SANITIZER MATCHES ".*Address.*") + set(HAVE_LIBEDIT 0) + else() + find_package(LibEdit REQUIRED) + set(HAVE_LIBEDIT 1) + endif() endif() if(LLVM_ENABLE_TERMINFO) if(LLVM_ENABLE_TERMINFO STREQUAL FORCE_ON) diff --git a/llvm/lib/LineEditor/CMakeLists.txt b/llvm/lib/LineEditor/CMakeLists.txt --- a/llvm/lib/LineEditor/CMakeLists.txt +++ b/llvm/lib/LineEditor/CMakeLists.txt @@ -1,6 +1,4 @@ -if(HAVE_LIBEDIT) - set(link_libs edit) -endif() +# LibEdit is found in llvm/cmake/config-ix.cmake add_llvm_component_library(LLVMLineEditor LineEditor.cpp @@ -9,7 +7,7 @@ ${LLVM_MAIN_INCLUDE_DIR}/llvm/LineEditor LINK_LIBS - ${link_libs} + LibEdit::LibEdit LINK_COMPONENTS Support diff --git a/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn b/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn --- a/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn +++ b/llvm/utils/gn/secondary/lldb/source/Host/BUILD.gn @@ -142,7 +142,7 @@ # list(APPEND EXTRA_LIBS ${CMAKE_DL_LIBS}) # endif() # if (LLDB_ENABLE_LIBEDIT) - # list(APPEND EXTRA_LIBS ${LibEdit_LIBRARIES}) + # list(APPEND EXTRA_LIBS LibEdit::LibEdit) # endif() # if (LLDB_ENABLE_LZMA) # list(APPEND EXTRA_LIBS ${LIBLZMA_LIBRARIES}) diff --git a/utils/bazel/llvm_configs/config.h.cmake b/utils/bazel/llvm_configs/config.h.cmake --- a/utils/bazel/llvm_configs/config.h.cmake +++ b/utils/bazel/llvm_configs/config.h.cmake @@ -105,7 +105,7 @@ #cmakedefine HAVE_ISATTY 1 /* Define to 1 if you have the `edit' library (-ledit). */ -#cmakedefine HAVE_LIBEDIT ${HAVE_LIBEDIT} +#cmakedefine HAVE_LIBEDIT ${LibEdit_FOUND} /* Define to 1 if you have the `pfm' library (-lpfm). */ #cmakedefine HAVE_LIBPFM ${HAVE_LIBPFM}