Index: lldb/cmake/modules/LLDBConfig.cmake =================================================================== --- lldb/cmake/modules/LLDBConfig.cmake +++ lldb/cmake/modules/LLDBConfig.cmake @@ -24,40 +24,48 @@ set(LLDB_LINKER_SUPPORTS_GROUPS ON) endif() +function(add_optional_dependency variable description package found) + set(${variable} "AUTO" CACHE STRING "${description} On, Off or Auto (default)") + string(TOUPPER "${${variable}}" ${variable}) + + if ("${${variable}}" STREQUAL "AUTO") + set(maybe_required) + elseif("${${variable}}" STREQUAL "ON") + set(maybe_required REQUIRED) + else() + set(${variable} OFF PARENT_SCOPE) + return() + endif() + + find_package(${package} ${maybe_required}) + # We could set ${variable} directory to ${${found}} but then the value is + # TRUE/FALSE rather than ON/OFF. + if (${${found}}) + set(${variable} ON PARENT_SCOPE) + else() + set(${variable} OFF PARENT_SCOPE) + endif() +endfunction() + +add_optional_dependency(LLDB_ENABLE_LIBEDIT "Enable editline support." LibEdit libedit_FOUND) +add_optional_dependency(LLDB_ENABLE_CURSES "Enable curses support." Curses CURSES_FOUND) + set(default_enable_python ON) -set(default_enable_libedit ON) -set(default_enable_curses ON) # Temporary support the old LLDB_DISABLE_* variables -if (DEFINED LLDB_DISABLE_CURSES) - if (LLDB_DISABLE_CURSES) - set(default_enable_curses OFF) - endif() -endif() if (DEFINED LLDB_DISABLE_PYTHON) if (LLDB_DISABLE_PYTHON) set(default_enable_python OFF) endif() endif() -if(DEFINED LLVM_ENABLE_LIBEDIT AND NOT LLVM_ENABLE_LIBEDIT) - set(default_disable_libedit ON) -endif() - -if(CMAKE_SYSTEM_NAME MATCHES "Windows") - set(default_enable_libedit OFF) - set(default_enable_curses OFF) -elseif(CMAKE_SYSTEM_NAME MATCHES "Android") +if(CMAKE_SYSTEM_NAME MATCHES "Android") set(default_enable_python OFF) - set(default_enable_libedit OFF) - set(default_enable_curses OFF) elseif(IOS) set(default_enable_python OFF) endif() option(LLDB_ENABLE_PYTHON "Enable Python scripting integration." ${default_enable_python}) -option(LLDB_ENABLE_LIBEDIT "Enable the use of editline." ${default_enable_libedit}) -option(LLDB_ENABLE_CURSES "Enable Curses integration." ${default_enable_curses}) option(LLDB_RELOCATABLE_PYTHON "Use the PYTHONHOME environment variable to locate Python." OFF) option(LLDB_USE_SYSTEM_SIX "Use six.py shipped with system and do not install a copy of it" OFF) option(LLDB_USE_ENTITLEMENTS "When codesigning, use entitlements if available" ON) @@ -120,12 +128,9 @@ add_definitions( -DHAVE_ROUND ) endif() - +# Check if we libedit capable of handling wide characters (built with +# '--enable-widec'). if (LLDB_ENABLE_LIBEDIT) - find_package(LibEdit REQUIRED) - - # Check if we libedit capable of handling wide characters (built with - # '--enable-widec'). set(CMAKE_REQUIRED_LIBRARIES ${libedit_LIBRARIES}) set(CMAKE_REQUIRED_INCLUDES ${libedit_INCLUDE_DIRS}) check_symbol_exists(el_winsertstr histedit.h LLDB_EDITLINE_USE_WCHAR) @@ -141,7 +146,6 @@ set(CMAKE_EXTRA_INCLUDE_FILES) endif() - # On Windows, we can't use the normal FindPythonLibs module that comes with CMake, # for a number of reasons. # 1) Prior to MSVC 2015, it is only possible to embed Python if python itself was @@ -498,10 +502,10 @@ endif() if (LLDB_ENABLE_CURSES) - find_package(Curses REQUIRED) find_library(CURSES_PANEL_LIBRARY NAMES panel DOC "The curses panel library") if (NOT CURSES_PANEL_LIBRARY) - message(FATAL_ERROR "A required curses' panel library not found.") + set(LLDB_ENABLE_CURSES OFF) + message(WARNING "Curses panel library not found.") endif () endif ()