1 cmake_minimum_required(VERSION 3.13.4)
3 # Add path for custom modules.
6 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
7 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
10 # If we are not building as part of LLVM, build LLDB as a standalone project,
11 # using LLVM as an external library.
12 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
14 include(LLDBStandalone)
16 set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
17 set(CMAKE_CXX_STANDARD_REQUIRED YES)
18 set(CMAKE_CXX_EXTENSIONS NO)
24 # Define the LLDB_CONFIGURATION_xxx matching the build type.
25 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
26 add_definitions(-DLLDB_CONFIGURATION_DEBUG)
30 add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
33 if (LLDB_ENABLE_PYTHON)
34 if (NOT CMAKE_CROSSCOMPILING)
36 COMMAND ${Python3_EXECUTABLE}
37 -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
38 OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH
39 OUTPUT_STRIP_TRAILING_WHITESPACE)
41 file(TO_CMAKE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} LLDB_PYTHON_DEFAULT_RELATIVE_PATH)
43 if ("${LLDB_PYTHON_RELATIVE_PATH}" STREQUAL "")
45 "Crosscompiling LLDB with Python requires manually setting
46 LLDB_PYTHON_RELATIVE_PATH.")
50 set(LLDB_PYTHON_RELATIVE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH}
51 CACHE STRING "Path where Python modules are installed, relative to install prefix")
54 if (LLDB_ENABLE_PYTHON OR LLDB_ENABLE_LUA)
55 add_subdirectory(bindings)
58 # We need the headers generated by instrinsics_gen before we can compile
59 # any source file in LLDB as the imported Clang modules might include
60 # some of these generated headers. This approach is copied from Clang's main
61 # CMakeLists.txt, so it should kept in sync the code in Clang which was added
63 if(LLVM_ENABLE_MODULES)
64 list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
67 if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE AND NOT LLDB_TABLEGEN_EXE)
68 set(LLVM_USE_HOST_TOOLS ON)
70 if (NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR)
72 "Crosscompiling standalone requires the variables NATIVE_{CLANG,LLVM}_DIR
73 for building the native lldb-tblgen used during the build process.")
75 llvm_create_cross_target(lldb NATIVE "" Release
76 -DLLVM_DIR=${NATIVE_LLVM_DIR}
77 -DClang_DIR=${NATIVE_Clang_DIR})
81 add_subdirectory(utils/TableGen)
83 add_subdirectory(source)
84 add_subdirectory(tools)
85 add_subdirectory(docs)
87 if (LLDB_ENABLE_PYTHON)
88 if(LLDB_BUILD_FRAMEWORK)
89 set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
91 set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
93 get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR)
94 finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}")
97 option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
98 if(LLDB_INCLUDE_TESTS)
99 add_subdirectory(test)
100 add_subdirectory(unittests)
101 add_subdirectory(utils)
104 if(LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE)
105 llvm_distribution_add_targets()