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 set(LLDB_BUILT_STANDALONE TRUE)
17 # Must go below project(..)
18 include(GNUInstallDirs)
20 if(LLDB_BUILT_STANDALONE)
21 include(LLDBStandalone)
23 set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
24 set(CMAKE_CXX_STANDARD_REQUIRED YES)
25 set(CMAKE_CXX_EXTENSIONS NO)
31 # Define the LLDB_CONFIGURATION_xxx matching the build type.
32 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
33 add_definitions(-DLLDB_CONFIGURATION_DEBUG)
37 add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
40 if (LLDB_ENABLE_PYTHON)
41 set(cachestring_LLDB_PYTHON_RELATIVE_PATH
42 "Path where Python modules are installed, relative to LLDB's install prefix")
43 set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
44 "Path to python interpreter exectuable, relative to python's install prefix")
45 set(cachestring_LLDB_PYTHON_EXT_SUFFIX
46 "Filename extension for native code python modules")
48 foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH LLDB_PYTHON_EXT_SUFFIX)
49 if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
51 COMMAND ${Python3_EXECUTABLE}
52 ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/get-python-config.py
55 OUTPUT_STRIP_TRAILING_WHITESPACE)
56 file(TO_CMAKE_PATH "${value}" value)
57 set(${var} ${value} CACHE STRING ${cachestring_${var}})
59 if ("${${var}}" STREQUAL "")
61 "Crosscompiling LLDB with Python requires manually setting ${var}.")
68 find_program(Lua_EXECUTABLE lua5.3)
69 set(LLDB_LUA_DEFAULT_RELATIVE_PATH "lib/lua/5.3")
70 set(LLDB_LUA_RELATIVE_PATH ${LLDB_LUA_DEFAULT_RELATIVE_PATH}
71 CACHE STRING "Path where Lua modules are installed, relative to install prefix")
74 if (LLDB_ENABLE_PYTHON OR LLDB_ENABLE_LUA)
75 add_subdirectory(bindings)
78 # We need the headers generated by instrinsics_gen before we can compile
79 # any source file in LLDB as the imported Clang modules might include
80 # some of these generated headers. This approach is copied from Clang's main
81 # CMakeLists.txt, so it should kept in sync the code in Clang which was added
83 if(LLVM_ENABLE_MODULES)
84 list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
87 if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE AND NOT LLDB_TABLEGEN_EXE)
88 set(LLVM_USE_HOST_TOOLS ON)
90 if (NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR)
92 "Crosscompiling standalone requires the variables NATIVE_{CLANG,LLVM}_DIR
93 for building the native lldb-tblgen used during the build process.")
95 llvm_create_cross_target(lldb NATIVE "" Release
96 -DLLVM_DIR=${NATIVE_LLVM_DIR}
97 -DClang_DIR=${NATIVE_Clang_DIR})
101 add_subdirectory(utils/TableGen)
103 add_subdirectory(source)
104 add_subdirectory(tools)
105 add_subdirectory(docs)
107 if (LLDB_ENABLE_PYTHON)
108 if(LLDB_BUILD_FRAMEWORK)
109 set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
111 set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
113 get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR)
114 finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}")
118 if(LLDB_BUILD_FRAMEWORK)
119 set(lldb_lua_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Lua")
121 set(lldb_lua_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_LUA_RELATIVE_PATH}")
123 get_target_property(lldb_lua_bindings_dir swig_wrapper_lua BINARY_DIR)
124 finish_swig_lua("lldb-lua" "${lldb_lua_bindings_dir}" "${lldb_lua_target_dir}")
127 option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
128 if(LLDB_INCLUDE_TESTS)
129 add_subdirectory(test)
130 add_subdirectory(unittests)
131 add_subdirectory(utils)
134 if(LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE)
135 llvm_distribution_add_targets()