1if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) 2 add_definitions( -DEXPORT_LIBLLDB ) 3endif() 4 5# Include this so that add_lldb_library() has the list of dependencies 6# for liblldb to link against 7include(${LLDB_PROJECT_ROOT}/cmake/LLDBDependencies.cmake) 8 9option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off) 10 11if(LLDB_BUILD_FRAMEWORK AND CMAKE_VERSION VERSION_LESS 3.7) 12 message(FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7") 13endif() 14 15if (LLDB_BUILD_FRAMEWORK AND NOT APPLE) 16 message(FATAL_ERROR "LLDB.framework cannot be generated unless targeting Apple platforms.") 17endif() 18 19get_property(LLDB_ALL_PLUGINS GLOBAL PROPERTY LLDB_PLUGINS) 20 21add_lldb_library(liblldb SHARED 22 SBAddress.cpp 23 SBAttachInfo.cpp 24 SBBlock.cpp 25 SBBreakpoint.cpp 26 SBBreakpointLocation.cpp 27 SBBroadcaster.cpp 28 SBCommandInterpreter.cpp 29 SBCommandReturnObject.cpp 30 SBCommunication.cpp 31 SBCompileUnit.cpp 32 SBData.cpp 33 SBDebugger.cpp 34 SBDeclaration.cpp 35 SBError.cpp 36 SBEvent.cpp 37 SBExecutionContext.cpp 38 SBExpressionOptions.cpp 39 SBFileSpec.cpp 40 SBFileSpecList.cpp 41 SBFrame.cpp 42 SBFunction.cpp 43 SBHostOS.cpp 44 SBInstruction.cpp 45 SBInstructionList.cpp 46 SBLanguageRuntime.cpp 47 SBLaunchInfo.cpp 48 SBLineEntry.cpp 49 SBListener.cpp 50 SBMemoryRegionInfo.cpp 51 SBMemoryRegionInfoList.cpp 52 SBModule.cpp 53 SBModuleSpec.cpp 54 SBPlatform.cpp 55 SBProcess.cpp 56 SBQueue.cpp 57 SBQueueItem.cpp 58 SBSection.cpp 59 SBSourceManager.cpp 60 SBStream.cpp 61 SBStringList.cpp 62 SBStructuredData.cpp 63 SBSymbol.cpp 64 SBSymbolContext.cpp 65 SBSymbolContextList.cpp 66 SBTarget.cpp 67 SBThread.cpp 68 SBThreadCollection.cpp 69 SBThreadPlan.cpp 70 SBTrace.cpp 71 SBTraceOptions.cpp 72 SBType.cpp 73 SBTypeCategory.cpp 74 SBTypeEnumMember.cpp 75 SBTypeFilter.cpp 76 SBTypeFormat.cpp 77 SBTypeNameSpecifier.cpp 78 SBTypeSummary.cpp 79 SBTypeSynthetic.cpp 80 SBValue.cpp 81 SBValueList.cpp 82 SBVariablesOptions.cpp 83 SBWatchpoint.cpp 84 SBUnixSignals.cpp 85 SystemInitializerFull.cpp 86 ${LLDB_WRAP_PYTHON} 87 88 LINK_LIBS 89 lldbBase 90 lldbBreakpoint 91 lldbCore 92 lldbDataFormatters 93 lldbExpression 94 lldbHost 95 lldbInitialization 96 lldbInterpreter 97 lldbSymbol 98 lldbTarget 99 lldbUtility 100 ${LLDB_ALL_PLUGINS} 101 LINK_COMPONENTS 102 Support 103 ) 104 105if (LLVM_ENABLE_WERROR) 106 if (MSVC) 107 set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0") 108 else() 109 set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w") 110 endif() 111endif() 112 113# This should not be part of LLDBDependencies.cmake, because we don't 114# want every single library taking a dependency on the script interpreters. 115target_link_libraries(liblldb PRIVATE 116 lldbPluginScriptInterpreterNone 117 lldbPluginScriptInterpreterPython 118 ) 119 120set_target_properties(liblldb 121 PROPERTIES 122 VERSION ${LLDB_VERSION} 123 ) 124 125if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") 126 if (NOT LLDB_EXPORT_ALL_SYMBOLS) 127 # If we're not exporting all symbols, we'll want to explicitly set 128 # the exported symbols here. This prevents 'log enable --stack ...' 129 # from working on some systems but limits the liblldb size. 130 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb namespace") 131 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports) 132 else() 133 # Don't use an explicit export. Instead, tell the linker to 134 # export all symbols. 135 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces") 136 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports) 137 endif() 138endif() 139 140if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) 141 # Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs, 142 # so only it needs to explicitly link against ${PYTHON_LIBRARY} 143 if (MSVC AND NOT LLDB_DISABLE_PYTHON) 144 target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARY}) 145 endif() 146else() 147 set_target_properties(liblldb 148 PROPERTIES 149 OUTPUT_NAME lldb 150 ) 151endif() 152 153if (LLDB_WRAP_PYTHON) 154 add_dependencies(liblldb swig_wrapper) 155endif() 156target_link_libraries(liblldb PRIVATE ${LLDB_SYSTEM_LIBS}) 157 158if(LLDB_BUILD_FRAMEWORK) 159 file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h) 160 set_target_properties(liblldb PROPERTIES 161 OUTPUT_NAME LLDB 162 FRAMEWORK On 163 FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION} 164 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR} 165 PUBLIC_HEADER "${public_headers}") 166 167 add_custom_command(TARGET liblldb POST_BUILD 168 COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:liblldb>/Versions/${LLDB_FRAMEWORK_VERSION} 169 COMMAND ${CMAKE_COMMAND} -E copy_directory ${LLDB_SOURCE_DIR}/include/lldb/API $<TARGET_FILE_DIR:liblldb>/Headers 170 COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Headers 171 COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLDB_VERSION} $<TARGET_FILE_DIR:liblldb>/Resources/Clang 172 ) 173endif() 174 175