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 (CMAKE_SYSTEM_NAME MATCHES "Windows|Android")
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 if(LLDB_USE_SYSTEM_SIX)
24 set(SIX_EXTRA_ARGS "--useSystemSix")
27 set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
28 if(LLDB_BUILD_FRAMEWORK)
29 set(LLDB_PYTHON_TARGET_DIR
30 ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
32 # Don't set -m when building the framework.
33 set(FINISH_EXTRA_ARGS "-m")
35 set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
37 add_subdirectory(scripts)
39 add_subdirectory(source)
40 add_subdirectory(test)
41 add_subdirectory(tools)
42 add_subdirectory(unittests)
45 if (NOT LLDB_DISABLE_PYTHON)
46 # Add a Post-Build Event to copy over Python files and create the symlink
47 # to liblldb.so for the Python API(hardlink on Windows)
48 add_custom_target(finish_swig ALL
50 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
51 --srcRoot=${LLDB_SOURCE_DIR}
52 --targetDir=${LLDB_PYTHON_TARGET_DIR}
53 --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts
54 --prefix=${CMAKE_BINARY_DIR}
55 --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
56 --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
60 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
61 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scripts/lldb.py
62 COMMENT "Python script sym-linking LLDB Python API")
63 # We depend on liblldb being built before we can do this step.
64 add_dependencies(finish_swig liblldb lldb-argdumper)
66 # If we build the readline module, we depend on that happening
69 add_dependencies(finish_swig readline)
72 # Ensure we do the python post-build step when building lldb.
73 add_dependencies(lldb finish_swig)
75 if(LLDB_BUILD_FRAMEWORK)
76 # The target to install libLLDB needs to depend on finish swig so that the
77 # framework build properly copies over the Python files.
78 add_dependencies(install-liblldb finish_swig)
81 # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
82 # lldb.exe or any other executables that were linked with liblldb.
83 if (WIN32 AND NOT "${PYTHON_DLL}" STREQUAL "")
84 # When using the Visual Studio CMake generator the lldb binaries end up in Release/bin, Debug/bin etc.
85 file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin" LLDB_BIN_DIR)
86 file(TO_NATIVE_PATH "${PYTHON_DLL}" PYTHON_DLL_NATIVE_PATH)
90 COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_DLL_NATIVE_PATH} ${LLDB_BIN_DIR} VERBATIM
91 COMMENT "Copying Python DLL to LLDB binaries directory.")