1 cmake_minimum_required(VERSION 3.4.3)
3 include(cmake/modules/LLDBStandalone.cmake)
4 include(cmake/modules/LLDBConfig.cmake)
5 include(cmake/modules/AddLLDB.cmake)
7 if (__ANDROID_NDK__ OR (CMAKE_SYSTEM_NAME MATCHES "Windows"))
8 set(LLDB_DEFAULT_DISABLE_LIBEDIT 1)
10 set(LLDB_DEFAULT_DISABLE_LIBEDIT 0)
13 # We need libedit support to go down both the source and
14 # the scripts directories.
15 set(LLDB_DISABLE_LIBEDIT ${LLDB_DEFAULT_DISABLE_LIBEDIT} CACHE BOOL "Disables the use of editline.")
16 if (LLDB_DISABLE_LIBEDIT)
17 add_definitions( -DLLDB_DISABLE_LIBEDIT )
20 # add_subdirectory(include)
21 add_subdirectory(docs)
22 if (NOT LLDB_DISABLE_PYTHON)
23 set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
24 if(LLDB_BUILD_FRAMEWORK)
25 set(LLDB_PYTHON_TARGET_DIR
26 ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
28 # Don't set -m when building the framework.
29 set(FINISH_EXTRA_ARGS "-m")
31 set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp)
33 add_subdirectory(scripts)
35 add_subdirectory(source)
36 add_subdirectory(test)
37 add_subdirectory(tools)
38 add_subdirectory(unittests)
41 if (NOT LLDB_DISABLE_PYTHON)
42 # Add a Post-Build Event to copy over Python files and create the symlink
43 # to liblldb.so for the Python API(hardlink on Windows)
44 add_custom_target(finish_swig ALL
46 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
47 --srcRoot=${LLDB_SOURCE_DIR}
48 --targetDir=${LLDB_PYTHON_TARGET_DIR}
49 --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts
50 --prefix=${CMAKE_BINARY_DIR}
51 --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
52 --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
55 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
56 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scripts/lldb.py
57 COMMENT "Python script sym-linking LLDB Python API")
58 # We depend on liblldb being built before we can do this step.
59 add_dependencies(finish_swig liblldb lldb-argdumper)
61 # If we build the readline module, we depend on that happening
64 add_dependencies(finish_swig readline)
67 # Ensure we do the python post-build step when building lldb.
68 add_dependencies(lldb finish_swig)
70 if(LLDB_BUILD_FRAMEWORK)
71 # The target to install libLLDB needs to depend on finish swig so that the
72 # framework build properly copies over the Python files.
73 add_dependencies(install-liblldb finish_swig)
76 # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
77 # lldb.exe or any other executables that were linked with liblldb.
78 if (WIN32 AND NOT "${PYTHON_DLL}" STREQUAL "")
79 # When using the Visual Studio CMake generator the lldb binaries end up in Release/bin, Debug/bin etc.
80 file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin" LLDB_BIN_DIR)
81 file(TO_NATIVE_PATH "${PYTHON_DLL}" PYTHON_DLL_NATIVE_PATH)
85 COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_DLL_NATIVE_PATH} ${LLDB_BIN_DIR} VERBATIM
86 COMMENT "Copying Python DLL to LLDB binaries directory.")