1get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS) 2 3if(LLDB_BUILD_FRAMEWORK) 4 set(option_install_prefix INSTALL_PREFIX ${LLDB_FRAMEWORK_INSTALL_DIR}) 5 set(option_framework FRAMEWORK) 6endif() 7 8if(LLDB_ENABLE_PYTHON) 9 get_target_property(python_bindings_dir swig_wrapper_python BINARY_DIR) 10 set(lldb_python_wrapper ${python_bindings_dir}/LLDBWrapPython.cpp) 11endif() 12 13if(LLDB_ENABLE_LUA) 14 get_target_property(lua_bindings_dir swig_wrapper_lua BINARY_DIR) 15 set(lldb_lua_wrapper ${lua_bindings_dir}/LLDBWrapLua.cpp) 16endif() 17 18add_lldb_library(liblldb SHARED ${option_framework} 19 SBAddress.cpp 20 SBAttachInfo.cpp 21 SBBlock.cpp 22 SBBreakpoint.cpp 23 SBBreakpointLocation.cpp 24 SBBreakpointName.cpp 25 SBBreakpointOptionCommon.cpp 26 SBBroadcaster.cpp 27 SBCommandInterpreter.cpp 28 SBCommandInterpreterRunOptions.cpp 29 SBCommandReturnObject.cpp 30 SBCommunication.cpp 31 SBCompileUnit.cpp 32 SBData.cpp 33 SBDebugger.cpp 34 SBDeclaration.cpp 35 SBEnvironment.cpp 36 SBError.cpp 37 SBEvent.cpp 38 SBExecutionContext.cpp 39 SBExpressionOptions.cpp 40 SBFileSpec.cpp 41 SBFile.cpp 42 SBFileSpecList.cpp 43 SBFrame.cpp 44 SBFunction.cpp 45 SBHostOS.cpp 46 SBInstruction.cpp 47 SBInstructionList.cpp 48 SBLanguageRuntime.cpp 49 SBLaunchInfo.cpp 50 SBLineEntry.cpp 51 SBListener.cpp 52 SBMemoryRegionInfo.cpp 53 SBMemoryRegionInfoList.cpp 54 SBModule.cpp 55 SBModuleSpec.cpp 56 SBPlatform.cpp 57 SBProcess.cpp 58 SBProcessInfo.cpp 59 SBQueue.cpp 60 SBQueueItem.cpp 61 SBReproducer.cpp 62 SBSection.cpp 63 SBSourceManager.cpp 64 SBStream.cpp 65 SBStringList.cpp 66 SBStructuredData.cpp 67 SBSymbol.cpp 68 SBSymbolContext.cpp 69 SBSymbolContextList.cpp 70 SBTarget.cpp 71 SBThread.cpp 72 SBThreadCollection.cpp 73 SBThreadPlan.cpp 74 SBTrace.cpp 75 SBType.cpp 76 SBTypeCategory.cpp 77 SBTypeEnumMember.cpp 78 SBTypeFilter.cpp 79 SBTypeFormat.cpp 80 SBTypeNameSpecifier.cpp 81 SBTypeSummary.cpp 82 SBTypeSynthetic.cpp 83 SBValue.cpp 84 SBValueList.cpp 85 SBVariablesOptions.cpp 86 SBWatchpoint.cpp 87 SBUnixSignals.cpp 88 SystemInitializerFull.cpp 89 ${lldb_python_wrapper} 90 ${lldb_lua_wrapper} 91 92 LINK_LIBS 93 lldbBreakpoint 94 lldbCore 95 lldbDataFormatters 96 lldbExpression 97 lldbHost 98 lldbInitialization 99 lldbInterpreter 100 lldbSymbol 101 lldbTarget 102 lldbUtility 103 lldbVersion 104 ${LLDB_ALL_PLUGINS} 105 LINK_COMPONENTS 106 Support 107 108 ${option_install_prefix} 109) 110 111# lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so, 112# which depends on lib/libLLVM*.so (BUILD_SHARED_LIBS) or lib/libLLVM-10git.so 113# (LLVM_LINK_LLVM_DYLIB). Add an additional rpath $ORIGIN/../../../../lib so 114# that _lldb.so can be loaded from Python. 115if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX AND NOT APPLE) 116 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}") 117endif() 118 119if(Python3_RPATH) 120 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}") 121 set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}") 122endif() 123 124 125if(LLDB_ENABLE_PYTHON) 126 add_dependencies(liblldb swig_wrapper_python) 127 128 if (MSVC) 129 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") 130 else() 131 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") 132 endif() 133 134 set_source_files_properties(${lldb_python_wrapper} PROPERTIES GENERATED ON) 135 if (CLANG_CL) 136 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING 137 PROPERTY COMPILE_FLAGS " -Wno-unused-function") 138 endif() 139 if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND 140 NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") 141 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING 142 PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual") 143 endif () 144endif() 145 146if(LLDB_ENABLE_LUA) 147 add_dependencies(liblldb swig_wrapper_lua) 148 target_include_directories(liblldb PRIVATE ${LUA_INCLUDE_DIR}) 149 150 if (MSVC) 151 set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") 152 else() 153 set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") 154 endif() 155 156 set_source_files_properties(${lldb_lua_wrapper} PROPERTIES GENERATED ON) 157endif() 158 159set_target_properties(liblldb 160 PROPERTIES 161 VERSION ${LLDB_VERSION} 162) 163 164target_compile_definitions(liblldb PRIVATE LLDB_IN_LIBLLDB) 165if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") 166 if (NOT LLDB_EXPORT_ALL_SYMBOLS) 167 # If we're not exporting all symbols, we'll want to explicitly set 168 # the exported symbols here. This prevents 'log enable --stack ...' 169 # from working on some systems but limits the liblldb size. 170 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb namespace") 171 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports) 172 else() 173 # Don't use an explicit export. Instead, tell the linker to 174 # export all symbols. 175 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces") 176 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports) 177 endif() 178 set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc") 179endif() 180 181if (NOT MSVC) 182 set_target_properties(liblldb 183 PROPERTIES 184 OUTPUT_NAME lldb 185 ) 186endif() 187 188# The Clang expression parser in LLDB requires the Clang resource directory to function. 189if (TARGET clang-resource-headers) 190 # If building alongside Clang, just add a dependency to ensure it is build together with liblldb. 191 add_dependencies(liblldb clang-resource-headers) 192else() 193 # In a standalone build create a symlink from the LLDB library directory that points to the 194 # resource directory in the Clang library directory. LLDB searches relative to its install path, 195 # and the symlink is created in the same relative path as the resource directory of Clang when 196 # building alongside Clang. 197 # When building the LLDB framework, this isn't necessary as there we copy everything we need into 198 # the framework (including the Clang resourece directory). 199 if(NOT LLDB_BUILD_FRAMEWORK) 200 set(LLDB_CLANG_RESOURCE_DIR_PARENT "$<TARGET_FILE_DIR:liblldb>/clang") 201 file(MAKE_DIRECTORY "${LLDB_CLANG_RESOURCE_DIR_PARENT}") 202 add_custom_command(TARGET liblldb POST_BUILD 203 COMMENT "Linking Clang resource dir into LLDB build directory: ${LLDB_CLANG_RESOURCE_DIR_PARENT}" 204 COMMAND ${CMAKE_COMMAND} -E make_directory "${LLDB_CLANG_RESOURCE_DIR_PARENT}" 205 COMMAND ${CMAKE_COMMAND} -E create_symlink "${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}" 206 "${LLDB_CLANG_RESOURCE_DIR_PARENT}/${LLDB_CLANG_RESOURCE_DIR_NAME}" 207 ) 208 endif() 209endif() 210 211if(LLDB_BUILD_FRAMEWORK) 212 include(LLDBFramework) 213endif() 214