Imported Upstream version 6.10.0.49

Former-commit-id: 1d6753294b2993e1fbf92de9366bb9544db4189b
This commit is contained in:
Xamarin Public Jenkins (auto-signing)
2020-01-16 16:38:04 +00:00
parent d94e79959b
commit 468663ddbb
48518 changed files with 2789335 additions and 61176 deletions

View File

@ -0,0 +1,167 @@
function(add_lldb_library name)
# only supported parameters to this macro are the optional
# MODULE;SHARED;STATIC library type and source files
cmake_parse_arguments(PARAM
"MODULE;SHARED;STATIC;OBJECT;PLUGIN"
""
"EXTRA_CXXFLAGS;DEPENDS;LINK_LIBS;LINK_COMPONENTS"
${ARGN})
llvm_process_sources(srcs ${PARAM_UNPARSED_ARGUMENTS})
list(APPEND LLVM_LINK_COMPONENTS ${PARAM_LINK_COMPONENTS})
if(PARAM_PLUGIN)
set_property(GLOBAL APPEND PROPERTY LLDB_PLUGINS ${name})
endif()
if (MSVC_IDE OR XCODE)
string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
list(GET split_path -1 dir)
file(GLOB_RECURSE headers
../../include/lldb${dir}/*.h)
set(srcs ${srcs} ${headers})
endif()
if (PARAM_MODULE)
set(libkind MODULE)
elseif (PARAM_SHARED)
set(libkind SHARED)
elseif (PARAM_OBJECT)
set(libkind OBJECT)
else ()
# PARAM_STATIC or library type unspecified. BUILD_SHARED_LIBS
# does not control the kind of libraries created for LLDB,
# only whether or not they link to shared/static LLVM/Clang
# libraries.
set(libkind STATIC)
endif()
#PIC not needed on Win
# FIXME: Setting CMAKE_CXX_FLAGS here is a no-op, use target_compile_options
# or omit this logic instead.
if (NOT WIN32)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
endif()
if (PARAM_OBJECT)
add_library(${name} ${libkind} ${srcs})
else()
llvm_add_library(${name} ${libkind} ${srcs} LINK_LIBS
${PARAM_LINK_LIBS}
DEPENDS ${PARAM_DEPENDS})
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "liblldb")
if (PARAM_SHARED)
set(out_dir lib${LLVM_LIBDIR_SUFFIX})
if(${name} STREQUAL "liblldb" AND LLDB_BUILD_FRAMEWORK)
set(out_dir ${LLDB_FRAMEWORK_INSTALL_DIR})
endif()
install(TARGETS ${name}
COMPONENT ${name}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${out_dir}
ARCHIVE DESTINATION ${out_dir})
else()
install(TARGETS ${name}
COMPONENT ${name}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
endif()
if (NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
endif()
endif()
endif()
# Hack: only some LLDB libraries depend on the clang autogenerated headers,
# but it is simple enough to make all of LLDB depend on some of those
# headers without negatively impacting much of anything.
add_dependencies(${name} clang-tablegen-targets)
# Add in any extra C++ compilation flags for this library.
target_compile_options(${name} PRIVATE ${PARAM_EXTRA_CXXFLAGS})
set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
endfunction(add_lldb_library)
function(add_lldb_executable name)
cmake_parse_arguments(ARG
"INCLUDE_IN_FRAMEWORK;GENERATE_INSTALL"
""
"LINK_LIBS;LINK_COMPONENTS"
${ARGN}
)
list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
add_llvm_executable(${name} ${ARG_UNPARSED_ARGUMENTS})
target_link_libraries(${name} PRIVATE ${ARG_LINK_LIBS})
set_target_properties(${name} PROPERTIES
FOLDER "lldb executables")
if(LLDB_BUILD_FRAMEWORK)
if(ARG_INCLUDE_IN_FRAMEWORK)
if(NOT IOS)
set(resource_dir "/Resources")
set(resource_dots "../")
endif()
string(REGEX REPLACE "[^/]+" ".." _dots ${LLDB_FRAMEWORK_INSTALL_DIR})
set_target_properties(${name} PROPERTIES
RUNTIME_OUTPUT_DIRECTORY $<TARGET_FILE_DIR:liblldb>${resource_dir}
BUILD_WITH_INSTALL_RPATH On
INSTALL_RPATH "@loader_path/../../../${resource_dots}${_dots}/${LLDB_FRAMEWORK_INSTALL_DIR}")
# For things inside the framework we don't need functional install targets
# because CMake copies the resources and headers from the build directory.
# But we still need this target to exist in order to use the
# LLVM_DISTRIBUTION_COMPONENTS build option. We also need the
# install-liblldb target to depend on this tool, so that it gets put into
# the Resources directory before the framework is installed.
if(ARG_GENERATE_INSTALL)
add_custom_target(install-${name} DEPENDS ${name})
add_dependencies(install-liblldb ${name})
add_custom_target(install-${name}-stripped DEPENDS ${name})
add_dependencies(install-liblldb-stripped ${name})
endif()
else()
set_target_properties(${name} PROPERTIES
BUILD_WITH_INSTALL_RPATH On
INSTALL_RPATH "@loader_path/../${LLDB_FRAMEWORK_INSTALL_DIR}")
endif()
endif()
if(ARG_GENERATE_INSTALL AND NOT (ARG_INCLUDE_IN_FRAMEWORK AND LLDB_BUILD_FRAMEWORK ))
install(TARGETS ${name}
COMPONENT ${name}
RUNTIME DESTINATION bin)
if (NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-${name}
DEPENDS ${name}
COMPONENT ${name})
endif()
endif()
if(ARG_INCLUDE_IN_FRAMEWORK AND LLDB_BUILD_FRAMEWORK)
add_llvm_tool_symlink(${name} ${name} ALWAYS_GENERATE SKIP_INSTALL
OUTPUT_DIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
endif()
endfunction(add_lldb_executable)
function(add_lldb_tool name)
add_lldb_executable(${name} GENERATE_INSTALL ${ARGN})
endfunction()
# Support appending linker flags to an existing target.
# This will preserve the existing linker flags on the
# target, if there are any.
function(lldb_append_link_flags target_name new_link_flags)
# Retrieve existing linker flags.
get_target_property(current_link_flags ${target_name} LINK_FLAGS)
# If we had any linker flags, include them first in the new linker flags.
if(current_link_flags)
set(new_link_flags "${current_link_flags} ${new_link_flags}")
endif()
# Now set them onto the target.
set_target_properties(${target_name} PROPERTIES LINK_FLAGS ${new_link_flags})
endfunction()

View File

@ -0,0 +1,11 @@
execute_process(COMMAND /usr/libexec/PlistBuddy -c "Print:CFBundleVersion" ${LLDB_INFO_PLIST}
OUTPUT_VARIABLE BundleVersion
OUTPUT_STRIP_TRAILING_WHITESPACE)
file(APPEND "${HEADER_FILE}.tmp"
"#define LLDB_VERSION_STRING lldb-${BundleVersion}\n")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${HEADER_FILE}.tmp" "${HEADER_FILE}")
file(REMOVE "${HEADER_FILE}.tmp")

View File

@ -0,0 +1,425 @@
include(CheckCXXSymbolExists)
set(LLDB_PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set(LLDB_SOURCE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/source")
set(LLDB_INCLUDE_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/include")
set(LLDB_LINKER_SUPPORTS_GROUPS OFF)
if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
# The Darwin linker doesn't understand --start-group/--end-group.
set(LLDB_LINKER_SUPPORTS_GROUPS ON)
endif()
set(LLDB_DEFAULT_DISABLE_PYTHON 0)
set(LLDB_DEFAULT_DISABLE_CURSES 0)
if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
set(LLDB_DEFAULT_DISABLE_CURSES 1)
elseif (CMAKE_SYSTEM_NAME MATCHES "Android" )
set(LLDB_DEFAULT_DISABLE_PYTHON 1)
set(LLDB_DEFAULT_DISABLE_CURSES 1)
elseif(IOS)
set(LLDB_DEFAULT_DISABLE_PYTHON 1)
endif()
set(LLDB_DISABLE_PYTHON ${LLDB_DEFAULT_DISABLE_PYTHON} CACHE BOOL
"Disables the Python scripting integration.")
set(LLDB_DISABLE_CURSES ${LLDB_DEFAULT_DISABLE_CURSES} CACHE BOOL
"Disables the Curses integration.")
set(LLDB_RELOCATABLE_PYTHON 0 CACHE BOOL
"Causes LLDB to use the PYTHONHOME environment variable to locate Python.")
set(LLDB_USE_SYSTEM_SIX 0 CACHE BOOL
"Use six.py shipped with system and do not install a copy of it")
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
set(LLDB_EXPORT_ALL_SYMBOLS 0 CACHE BOOL
"Causes lldb to export all symbols when building liblldb.")
else()
# Windows doesn't support toggling this, so don't bother making it a
# cache variable.
set(LLDB_EXPORT_ALL_SYMBOLS 0)
endif()
if ((NOT MSVC) OR MSVC12)
add_definitions( -DHAVE_ROUND )
endif()
if (LLDB_DISABLE_CURSES)
add_definitions( -DLLDB_DISABLE_CURSES )
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
# compiled with an identical version (and build configuration) of MSVC as LLDB.
# The standard algorithm does not take into account the differences between
# a binary release distribution of python and a custom built distribution.
# 2) From MSVC 2015 and onwards, it is only possible to use Python 3.5 or later.
# 3) FindPythonLibs queries the registry to locate Python, and when looking for a
# 64-bit version of Python, since cmake.exe is a 32-bit executable, it will see
# a 32-bit view of the registry. As such, it is impossible for FindPythonLibs to
# locate 64-bit Python libraries.
# This function is designed to address those limitations. Currently it only partially
# addresses them, but it can be improved and extended on an as-needed basis.
function(find_python_libs_windows)
if ("${PYTHON_HOME}" STREQUAL "")
message("LLDB embedded Python on Windows requires specifying a value for PYTHON_HOME. Python support disabled.")
set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
return()
endif()
file(TO_CMAKE_PATH "${PYTHON_HOME}/Include" PYTHON_INCLUDE_DIRS)
if(EXISTS "${PYTHON_INCLUDE_DIRS}/patchlevel.h")
file(STRINGS "${PYTHON_INCLUDE_DIRS}/patchlevel.h" python_version_str
REGEX "^#define[ \t]+PY_VERSION[ \t]+\"[^\"]+\"")
string(REGEX REPLACE "^#define[ \t]+PY_VERSION[ \t]+\"([^\"+]+)[+]?\".*" "\\1"
PYTHONLIBS_VERSION_STRING "${python_version_str}")
message("-- Found Python version ${PYTHONLIBS_VERSION_STRING}")
string(REGEX REPLACE "([0-9]+)[.]([0-9]+)[.][0-9]+" "python\\1\\2" PYTHONLIBS_BASE_NAME "${PYTHONLIBS_VERSION_STRING}")
unset(python_version_str)
else()
message("Unable to find ${PYTHON_INCLUDE_DIRS}/patchlevel.h, Python installation is corrupt.")
message("Python support will be disabled for this build.")
set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
return()
endif()
file(TO_CMAKE_PATH "${PYTHON_HOME}" PYTHON_HOME)
file(TO_CMAKE_PATH "${PYTHON_HOME}/python_d.exe" PYTHON_DEBUG_EXE)
file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}_d.lib" PYTHON_DEBUG_LIB)
file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}_d.dll" PYTHON_DEBUG_DLL)
file(TO_CMAKE_PATH "${PYTHON_HOME}/python.exe" PYTHON_RELEASE_EXE)
file(TO_CMAKE_PATH "${PYTHON_HOME}/libs/${PYTHONLIBS_BASE_NAME}.lib" PYTHON_RELEASE_LIB)
file(TO_CMAKE_PATH "${PYTHON_HOME}/${PYTHONLIBS_BASE_NAME}.dll" PYTHON_RELEASE_DLL)
if (NOT EXISTS ${PYTHON_DEBUG_EXE})
message("Unable to find ${PYTHON_DEBUG_EXE}")
unset(PYTHON_DEBUG_EXE)
endif()
if (NOT EXISTS ${PYTHON_RELEASE_EXE})
message("Unable to find ${PYTHON_RELEASE_EXE}")
unset(PYTHON_RELEASE_EXE)
endif()
if (NOT EXISTS ${PYTHON_DEBUG_LIB})
message("Unable to find ${PYTHON_DEBUG_LIB}")
unset(PYTHON_DEBUG_LIB)
endif()
if (NOT EXISTS ${PYTHON_RELEASE_LIB})
message("Unable to find ${PYTHON_RELEASE_LIB}")
unset(PYTHON_RELEASE_LIB)
endif()
if (NOT EXISTS ${PYTHON_DEBUG_DLL})
message("Unable to find ${PYTHON_DEBUG_DLL}")
unset(PYTHON_DEBUG_DLL)
endif()
if (NOT EXISTS ${PYTHON_RELEASE_DLL})
message("Unable to find ${PYTHON_RELEASE_DLL}")
unset(PYTHON_RELEASE_DLL)
endif()
if (NOT (PYTHON_DEBUG_EXE AND PYTHON_RELEASE_EXE AND PYTHON_DEBUG_LIB AND PYTHON_RELEASE_LIB AND PYTHON_DEBUG_DLL AND PYTHON_RELEASE_DLL))
message("Python installation is corrupt. Python support will be disabled for this build.")
set(LLDB_DISABLE_PYTHON 1 PARENT_SCOPE)
return()
endif()
# Generator expressions are evaluated in the context of each build configuration generated
# by CMake. Here we use the $<CONFIG:Debug>:VALUE logical generator expression to ensure
# that the debug Python library, DLL, and executable are used in the Debug build configuration.
#
# Generator expressions can be difficult to grok at first so here's a breakdown of the one
# used for PYTHON_LIBRARY:
#
# 1. $<CONFIG:Debug> evaluates to 1 when the Debug configuration is being generated,
# or 0 in all other cases.
# 2. $<$<CONFIG:Debug>:${PYTHON_DEBUG_LIB}> expands to ${PYTHON_DEBUG_LIB} when the Debug
# configuration is being generated, or nothing (literally) in all other cases.
# 3. $<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_LIB}> expands to ${PYTHON_RELEASE_LIB} when
# any configuration other than Debug is being generated, or nothing in all other cases.
# 4. The conditionals in 2 & 3 are mutually exclusive.
# 5. A logical expression with a conditional that evaluates to 0 yields no value at all.
#
# Due to 4 & 5 it's possible to concatenate 2 & 3 to obtain a single value specific to each
# build configuration. In this example the value will be ${PYTHON_DEBUG_LIB} when generating the
# Debug configuration, or ${PYTHON_RELEASE_LIB} when generating any other configuration.
# Note that it's imperative that there is no whitespace between the two expressions, otherwise
# CMake will insert a semicolon between the two.
set (PYTHON_EXECUTABLE $<$<CONFIG:Debug>:${PYTHON_DEBUG_EXE}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_EXE}>)
set (PYTHON_LIBRARY $<$<CONFIG:Debug>:${PYTHON_DEBUG_LIB}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_LIB}>)
set (PYTHON_DLL $<$<CONFIG:Debug>:${PYTHON_DEBUG_DLL}>$<$<NOT:$<CONFIG:Debug>>:${PYTHON_RELEASE_DLL}>)
set (PYTHON_EXECUTABLE ${PYTHON_EXECUTABLE} PARENT_SCOPE)
set (PYTHON_LIBRARY ${PYTHON_LIBRARY} PARENT_SCOPE)
set (PYTHON_DLL ${PYTHON_DLL} PARENT_SCOPE)
set (PYTHON_INCLUDE_DIRS ${PYTHON_INCLUDE_DIRS} PARENT_SCOPE)
message("-- LLDB Found PythonExecutable: ${PYTHON_RELEASE_EXE} and ${PYTHON_DEBUG_EXE}")
message("-- LLDB Found PythonLibs: ${PYTHON_RELEASE_LIB} and ${PYTHON_DEBUG_LIB}")
message("-- LLDB Found PythonDLL: ${PYTHON_RELEASE_DLL} and ${PYTHON_DEBUG_DLL}")
message("-- LLDB Found PythonIncludeDirs: ${PYTHON_INCLUDE_DIRS}")
endfunction(find_python_libs_windows)
if (NOT LLDB_DISABLE_PYTHON)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
find_python_libs_windows()
if (NOT LLDB_RELOCATABLE_PYTHON)
file(TO_CMAKE_PATH "${PYTHON_HOME}" LLDB_PYTHON_HOME)
add_definitions( -DLLDB_PYTHON_HOME="${LLDB_PYTHON_HOME}" )
endif()
else()
find_package(PythonLibs REQUIRED)
endif()
if (PYTHON_INCLUDE_DIRS)
include_directories(${PYTHON_INCLUDE_DIRS})
endif()
endif()
if (LLDB_DISABLE_PYTHON)
unset(PYTHON_INCLUDE_DIRS)
unset(PYTHON_LIBRARY)
add_definitions( -DLLDB_DISABLE_PYTHON )
endif()
if (LLVM_EXTERNAL_CLANG_SOURCE_DIR)
include_directories(${LLVM_EXTERNAL_CLANG_SOURCE_DIR}/include)
else ()
include_directories(${CMAKE_SOURCE_DIR}/tools/clang/include)
endif ()
include_directories("${CMAKE_CURRENT_BINARY_DIR}/../clang/include")
# Disable GCC warnings
check_cxx_compiler_flag("-Wno-deprecated-declarations"
CXX_SUPPORTS_NO_DEPRECATED_DECLARATIONS)
if (CXX_SUPPORTS_NO_DEPRECATED_DECLARATIONS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-declarations")
endif ()
check_cxx_compiler_flag("-Wno-unknown-pragmas"
CXX_SUPPORTS_NO_UNKNOWN_PRAGMAS)
if (CXX_SUPPORTS_NO_UNKNOWN_PRAGMAS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas")
endif ()
check_cxx_compiler_flag("-Wno-strict-aliasing"
CXX_SUPPORTS_NO_STRICT_ALIASING)
if (CXX_SUPPORTS_NO_STRICT_ALIASING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-strict-aliasing")
endif ()
# Disable Clang warnings
check_cxx_compiler_flag("-Wno-deprecated-register"
CXX_SUPPORTS_NO_DEPRECATED_REGISTER)
if (CXX_SUPPORTS_NO_DEPRECATED_REGISTER)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register")
endif ()
check_cxx_compiler_flag("-Wno-vla-extension"
CXX_SUPPORTS_NO_VLA_EXTENSION)
if (CXX_SUPPORTS_NO_VLA_EXTENSION)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-vla-extension")
endif ()
check_cxx_compiler_flag("-Wno-gnu-anonymous-struct"
CXX_SUPPORTS_NO_GNU_ANONYMOUS_STRUCT)
check_cxx_compiler_flag("-Wno-nested-anon-types"
CXX_SUPPORTS_NO_NESTED_ANON_TYPES)
# Disable MSVC warnings
if( MSVC )
add_definitions(
-wd4018 # Suppress 'warning C4018: '>=' : signed/unsigned mismatch'
-wd4068 # Suppress 'warning C4068: unknown pragma'
-wd4150 # Suppress 'warning C4150: deletion of pointer to incomplete type'
-wd4251 # Suppress 'warning C4251: T must have dll-interface to be used by clients of class U.'
-wd4521 # Suppress 'warning C4521: 'type' : multiple copy constructors specified'
-wd4530 # Suppress 'warning C4530: C++ exception handler used, but unwind semantics are not enabled.'
)
endif()
# Use the Unicode (UTF-16) APIs by default on Win32
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
add_definitions( -D_UNICODE -DUNICODE )
endif()
set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
"the makefiles distributed with LLDB. Please create a directory and run cmake "
"from there, passing the path to this source directory as the last argument. "
"This process created the file `CMakeCache.txt' and the directory "
"`CMakeFiles'. Please delete them.")
endif()
# Compute the LLDB version from the LLVM version.
string(REGEX MATCH "[0-9]+\\.[0-9]+(\\.[0-9]+)?" LLDB_VERSION
${PACKAGE_VERSION})
message(STATUS "LLDB version: ${LLDB_VERSION}")
include_directories(BEFORE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_BINARY_DIR}/include
)
if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
install(DIRECTORY include/
COMPONENT lldb-headers
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
PATTERN ".cmake" EXCLUDE
PATTERN "Config.h" EXCLUDE
)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/
COMPONENT lldb-headers
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
PATTERN ".cmake" EXCLUDE
)
add_custom_target(lldb-headers)
set_target_properties(lldb-headers PROPERTIES FOLDER "Misc")
if (NOT CMAKE_CONFIGURATION_TYPES)
add_llvm_install_targets(install-lldb-headers
COMPONENT lldb-headers)
endif()
endif()
if (NOT LIBXML2_FOUND AND NOT (CMAKE_SYSTEM_NAME MATCHES "Windows"))
# Skip Libxml2 on Windows. In CMake 3.4 and higher, the algorithm for
# finding libxml2 got "smarter", and it can now locate the version which is
# in gnuwin32, even though that version does not contain the headers that
# LLDB uses.
find_package(LibXml2)
endif()
# Find libraries or frameworks that may be needed
if (APPLE)
if(NOT IOS)
find_library(CARBON_LIBRARY Carbon)
find_library(CORE_SERVICES_LIBRARY CoreServices)
find_library(DEBUG_SYMBOLS_LIBRARY DebugSymbols PATHS "/System/Library/PrivateFrameworks")
endif()
find_library(FOUNDATION_LIBRARY Foundation)
find_library(CORE_FOUNDATION_LIBRARY CoreFoundation)
find_library(SECURITY_LIBRARY Security)
set(LLDB_FRAMEWORK_INSTALL_DIR Library/Frameworks CACHE STRING "Output directory for LLDB.framework")
set(LLDB_FRAMEWORK_VERSION A CACHE STRING "LLDB.framework version (default is A)")
set(LLDB_FRAMEWORK_RESOURCE_DIR
LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Resources)
add_definitions( -DLIBXML2_DEFINED )
list(APPEND system_libs xml2
${CURSES_LIBRARIES}
${FOUNDATION_LIBRARY}
${CORE_FOUNDATION_LIBRARY}
${CORE_SERVICES_LIBRARY}
${SECURITY_LIBRARY}
${DEBUG_SYMBOLS_LIBRARY})
else()
if (LIBXML2_FOUND)
add_definitions( -DLIBXML2_DEFINED )
list(APPEND system_libs ${LIBXML2_LIBRARIES})
include_directories(${LIBXML2_INCLUDE_DIR})
endif()
endif()
if (HAVE_LIBPTHREAD)
list(APPEND system_libs pthread)
endif(HAVE_LIBPTHREAD)
if (HAVE_LIBDL)
list(APPEND system_libs ${CMAKE_DL_LIBS})
endif()
# Figure out if lldb could use lldb-server. If so, then we'll
# ensure we build lldb-server when an lldb target is being built.
if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD")
set(LLDB_CAN_USE_LLDB_SERVER 1)
else()
set(LLDB_CAN_USE_LLDB_SERVER 0)
endif()
# Figure out if lldb could use debugserver. If so, then we'll
# ensure we build debugserver when we build lldb.
if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set(LLDB_CAN_USE_DEBUGSERVER 1)
else()
set(LLDB_CAN_USE_DEBUGSERVER 0)
endif()
if (NOT LLDB_DISABLE_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.")
endif ()
# Add panels to the library path
set (CURSES_LIBRARIES ${CURSES_LIBRARIES} ${CURSES_PANEL_LIBRARY})
list(APPEND system_libs ${CURSES_LIBRARIES})
include_directories(${CURSES_INCLUDE_DIR})
endif ()
check_cxx_symbol_exists("__GLIBCXX__" "string" LLDB_USING_LIBSTDCXX)
if(LLDB_USING_LIBSTDCXX)
# There doesn't seem to be an easy way to check the library version. Instead, we rely on the
# fact that std::set did not have the allocator constructor available until version 4.9
check_cxx_source_compiles("
#include <set>
std::set<int> s = std::set<int>(std::allocator<int>());
int main() { return 0; }"
LLDB_USING_LIBSTDCXX_4_9)
if (NOT LLDB_USING_LIBSTDCXX_4_9 AND NOT LLVM_ENABLE_EH)
message(WARNING
"You appear to be linking to libstdc++ version lesser than 4.9 without exceptions "
"enabled. These versions of the library have an issue, which causes occasional "
"lldb crashes. See <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59656> for "
"details. Possible courses of action are:\n"
"- use libstdc++ version 4.9 or newer\n"
"- use libc++ (via LLVM_ENABLE_LIBCXX)\n"
"- enable exceptions (via LLVM_ENABLE_EH)\n"
"- ignore this warning and accept occasional instability")
endif()
endif()
if(MSVC)
set(LLDB_USE_BUILTIN_DEMANGLER ON)
else()
option(LLDB_USE_BUILTIN_DEMANGLER "Use lldb's builtin demangler instead of the system one" ON)
endif()
if(LLDB_USE_BUILTIN_DEMANGLER)
add_definitions(-DLLDB_USE_BUILTIN_DEMANGLER)
endif()
if ((CMAKE_SYSTEM_NAME MATCHES "Android") AND LLVM_BUILD_STATIC AND
((ANDROID_ABI MATCHES "armeabi") OR (ANDROID_ABI MATCHES "mips")))
add_definitions(-DANDROID_USE_ACCEPT_WORKAROUND)
endif()
find_package(Backtrace)
include(LLDBGenerateConfig)

View File

@ -0,0 +1,48 @@
# This file contains all the logic for running configure-time checks
include(CheckSymbolExists)
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckLibraryExists)
set(CMAKE_REQUIRED_DEFINITIONS -D_GNU_SOURCE)
check_symbol_exists(ppoll poll.h HAVE_PPOLL)
set(CMAKE_REQUIRED_DEFINITIONS)
check_symbol_exists(sigaction signal.h HAVE_SIGACTION)
check_cxx_symbol_exists(accept4 "sys/socket.h" HAVE_ACCEPT4)
check_include_file(termios.h HAVE_TERMIOS_H)
check_include_files("sys/types.h;sys/event.h" HAVE_SYS_EVENT_H)
check_cxx_source_compiles("
#include <sys/uio.h>
int main() { process_vm_readv(0, nullptr, 0, nullptr, 0, 0); return 0; }"
HAVE_PROCESS_VM_READV)
check_cxx_source_compiles("
#include <sys/syscall.h>
int main() { return __NR_process_vm_readv; }"
HAVE_NR_PROCESS_VM_READV)
check_library_exists(compression compression_encode_buffer "" HAVE_LIBCOMPRESSION)
# These checks exist in LLVM's configuration, so I want to match the LLVM names
# so that the check isn't duplicated, but we translate them into the LLDB names
# so that I don't have to change all the uses at the moment.
set(LLDB_CONFIG_TERMIOS_SUPPORTED ${HAVE_TERMIOS_H})
if(NOT UNIX)
set(LLDB_DISABLE_POSIX 1)
endif()
if(NOT LLDB_CONFIG_HEADER_INPUT)
set(LLDB_CONFIG_HEADER_INPUT ${LLDB_INCLUDE_ROOT}/lldb/Host/Config.h.cmake)
endif()
if(NOT LLDB_CONFIG_HEADER_OUTPUT)
set(LLDB_CONFIG_HEADER_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/include/lldb/Host/Config.h)
endif()
# This should be done at the end
configure_file(
${LLDB_CONFIG_HEADER_INPUT}
${LLDB_CONFIG_HEADER_OUTPUT}
)

View File

@ -0,0 +1,131 @@
# If we are not building as a part of LLVM, build LLDB as an
# standalone project, using LLVM as an external library:
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(lldb)
option(LLVM_INSTALL_TOOLCHAIN_ONLY "Only include toolchain files in the 'install' target." OFF)
# Rely on llvm-config.
set(CONFIG_OUTPUT)
find_program(LLVM_CONFIG "llvm-config")
if(LLVM_CONFIG)
message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
set(CONFIG_COMMAND ${LLVM_CONFIG}
"--assertion-mode"
"--bindir"
"--libdir"
"--includedir"
"--prefix"
"--src-root"
"--cmakedir")
execute_process(
COMMAND ${CONFIG_COMMAND}
RESULT_VARIABLE HAD_ERROR
OUTPUT_VARIABLE CONFIG_OUTPUT
)
if(NOT HAD_ERROR)
string(REGEX REPLACE
"[ \t]*[\r\n]+[ \t]*" ";"
CONFIG_OUTPUT ${CONFIG_OUTPUT})
else()
string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
message(STATUS "${CONFIG_COMMAND_STR}")
message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
endif()
else()
message(FATAL_ERROR "llvm-config not found -- ${LLVM_CONFIG}")
endif()
list(GET CONFIG_OUTPUT 0 ENABLE_ASSERTIONS)
list(GET CONFIG_OUTPUT 1 TOOLS_BINARY_DIR)
list(GET CONFIG_OUTPUT 2 LIBRARY_DIR)
list(GET CONFIG_OUTPUT 3 INCLUDE_DIR)
list(GET CONFIG_OUTPUT 4 LLVM_OBJ_ROOT)
list(GET CONFIG_OUTPUT 5 MAIN_SRC_DIR)
list(GET CONFIG_OUTPUT 6 LLVM_CMAKE_PATH)
if(NOT MSVC_IDE)
set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
CACHE BOOL "Enable assertions")
# Assertions should follow llvm-config's.
mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
endif()
set(LLVM_TOOLS_BINARY_DIR ${TOOLS_BINARY_DIR} CACHE PATH "Path to llvm/bin")
set(LLVM_LIBRARY_DIR ${LIBRARY_DIR} CACHE PATH "Path to llvm/lib")
set(LLVM_MAIN_INCLUDE_DIR ${INCLUDE_DIR} CACHE PATH "Path to llvm/include")
set(LLVM_DIR ${LLVM_OBJ_ROOT}/cmake/modules/CMakeFiles CACHE PATH "Path to LLVM build tree CMake files")
set(LLVM_BINARY_DIR ${LLVM_OBJ_ROOT} CACHE PATH "Path to LLVM build tree")
set(LLVM_MAIN_SRC_DIR ${MAIN_SRC_DIR} CACHE PATH "Path to LLVM source tree")
find_program(LLVM_TABLEGEN_EXE "llvm-tblgen" ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH)
set(LLVMCONFIG_FILE "${LLVM_CMAKE_PATH}/LLVMConfig.cmake")
if(EXISTS ${LLVMCONFIG_FILE})
file(TO_CMAKE_PATH "${LLVM_CMAKE_PATH}" LLVM_CMAKE_PATH)
list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_PATH}")
include(${LLVMCONFIG_FILE})
else()
message(FATAL_ERROR "Not found: ${LLVMCONFIG_FILE}")
endif()
# They are used as destination of target generators.
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX})
if(WIN32 OR CYGWIN)
# DLL platform -- put DLLs into bin.
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_RUNTIME_OUTPUT_INTDIR})
else()
set(LLVM_SHLIB_OUTPUT_INTDIR ${LLVM_LIBRARY_OUTPUT_INTDIR})
endif()
include(AddLLVM)
include(HandleLLVMOptions)
include(CheckAtomic)
if (PYTHON_EXECUTABLE STREQUAL "")
set(Python_ADDITIONAL_VERSIONS 3.5 3.4 3.3 3.2 3.1 3.0 2.7 2.6 2.5)
include(FindPythonInterp)
if( NOT PYTHONINTERP_FOUND )
message(FATAL_ERROR
"Unable to find Python interpreter, required for builds and testing.
Please install Python or specify the PYTHON_EXECUTABLE CMake variable.")
endif()
else()
message("-- Found PythonInterp: ${PYTHON_EXECUTABLE}")
endif()
# Import CMake library targets from LLVM and Clang.
include("${LLVM_OBJ_ROOT}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm/LLVMConfig.cmake")
# cmake/clang/ClangConfig.cmake is not created when LLVM and Cland are built together.
if (EXISTS "${LLVM_OBJ_ROOT}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/ClangConfig.cmake")
include("${LLVM_OBJ_ROOT}/lib${LLVM_LIBDIR_SUFFIX}/cmake/clang/ClangConfig.cmake")
endif()
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
set(LLVM_BINARY_DIR ${CMAKE_BINARY_DIR})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories("${LLVM_BINARY_DIR}/include" "${LLVM_MAIN_INCLUDE_DIR}")
# Next three include directories are needed when llvm-config is located in build directory.
# LLVM and Cland are assumed to be built together
if (EXISTS "${LLVM_OBJ_ROOT}/include")
include_directories("${LLVM_OBJ_ROOT}/include")
endif()
if (EXISTS "${LLVM_MAIN_SRC_DIR}/tools/clang/include")
include_directories("${LLVM_MAIN_SRC_DIR}/tools/clang/include")
endif()
if (EXISTS "${LLVM_OBJ_ROOT}/tools/clang/include")
include_directories("${LLVM_OBJ_ROOT}/tools/clang/include")
endif()
link_directories("${LLVM_LIBRARY_DIR}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX})
set(LLDB_BUILT_STANDALONE 1)
endif()