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 # Define the LLDB_CONFIGURATION_xxx matching the build type
15 if( uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
16 add_definitions( -DLLDB_CONFIGURATION_DEBUG )
18 add_definitions( -DLLDB_CONFIGURATION_RELEASE )
21 if (CMAKE_SYSTEM_NAME MATCHES "Windows|Android")
22 set(LLDB_DEFAULT_DISABLE_LIBEDIT 1)
24 set(LLDB_DEFAULT_DISABLE_LIBEDIT 0)
27 # We need libedit support to go down both the source and
28 # the scripts directories.
29 set(LLDB_DISABLE_LIBEDIT ${LLDB_DEFAULT_DISABLE_LIBEDIT} CACHE BOOL "Disables the use of editline.")
30 if (LLDB_DISABLE_LIBEDIT)
31 add_definitions( -DLLDB_DISABLE_LIBEDIT )
35 add_definitions(-DLLDB_USE_OS_LOG)
38 # add_subdirectory(include)
39 add_subdirectory(docs)
40 if (NOT LLDB_DISABLE_PYTHON)
41 if(LLDB_USE_SYSTEM_SIX)
42 set(SIX_EXTRA_ARGS "--useSystemSix")
45 set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
46 set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
47 if(LLDB_BUILD_FRAMEWORK)
48 set(LLDB_PYTHON_TARGET_DIR
49 ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
50 set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp)
52 # Don't set -m when building the framework.
53 set(FINISH_EXTRA_ARGS "-m")
57 add_subdirectory(scripts)
60 add_subdirectory(source)
61 add_subdirectory(tools)
63 option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests."
64 ${LLVM_INCLUDE_TESTS})
65 option(LLDB_TEST_USE_CUSTOM_C_COMPILER "Use the C compiler provided via LLDB_TEST_C_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF)
66 option(LLDB_TEST_USE_CUSTOM_CXX_COMPILER "Use the C++ compiler provided via LLDB_TEST_CXX_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF)
67 if(LLDB_INCLUDE_TESTS)
68 if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER AND TARGET clang)
69 set(LLDB_DEFAULT_TEST_C_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}")
71 set(LLDB_DEFAULT_TEST_C_COMPILER "")
74 if (NOT LLDB_TEST_USE_CUSTOM_CXX_COMPILER AND TARGET clang)
75 set(LLDB_DEFAULT_TEST_CXX_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}")
77 set(LLDB_DEFAULT_TEST_CXX_COMPILER "")
80 set(LLDB_TEST_C_COMPILER "${LLDB_DEFAULT_TEST_C_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors")
81 set(LLDB_TEST_CXX_COMPILER "${LLDB_DEFAULT_TEST_CXX_COMPILER}" CACHE PATH "C++ Compiler to use for building LLDB test inferiors")
83 if (("${LLDB_TEST_C_COMPILER}" STREQUAL "") OR
84 ("${LLDB_TEST_CXX_COMPILER}" STREQUAL ""))
85 message(FATAL_ERROR "LLDB test compilers not specified. Tests will not run")
88 add_subdirectory(test)
89 add_subdirectory(unittests)
93 if (NOT LLDB_DISABLE_PYTHON)
94 # Add a Post-Build Event to copy over Python files and create the symlink
95 # to liblldb.so for the Python API(hardlink on Windows)
96 add_custom_target(finish_swig ALL
98 ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
99 --srcRoot=${LLDB_SOURCE_DIR}
100 --targetDir=${LLDB_PYTHON_TARGET_DIR}
101 --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts
102 --prefix=${CMAKE_BINARY_DIR}
103 --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
104 --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
108 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
109 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scripts/lldb.py
110 COMMENT "Python script sym-linking LLDB Python API")
111 # We depend on liblldb being built before we can do this step.
112 add_dependencies(finish_swig liblldb lldb-argdumper)
114 # If we build the readline module, we depend on that happening
117 add_dependencies(finish_swig readline)
120 # Ensure we do the python post-build step when building lldb.
121 add_dependencies(lldb finish_swig)
123 if(LLDB_BUILD_FRAMEWORK)
124 # The target to install libLLDB needs to depend on finish swig so that the
125 # framework build properly copies over the Python files.
126 add_dependencies(install-liblldb finish_swig)
129 # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
130 # lldb.exe or any other executables that were linked with liblldb.
131 if (WIN32 AND NOT "${PYTHON_DLL}" STREQUAL "")
132 # When using the Visual Studio CMake generator the lldb binaries end up in Release/bin, Debug/bin etc.
133 file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin" LLDB_BIN_DIR)
134 file(TO_NATIVE_PATH "${PYTHON_DLL}" PYTHON_DLL_NATIVE_PATH)
138 COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_DLL_NATIVE_PATH} ${LLDB_BIN_DIR} VERBATIM
139 COMMENT "Copying Python DLL to LLDB binaries directory.")