1 cmake_minimum_required(VERSION 3.13.4)
3 include(GNUInstallDirs)
5 # Add path for custom modules.
8 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
9 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
12 # If we are not building as part of LLVM, build LLDB as a standalone project,
13 # using LLVM as an external library.
14 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
16 include(LLDBStandalone)
18 set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
19 set(CMAKE_CXX_STANDARD_REQUIRED YES)
20 set(CMAKE_CXX_EXTENSIONS NO)
26 # Define the LLDB_CONFIGURATION_xxx matching the build type.
27 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
28 add_definitions(-DLLDB_CONFIGURATION_DEBUG)
32 add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
35 if (LLDB_ENABLE_PYTHON)
36 set(cachestring_LLDB_PYTHON_RELATIVE_PATH
37 "Path where Python modules are installed, relative to LLDB's install prefix")
38 set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
39 "Path to python interpreter exectuable, relative to python's install prefix")
40 set(cachestring_LLDB_PYTHON_EXT_SUFFIX
41 "Filename extension for native code python modules")
43 foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH LLDB_PYTHON_EXT_SUFFIX)
44 if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
46 COMMAND ${Python3_EXECUTABLE}
47 ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/get-python-config.py
50 OUTPUT_STRIP_TRAILING_WHITESPACE)
51 file(TO_CMAKE_PATH "${value}" value)
52 set(${var} ${value} CACHE STRING ${cachestring_${var}})
54 if ("${${var}}" STREQUAL "")
56 "Crosscompiling LLDB with Python requires manually setting ${var}.")
63 find_program(Lua_EXECUTABLE lua5.3)
64 set(LLDB_LUA_DEFAULT_RELATIVE_PATH "lib/lua/5.3")
65 set(LLDB_LUA_RELATIVE_PATH ${LLDB_LUA_DEFAULT_RELATIVE_PATH}
66 CACHE STRING "Path where Lua modules are installed, relative to install prefix")
69 if (LLDB_ENABLE_PYTHON OR LLDB_ENABLE_LUA)
70 add_subdirectory(bindings)
73 # We need the headers generated by instrinsics_gen before we can compile
74 # any source file in LLDB as the imported Clang modules might include
75 # some of these generated headers. This approach is copied from Clang's main
76 # CMakeLists.txt, so it should kept in sync the code in Clang which was added
78 if(LLVM_ENABLE_MODULES)
79 list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
82 if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE AND NOT LLDB_TABLEGEN_EXE)
83 set(LLVM_USE_HOST_TOOLS ON)
85 if (NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR)
87 "Crosscompiling standalone requires the variables NATIVE_{CLANG,LLVM}_DIR
88 for building the native lldb-tblgen used during the build process.")
90 llvm_create_cross_target(lldb NATIVE "" Release
91 -DLLVM_DIR=${NATIVE_LLVM_DIR}
92 -DClang_DIR=${NATIVE_Clang_DIR})
96 add_subdirectory(utils/TableGen)
98 add_subdirectory(source)
99 add_subdirectory(tools)
100 add_subdirectory(docs)
102 if (LLDB_ENABLE_PYTHON)
103 if(LLDB_BUILD_FRAMEWORK)
104 set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
106 set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
108 get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR)
109 finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}")
113 if(LLDB_BUILD_FRAMEWORK)
114 set(lldb_lua_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Lua")
116 set(lldb_lua_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_LUA_RELATIVE_PATH}")
118 get_target_property(lldb_lua_bindings_dir swig_wrapper_lua BINARY_DIR)
119 finish_swig_lua("lldb-lua" "${lldb_lua_bindings_dir}" "${lldb_lua_target_dir}")
122 option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
123 if(LLDB_INCLUDE_TESTS)
124 add_subdirectory(test)
125 add_subdirectory(unittests)
126 add_subdirectory(utils)
129 if(LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE)
130 llvm_distribution_add_targets()