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