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 SBTraceCursor.cpp 76 SBType.cpp 77 SBTypeCategory.cpp 78 SBTypeEnumMember.cpp 79 SBTypeFilter.cpp 80 SBTypeFormat.cpp 81 SBTypeNameSpecifier.cpp 82 SBTypeSummary.cpp 83 SBTypeSynthetic.cpp 84 SBValue.cpp 85 SBValueList.cpp 86 SBVariablesOptions.cpp 87 SBWatchpoint.cpp 88 SBUnixSignals.cpp 89 SystemInitializerFull.cpp 90 ${lldb_python_wrapper} 91 ${lldb_lua_wrapper} 92 93 LINK_LIBS 94 lldbBreakpoint 95 lldbCore 96 lldbDataFormatters 97 lldbExpression 98 lldbHost 99 lldbInitialization 100 lldbInterpreter 101 lldbSymbol 102 lldbTarget 103 lldbUtility 104 lldbVersion 105 ${LLDB_ALL_PLUGINS} 106 LINK_COMPONENTS 107 Support 108 109 ${option_install_prefix} 110) 111 112# lib/pythonX.Y/dist-packages/lldb/_lldb.so is a symlink to lib/liblldb.so, 113# which depends on lib/libLLVM*.so (BUILD_SHARED_LIBS) or lib/libLLVM-10git.so 114# (LLVM_LINK_LLVM_DYLIB). Add an additional rpath $ORIGIN/../../../../lib so 115# that _lldb.so can be loaded from Python. 116if(LLDB_ENABLE_PYTHON AND (BUILD_SHARED_LIBS OR LLVM_LINK_LLVM_DYLIB) AND UNIX AND NOT APPLE) 117 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "\$ORIGIN/../../../../lib${LLVM_LIBDIR_SUFFIX}") 118endif() 119 120if(Python3_RPATH) 121 set_property(TARGET liblldb APPEND PROPERTY INSTALL_RPATH "${Python3_RPATH}") 122 set_property(TARGET liblldb APPEND PROPERTY BUILD_RPATH "${Python3_RPATH}") 123endif() 124 125 126if(LLDB_ENABLE_PYTHON) 127 add_dependencies(liblldb swig_wrapper_python) 128 129 if (MSVC) 130 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") 131 else() 132 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") 133 endif() 134 135 set_source_files_properties(${lldb_python_wrapper} PROPERTIES GENERATED ON) 136 if (CLANG_CL) 137 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING 138 PROPERTY COMPILE_FLAGS " -Wno-unused-function") 139 endif() 140 if (LLVM_COMPILER_IS_GCC_COMPATIBLE AND 141 NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") 142 set_property(SOURCE ${lldb_python_wrapper} APPEND_STRING 143 PROPERTY COMPILE_FLAGS " -Wno-sequence-point -Wno-cast-qual") 144 endif () 145endif() 146 147if(LLDB_ENABLE_LUA) 148 add_dependencies(liblldb swig_wrapper_lua) 149 target_include_directories(liblldb PRIVATE ${LUA_INCLUDE_DIR}) 150 151 if (MSVC) 152 set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") 153 else() 154 set_property(SOURCE ${lldb_lua_wrapper} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") 155 endif() 156 157 set_source_files_properties(${lldb_lua_wrapper} PROPERTIES GENERATED ON) 158endif() 159 160set_target_properties(liblldb 161 PROPERTIES 162 VERSION ${LLDB_VERSION} 163) 164 165target_compile_definitions(liblldb PRIVATE LLDB_IN_LIBLLDB) 166if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") 167 if (NOT LLDB_EXPORT_ALL_SYMBOLS) 168 # If we're not exporting all symbols, we'll want to explicitly set 169 # the exported symbols here. This prevents 'log enable --stack ...' 170 # from working on some systems but limits the liblldb size. 171 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb namespace") 172 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports) 173 else() 174 # Don't use an explicit export. Instead, tell the linker to 175 # export all symbols. 176 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces") 177 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports) 178 endif() 179 set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc") 180endif() 181 182if (NOT MSVC) 183 set_target_properties(liblldb 184 PROPERTIES 185 OUTPUT_NAME lldb 186 ) 187endif() 188 189# The Clang expression parser in LLDB requires the Clang resource directory to function. 190if (TARGET clang-resource-headers) 191 # If building alongside Clang, just add a dependency to ensure it is build together with liblldb. 192 add_dependencies(liblldb clang-resource-headers) 193else() 194 # In a standalone build create a symlink from the LLDB library directory that points to the 195 # resource directory in the Clang library directory. LLDB searches relative to its install path, 196 # and the symlink is created in the same relative path as the resource directory of Clang when 197 # building alongside Clang. 198 # When building the LLDB framework, this isn't necessary as there we copy everything we need into 199 # the framework (including the Clang resourece directory). 200 if(NOT LLDB_BUILD_FRAMEWORK) 201 set(LLDB_CLANG_RESOURCE_DIR_PARENT "$<TARGET_FILE_DIR:liblldb>/clang") 202 file(MAKE_DIRECTORY "${LLDB_CLANG_RESOURCE_DIR_PARENT}") 203 add_custom_command(TARGET liblldb POST_BUILD 204 COMMENT "Linking Clang resource dir into LLDB build directory: ${LLDB_CLANG_RESOURCE_DIR_PARENT}" 205 COMMAND ${CMAKE_COMMAND} -E make_directory "${LLDB_CLANG_RESOURCE_DIR_PARENT}" 206 COMMAND ${CMAKE_COMMAND} -E create_symlink "${LLDB_EXTERNAL_CLANG_RESOURCE_DIR}" 207 "${LLDB_CLANG_RESOURCE_DIR_PARENT}/${LLDB_CLANG_RESOURCE_DIR_NAME}" 208 ) 209 endif() 210endif() 211 212if(LLDB_BUILD_FRAMEWORK) 213 include(LLDBFramework) 214 215 if (TARGET install-liblldb) 216 add_dependencies(install-liblldb 217 lldb-framework-cleanup) 218 endif() 219 220 if (TARGET install-liblldb-stripped) 221 add_dependencies(install-liblldb-stripped 222 lldb-framework-cleanup) 223 endif() 224endif() 225