1 get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS)
3 if(LLDB_BUILD_FRAMEWORK)
4 set(option_install_prefix INSTALL_PREFIX ${LLDB_FRAMEWORK_INSTALL_DIR})
5 set(option_framework FRAMEWORK)
9 if (APPLE AND LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY)
10 # Work around an issue with the Python headers, which have a modular include
11 # inside an extern "C" block.
14 get_target_property(python_bindings_dir swig_wrapper_python BINARY_DIR)
15 set(lldb_python_wrapper ${python_bindings_dir}/LLDBWrapPython.cpp)
19 get_target_property(lua_bindings_dir swig_wrapper_lua BINARY_DIR)
20 set(lldb_lua_wrapper ${lua_bindings_dir}/LLDBWrapLua.cpp)
23 add_lldb_library(liblldb SHARED ${option_framework}
28 SBBreakpointLocation.cpp
30 SBBreakpointOptionCommon.cpp
32 SBCommandInterpreter.cpp
33 SBCommandInterpreterRunOptions.cpp
34 SBCommandReturnObject.cpp
43 SBExecutionContext.cpp
44 SBExpressionOptions.cpp
57 SBMemoryRegionInfo.cpp
58 SBMemoryRegionInfoList.cpp
76 SBSymbolContextList.cpp
79 SBThreadCollection.cpp
88 SBTypeNameSpecifier.cpp
93 SBVariablesOptions.cpp
95 SBWatchpointOptions.cpp
97 SystemInitializerFull.cpp
98 ${lldb_python_wrapper}
117 ${option_install_prefix}
120 # lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so,
121 # which depends on lib/libLLVM*.so (BUILD_SHARED_LIBS) or lib/libLLVM-10git.so
122 # (LLVM_LINK_LLVM_DYLIB). Add an additional rpath $ORIGIN/../../../../lib so
123 # that _lldb.so can be loaded from Python.
124 if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX AND NOT APPLE)
125 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}")
129 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}")
130 set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
134 if(LLDB_ENABLE_PYTHON)
135 add_dependencies(liblldb swig_wrapper_python)
138 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
140 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
143 set_source_files_properties(${lldb_python_wrapper} PROPERTIES GENERATED ON)
145 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
146 PROPERTY COMPILE_FLAGS " -Wno-unused-function")
148 if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
149 NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
150 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
151 PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
156 add_dependencies(liblldb swig_wrapper_lua)
157 target_include_directories(liblldb PRIVATE ${LUA_INCLUDE_DIR})
160 set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
162 set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
165 set_source_files_properties(${lldb_lua_wrapper} PROPERTIES GENERATED ON)
168 set_target_properties(liblldb
170 VERSION ${LLDB_VERSION}
173 target_compile_definitions(liblldb PRIVATE LLDB_IN_LIBLLDB)
174 if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
175 if (NOT LLDB_EXPORT_ALL_SYMBOLS)
176 # If we're not exporting all symbols, we'll want to explicitly set
177 # the exported symbols here. This prevents 'log enable --stack ...'
178 # from working on some systems but limits the liblldb size.
179 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb namespace")
180 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
181 elseif (NOT LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE)
182 # Don't use an explicit export. Instead, tell the linker to export all symbols.
183 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces")
184 MESSAGE(WARNING "Private LLDB symbols frequently change and no API stability is guaranteed. "
185 "Only the SB API is guaranteed to be stable.")
186 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
188 MESSAGE("-- Symbols (liblldb): exporting all symbols specified in the exports "
189 " file '${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}'")
190 MESSAGE(WARNING "Private LLDB symbols frequently change and no API stability is guaranteed. "
191 "Only the SB API is guaranteed to be stable.")
192 add_llvm_symbol_exports(liblldb "${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}")
194 set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
195 elseif (LLDB_EXPORT_ALL_SYMBOLS)
196 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces")
198 # Pull out the various lldb libraries linked into liblldb, these will be used
199 # when looking for symbols to extract. We ignore plugin libraries here,
200 # because these symbols aren't publicly exposed.
201 get_target_property(all_liblldb_libs liblldb LINK_LIBRARIES)
203 foreach(lib ${all_liblldb_libs})
204 if(TARGET ${lib} AND ${lib} MATCHES "^lldb" AND
205 NOT ${lib} MATCHES "^lldbPlugin")
206 get_target_property(lib_type ${lib} TYPE)
207 if("${lib_type}" STREQUAL "STATIC_LIBRARY")
208 list(APPEND lldb_libs ${lib})
212 list(REMOVE_DUPLICATES lldb_libs)
214 # Extract all of the private symbols and produce a single file we can use for
216 set(exported_symbol_file ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/liblldb_private.symbols)
217 get_host_tool_path(llvm-nm LLVM_NM llvm_nm_exe llvm_nm_target)
219 OUTPUT ${exported_symbol_file}
220 COMMAND "${Python3_EXECUTABLE}"
221 ${LLDB_SOURCE_DIR}/scripts/msvc_extract_private_symbols.py
222 ${lldb_libs} -o ${exported_symbol_file} --nm=${llvm_nm_exe}
223 WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR}
224 DEPENDS ${LLDB_SOURCE_DIR}/scripts/msvc_extract_private_symbols.py
225 ${lldb_libs} ${llvm_nm_target}
227 COMMENT "Generating liblldb private export list"
230 add_llvm_symbol_exports(liblldb ${exported_symbol_file})
231 set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc")
235 set_target_properties(liblldb
241 # The Clang expression parser in LLDB requires the Clang resource directory to function.
242 if (TARGET clang-resource-headers)
243 # If building alongside Clang, just add a dependency to ensure it is build together with liblldb.
244 add_dependencies(liblldb clang-resource-headers)
246 # In a standalone build create a symlink from the LLDB library directory that points to the
247 # resource directory in the Clang library directory. LLDB searches relative to its install path,
248 # and the symlink is created in the same relative path as the resource directory of Clang when
249 # building alongside Clang.
250 # When building the LLDB framework, this isn't necessary as there we copy everything we need into
251 # the framework (including the Clang resourece directory).
252 if(NOT LLDB_BUILD_FRAMEWORK)
253 set(LLDB_CLANG_RESOURCE_DIR "$<TARGET_FILE_DIR:liblldb>/clang")
254 add_custom_command(TARGET liblldb POST_BUILD
255 COMMENT "Linking Clang resource dir into LLDB build directory: ${LLDB_CLANG_RESOURCE_DIR}"
256 COMMAND ${CMAKE_COMMAND} -E create_symlink
257 "${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}" "${LLDB_CLANG_RESOURCE_DIR}"
262 if(LLDB_BUILD_FRAMEWORK)
263 include(LLDBFramework)
265 if (TARGET install-liblldb)
266 add_dependencies(install-liblldb
267 lldb-framework-cleanup)
270 if (TARGET install-liblldb-stripped)
271 add_dependencies(install-liblldb-stripped
272 lldb-framework-cleanup)