[Lldb-commits] [lldb] r333041 - build: use cmake to find the libedit content
Saleem Abdulrasool via lldb-commits
lldb-commits at lists.llvm.org
Tue May 22 16:24:46 PDT 2018
Author: compnerd
Date: Tue May 22 16:24:46 2018
New Revision: 333041
URL: http://llvm.org/viewvc/llvm-project?rev=333041&view=rev
Log:
build: use cmake to find the libedit content
Use proper cmake techniques to detect where the libedit package resides.
This allows for the use of libedit from an alternative location which is
needed for supporting cross-compilation.
Added:
lldb/trunk/cmake/modules/FindLibEdit.cmake
Modified:
lldb/trunk/CMakeLists.txt
lldb/trunk/scripts/Python/modules/readline/CMakeLists.txt
Modified: lldb/trunk/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/CMakeLists.txt?rev=333041&r1=333040&r2=333041&view=diff
==============================================================================
--- lldb/trunk/CMakeLists.txt (original)
+++ lldb/trunk/CMakeLists.txt Tue May 22 16:24:46 2018
@@ -29,6 +29,8 @@ endif ()
set(LLDB_DISABLE_LIBEDIT ${LLDB_DEFAULT_DISABLE_LIBEDIT} CACHE BOOL "Disables the use of editline.")
if (LLDB_DISABLE_LIBEDIT)
add_definitions( -DLLDB_DISABLE_LIBEDIT )
+else()
+ find_package(LibEdit REQUIRED)
endif()
if(APPLE)
Added: lldb/trunk/cmake/modules/FindLibEdit.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/modules/FindLibEdit.cmake?rev=333041&view=auto
==============================================================================
--- lldb/trunk/cmake/modules/FindLibEdit.cmake (added)
+++ lldb/trunk/cmake/modules/FindLibEdit.cmake Tue May 22 16:24:46 2018
@@ -0,0 +1,62 @@
+#.rst:
+# FindLibEdit
+# -----------
+#
+# Find libedit library and headers
+#
+# The module defines the following variables:
+#
+# ::
+#
+# libedit_FOUND - true if libedit was found
+# libedit_INCLUDE_DIRS - include search path
+# libedit_LIBRARIES - libraries to link
+# libedit_VERSION - version number
+
+if(libedit_INCLUDE_DIRS AND libedit_LIBRARIES)
+ set(libedit_FOUND TRUE)
+else()
+ find_package(PkgConfig QUIET)
+ pkg_check_modules(PC_LIBEDIT QUIET libedit)
+
+ find_path(libedit_INCLUDE_DIRS
+ NAMES
+ histedit.h
+ HINTS
+ ${PC_LIBEDIT_INCLUDEDIR}
+ ${PC_LIBEDIT_INCLUDE_DIRS}
+ ${CMAKE_INSTALL_FULL_INCLUDEDIR})
+ find_library(libedit_LIBRARIES
+ NAMES
+ edit libedit
+ HINTS
+ ${PC_LIBEDIT_LIBDIR}
+ ${PC_LIBEDIT_LIBRARY_DIRS}
+ ${CMAKE_INSTALL_FULL_LIBDIR})
+
+ if(libedit_INCLUDE_DIRS AND EXISTS "${libedit_INCLUDE_DIRS}/histedit.h")
+ file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h"
+ libedit_major_version_str
+ REGEX "^#define[ \t]+LIBEDIT_MAJOR[ \t]+[0-9]+")
+ string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MAJOR[ \t]+([0-9]+)" "\\1"
+ LIBEDIT_MAJOR_VERSION "${libedit_major_version_str}")
+
+ file(STRINGS "${libedit_INCLUDE_DIRS}/histedit.h"
+ libedit_minor_version_str
+ REGEX "^#define[ \t]+LIBEDIT_MINOR[ \t]+[0-9]+")
+ string(REGEX REPLACE "^#define[ \t]+LIBEDIT_MINOR[ \t]+([0-9]+)" "\\1"
+ LIBEDIT_MINOR_VERSION "${libedit_minor_version_str}")
+
+ set(libedit_VERSION_STRING "${libedit_major_version}.${libedit_minor_version}")
+ endif()
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(libedit
+ REQUIRED_VARS
+ libedit_INCLUDE_DIRS
+ libedit_LIBRARIES
+ VERSION_VAR
+ libedit_VERSION_STRING)
+ mark_as_advanced(libedit_INCLUDE_DIRS libedit_LIBRARIES)
+endif()
+
Modified: lldb/trunk/scripts/Python/modules/readline/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/modules/readline/CMakeLists.txt?rev=333041&r1=333040&r2=333041&view=diff
==============================================================================
--- lldb/trunk/scripts/Python/modules/readline/CMakeLists.txt (original)
+++ lldb/trunk/scripts/Python/modules/readline/CMakeLists.txt Tue May 22 16:24:46 2018
@@ -6,9 +6,12 @@ SET(PYTHON_DIRECTORY python${PYTHON_VERS
# Build the readline python module
include_directories(${PYTHON_INCLUDE_DIR})
add_library(readline SHARED readline.cpp)
+target_include_directories(readline
+ PRIVATE
+ ${libedit_INCLUDE_DIRS})
if (NOT LLDB_DISABLE_LIBEDIT)
- target_link_libraries(readline ${PYTHON_LIBRARY} edit)
+ target_link_libraries(readline ${PYTHON_LIBRARY} ${libedit_LIBRARIES})
else()
target_link_libraries(readline ${PYTHON_LIBRARY})
endif()
More information about the lldb-commits
mailing list