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 # Generate SBLanguages.h from Dwarf.def.
25 ${CMAKE_CURRENT_BINARY_DIR}/../../include/lldb/API/SBLanguages.h)
26 set(sb_languages_generator
27 ${LLDB_SOURCE_DIR}/scripts/generate-sbapi-dwarf-enum.py)
29 COMMENT "Generating SBLanguages.h from Dwarf.def"
30 COMMAND "${Python3_EXECUTABLE}"
31 ${sb_languages_generator}
32 ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def
33 -o ${sb_languages_file}
34 OUTPUT ${sb_languages_file}
35 DEPENDS ${LLVM_MAIN_INCLUDE_DIR}/llvm/BinaryFormat/Dwarf.def
36 ${sb_languages_generator}
37 WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR}
39 add_custom_target(lldb-sbapi-dwarf-enums
40 DEPENDS ${sb_languages_file})
41 set_target_properties(lldb-sbapi-dwarf-enums PROPERTIES FOLDER "LLDB/Tablegenning")
43 add_lldb_library(liblldb SHARED ${option_framework}
46 SBAddressRangeList.cpp
50 SBBreakpointLocation.cpp
52 SBBreakpointOptionCommon.cpp
54 SBCommandInterpreter.cpp
55 SBCommandInterpreterRunOptions.cpp
56 SBCommandReturnObject.cpp
66 SBExecutionContext.cpp
67 SBExpressionOptions.cpp
81 SBMemoryRegionInfo.cpp
82 SBMemoryRegionInfoList.cpp
95 SBStatisticsOptions.cpp
101 SBSymbolContextList.cpp
104 SBThreadCollection.cpp
113 SBTypeNameSpecifier.cpp
118 SBVariablesOptions.cpp
120 SBWatchpointOptions.cpp
122 SystemInitializerFull.cpp
123 ${lldb_python_wrapper}
127 lldb-sbapi-dwarf-enums
146 ${option_install_prefix}
149 # lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so,
150 # which depends on lib/libLLVM*.so (BUILD_SHARED_LIBS) or lib/libLLVM-10git.so
151 # (LLVM_LINK_LLVM_DYLIB). Add an additional rpath $ORIGIN/../../../../lib so
152 # that _lldb.so can be loaded from Python.
153 if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX AND NOT APPLE)
154 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}")
158 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}")
159 set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}")
163 if(LLDB_ENABLE_PYTHON)
164 add_dependencies(liblldb swig_wrapper_python)
167 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
169 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
172 set_source_files_properties(${lldb_python_wrapper} PROPERTIES GENERATED ON)
174 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
175 PROPERTY COMPILE_FLAGS " -Wno-unused-function")
177 if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND
178 NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
179 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING
180 PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual")
185 add_dependencies(liblldb swig_wrapper_lua)
186 target_include_directories(liblldb PRIVATE ${LUA_INCLUDE_DIR})
189 set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
191 set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
194 set_source_files_properties(${lldb_lua_wrapper} PROPERTIES GENERATED ON)
197 set_target_properties(liblldb
199 VERSION ${LLDB_VERSION}
202 target_compile_definitions(liblldb PRIVATE LLDB_IN_LIBLLDB)
203 if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
204 if (NOT LLDB_EXPORT_ALL_SYMBOLS)
205 # If we're not exporting all symbols, we'll want to explicitly set
206 # the exported symbols here. This prevents 'log enable --stack ...'
207 # from working on some systems but limits the liblldb size.
208 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb namespace")
209 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
210 elseif (NOT LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE)
211 # Don't use an explicit export. Instead, tell the linker to export all symbols.
212 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces")
213 MESSAGE(WARNING "Private LLDB symbols frequently change and no API stability is guaranteed. "
214 "Only the SB API is guaranteed to be stable.")
215 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
217 MESSAGE("-- Symbols (liblldb): exporting all symbols specified in the exports "
218 " file '${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}'")
219 MESSAGE(WARNING "Private LLDB symbols frequently change and no API stability is guaranteed. "
220 "Only the SB API is guaranteed to be stable.")
221 add_llvm_symbol_exports(liblldb "${LLDB_EXPORT_ALL_SYMBOLS_EXPORTS_FILE}")
223 elseif (LLDB_EXPORT_ALL_SYMBOLS)
224 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces")
226 # Pull out the various lldb libraries linked into liblldb, these will be used
227 # when looking for symbols to extract. We ignore most plugin libraries here,
228 # because we may expose more symbols than the DLL limit and these symbols
229 # aren't useful to expose.
230 get_target_property(all_liblldb_libs liblldb LINK_LIBRARIES)
232 foreach(lib ${all_liblldb_libs})
233 if(TARGET ${lib} AND ${lib} MATCHES "^lldb" AND
234 (${lib} IN_LIST LLDB_EXPORT_ALL_SYMBOLS_PLUGINS OR
235 NOT ${lib} MATCHES "^lldbPlugin"))
236 get_target_property(lib_type ${lib} TYPE)
237 if("${lib_type}" STREQUAL "STATIC_LIBRARY")
238 list(APPEND lldb_libs ${lib})
242 list(REMOVE_DUPLICATES lldb_libs)
244 # Extract all of the private symbols and produce a single file we can use for
246 set(exported_symbol_file ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/liblldb_private.symbols)
247 get_host_tool_path(llvm-nm LLVM_NM llvm_nm_exe llvm_nm_target)
249 OUTPUT ${exported_symbol_file}
250 COMMAND "${Python3_EXECUTABLE}"
251 ${LLDB_SOURCE_DIR}/scripts/msvc_extract_private_symbols.py
252 ${lldb_libs} -o ${exported_symbol_file} --nm=${llvm_nm_exe}
253 WORKING_DIRECTORY ${LLVM_LIBRARY_OUTPUT_INTDIR}
254 DEPENDS ${LLDB_SOURCE_DIR}/scripts/msvc_extract_private_symbols.py
255 ${lldb_libs} ${llvm_nm_target}
257 COMMENT "Generating liblldb private export list"
260 add_llvm_symbol_exports(liblldb ${exported_symbol_file})
264 set_target_properties(liblldb
270 # The Clang expression parser in LLDB requires the Clang resource directory to function.
271 if (TARGET clang-resource-headers)
272 # If building alongside Clang, just add a dependency to ensure it is build together with liblldb.
273 add_dependencies(liblldb clang-resource-headers)
275 # In a standalone build create a symlink from the LLDB library directory that points to the
276 # resource directory in the Clang library directory. LLDB searches relative to its install path,
277 # and the symlink is created in the same relative path as the resource directory of Clang when
278 # building alongside Clang.
279 # When building the LLDB framework, this isn't necessary as there we copy everything we need into
280 # the framework (including the Clang resourece directory).
281 if(NOT LLDB_BUILD_FRAMEWORK)
282 set(LLDB_CLANG_RESOURCE_DIR "$<TARGET_FILE_DIR:liblldb>/clang")
283 add_custom_command(TARGET liblldb POST_BUILD
284 COMMENT "Linking Clang resource dir into LLDB build directory: ${LLDB_CLANG_RESOURCE_DIR}"
285 COMMAND ${CMAKE_COMMAND} -E create_symlink
286 "${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}" "${LLDB_CLANG_RESOURCE_DIR}"
291 if(LLDB_BUILD_FRAMEWORK)
292 include(LLDBFramework)
294 if (TARGET install-liblldb)
295 add_dependencies(install-liblldb
296 lldb-framework-cleanup)
299 if (TARGET install-liblldb-stripped)
300 add_dependencies(install-liblldb-stripped
301 lldb-framework-cleanup)