1 cmake_minimum_required(VERSION 3.13.4)
3 if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
4 set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
6 include(${LLVM_COMMON_CMAKE_UTILS}/Modules/CMakePolicy.cmake
9 # Add path for custom modules.
12 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
13 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
16 # If we are not building as part of LLVM, build LLDB as a standalone project,
17 # using LLVM as an external library.
18 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
20 set(LLDB_BUILT_STANDALONE TRUE)
23 # Must go below project(..)
24 include(GNUInstallDirs)
26 option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
28 if(LLDB_BUILT_STANDALONE)
29 include(LLDBStandalone)
31 set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
32 set(CMAKE_CXX_STANDARD_REQUIRED YES)
33 set(CMAKE_CXX_EXTENSIONS NO)
39 # Define the LLDB_CONFIGURATION_xxx matching the build type.
40 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
41 add_definitions(-DLLDB_CONFIGURATION_DEBUG)
45 add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
48 if (LLDB_ENABLE_PYTHON)
49 set(cachestring_LLDB_PYTHON_RELATIVE_PATH
50 "Path where Python modules are installed, relative to LLDB's install prefix")
51 set(cachestring_LLDB_PYTHON_EXE_RELATIVE_PATH
52 "Path to python interpreter exectuable, relative to python's install prefix")
53 set(cachestring_LLDB_PYTHON_EXT_SUFFIX
54 "Filename extension for native code python modules")
56 foreach(var LLDB_PYTHON_RELATIVE_PATH LLDB_PYTHON_EXE_RELATIVE_PATH LLDB_PYTHON_EXT_SUFFIX)
57 if(NOT DEFINED ${var} AND NOT CMAKE_CROSSCOMPILING)
59 COMMAND ${Python3_EXECUTABLE}
60 ${CMAKE_CURRENT_SOURCE_DIR}/bindings/python/get-python-config.py
63 OUTPUT_STRIP_TRAILING_WHITESPACE)
64 file(TO_CMAKE_PATH "${value}" value)
65 set(${var} ${value} CACHE STRING ${cachestring_${var}})
67 if ("${${var}}" STREQUAL "")
69 "Crosscompiling LLDB with Python requires manually setting ${var}.")
76 find_program(Lua_EXECUTABLE lua5.3)
77 set(LLDB_LUA_DEFAULT_RELATIVE_PATH "lib/lua/5.3")
78 set(LLDB_LUA_RELATIVE_PATH ${LLDB_LUA_DEFAULT_RELATIVE_PATH}
79 CACHE STRING "Path where Lua modules are installed, relative to install prefix")
82 if (LLDB_ENABLE_PYTHON OR LLDB_ENABLE_LUA)
83 add_subdirectory(bindings)
86 # We need the headers generated by instrinsics_gen before we can compile
87 # any source file in LLDB as the imported Clang modules might include
88 # some of these generated headers. This approach is copied from Clang's main
89 # CMakeLists.txt, so it should kept in sync the code in Clang which was added
91 if(LLVM_ENABLE_MODULES)
92 list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
95 if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE AND NOT LLDB_TABLEGEN_EXE)
96 set(LLVM_USE_HOST_TOOLS ON)
98 if (NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR)
100 "Crosscompiling standalone requires the variables NATIVE_{CLANG,LLVM}_DIR
101 for building the native lldb-tblgen used during the build process.")
103 llvm_create_cross_target(lldb NATIVE "" Release
104 -DLLVM_DIR=${NATIVE_LLVM_DIR}
105 -DClang_DIR=${NATIVE_Clang_DIR})
109 add_subdirectory(utils/TableGen)
111 add_subdirectory(source)
112 add_subdirectory(tools)
113 add_subdirectory(docs)
115 if (LLDB_ENABLE_PYTHON)
116 if(LLDB_BUILD_FRAMEWORK)
117 set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
119 set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
121 get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR)
122 finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}")
126 if(LLDB_BUILD_FRAMEWORK)
127 set(lldb_lua_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Lua")
129 set(lldb_lua_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_LUA_RELATIVE_PATH}")
131 get_target_property(lldb_lua_bindings_dir swig_wrapper_lua BINARY_DIR)
132 finish_swig_lua("lldb-lua" "${lldb_lua_bindings_dir}" "${lldb_lua_target_dir}")
135 set(LLDB_INCLUDE_UNITTESTS ON)
136 if (NOT TARGET llvm_gtest)
137 set(LLDB_INCLUDE_UNITTESTS OFF)
140 if(LLDB_INCLUDE_TESTS)
141 add_subdirectory(test)
142 if (LLDB_INCLUDE_UNITTESTS)
143 add_subdirectory(unittests)
145 add_subdirectory(utils)
148 if(LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE)
149 llvm_distribution_add_targets()