blob: 8b47495e89894fcc01e05cb130ce45fcf2f9a7c6 [file] [log] [blame]
Zachary Turner7513e822015-02-17 22:20:20 +00001if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
Zachary Turner030b8cb2015-02-24 22:17:57 +00002 add_definitions( -DEXPORT_LIBLLDB )
Zachary Turner7513e822015-02-17 22:20:20 +00003endif()
4
Zachary Turner799770c2015-03-18 16:56:24 +00005# 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
Chris Bienemand3199f52016-09-21 21:02:16 +00009option(LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off)
10
11if (LLDB_BUILD_FRAMEWORK AND NOT APPLE)
12 message(FATAL_ERROR "LLDB.framework cannot be generated unless targeting Apple platforms.")
13endif()
14
Zachary Turner799770c2015-03-18 16:56:24 +000015add_lldb_library(liblldb SHARED
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000016 SBAddress.cpp
Oleksiy Vyalov71d08b32015-02-16 00:04:19 +000017 SBAttachInfo.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000018 SBBlock.cpp
19 SBBreakpoint.cpp
20 SBBreakpointLocation.cpp
21 SBBroadcaster.cpp
22 SBCommandInterpreter.cpp
23 SBCommandReturnObject.cpp
24 SBCommunication.cpp
25 SBCompileUnit.cpp
26 SBData.cpp
27 SBDebugger.cpp
28 SBDeclaration.cpp
29 SBError.cpp
30 SBEvent.cpp
Chandler Carruthb8a4ecb2014-10-01 21:33:28 +000031 SBExecutionContext.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000032 SBExpressionOptions.cpp
33 SBFileSpec.cpp
34 SBFileSpecList.cpp
35 SBFrame.cpp
36 SBFunction.cpp
37 SBHostOS.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000038 SBInstruction.cpp
39 SBInstructionList.cpp
Ilia K7f836242015-04-28 12:51:16 +000040 SBLanguageRuntime.cpp
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +000041 SBLaunchInfo.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000042 SBLineEntry.cpp
43 SBListener.cpp
Howard Hellyer260368432016-06-23 08:35:37 +000044 SBMemoryRegionInfo.cpp
45 SBMemoryRegionInfoList.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000046 SBModule.cpp
47 SBModuleSpec.cpp
Ed Maste53414042013-11-21 14:38:22 +000048 SBPlatform.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000049 SBProcess.cpp
Jason Molenda5e8dce42013-12-13 00:29:16 +000050 SBQueue.cpp
51 SBQueueItem.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000052 SBSection.cpp
53 SBSourceManager.cpp
54 SBStream.cpp
55 SBStringList.cpp
Todd Fiala75930012016-08-19 04:21:48 +000056 SBStructuredData.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000057 SBSymbol.cpp
58 SBSymbolContext.cpp
59 SBSymbolContextList.cpp
60 SBTarget.cpp
61 SBThread.cpp
Kuba Breckaaaa0b812014-09-06 01:22:55 +000062 SBThreadCollection.cpp
Todd Fiala8a3716b2014-09-30 15:58:56 +000063 SBThreadPlan.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000064 SBType.cpp
65 SBTypeCategory.cpp
Todd Fiala732215f2014-06-02 20:55:29 +000066 SBTypeEnumMember.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000067 SBTypeFilter.cpp
68 SBTypeFormat.cpp
69 SBTypeNameSpecifier.cpp
70 SBTypeSummary.cpp
71 SBTypeSynthetic.cpp
72 SBValue.cpp
73 SBValueList.cpp
Zachary Turner51f96ee2015-02-17 17:55:50 +000074 SBVariablesOptions.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000075 SBWatchpoint.cpp
Todd Fiala802dc4022014-06-23 19:30:49 +000076 SBUnixSignals.cpp
Zachary Turnere6e2bb32015-03-31 21:03:22 +000077 SystemInitializerFull.cpp
Zachary Turner799770c2015-03-18 16:56:24 +000078 ${LLDB_WRAP_PYTHON}
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000079 )
Zachary Turner799770c2015-03-18 16:56:24 +000080
Zachary Turnerd6ef2842016-10-05 17:07:16 +000081if (LLVM_ENABLE_WERROR)
82 if (MSVC)
83 set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
84 else()
85 set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
86 endif()
87endif()
88
Zachary Turner2c1f46d2015-07-30 20:28:07 +000089# This should not be part of LLDBDependencies.cmake, because we don't
90# want every single library taking a dependency on the script interpreters.
91target_link_libraries(liblldb PRIVATE
92 lldbPluginScriptInterpreterNone
93 lldbPluginScriptInterpreterPython
94 )
95
Zachary Turner799770c2015-03-18 16:56:24 +000096set_target_properties(liblldb
97 PROPERTIES
98 VERSION ${LLDB_VERSION}
99 )
100
Bruce Mitchener3921fc72015-09-04 00:00:41 +0000101if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
Todd Fialad6f84062015-10-14 14:52:15 +0000102 if (NOT LLDB_EXPORT_ALL_SYMBOLS)
103 # If we're not exporting all symbols, we'll want to explicitly set
104 # the exported symbols here. This prevents 'log enable --stack ...'
105 # from working on some systems but limits the liblldb size.
Todd Fialafe68f092016-10-29 00:29:15 +0000106 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb namespace")
Todd Fialad6f84062015-10-14 14:52:15 +0000107 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
108 else()
109 # Don't use an explicit export. Instead, tell the linker to
110 # export all symbols.
Todd Fialafe68f092016-10-29 00:29:15 +0000111 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces")
112 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
Todd Fialad6f84062015-10-14 14:52:15 +0000113 endif()
Bruce Mitchener3921fc72015-09-04 00:00:41 +0000114endif()
115
Zachary Turner799770c2015-03-18 16:56:24 +0000116if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
117 # Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs,
118 # so only it needs to explicitly link against ${PYTHON_LIBRARY}
119 if (MSVC AND NOT LLDB_DISABLE_PYTHON)
120 target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARY})
121 endif()
122else()
123 set_target_properties(liblldb
124 PROPERTIES
125 OUTPUT_NAME lldb
126 )
127endif()
128
Bruce Mitchener6ec5d612015-10-09 03:40:55 +0000129if (LLDB_WRAP_PYTHON)
Zachary Turner799770c2015-03-18 16:56:24 +0000130 add_dependencies(liblldb swig_wrapper)
131endif()
Pavel Labath2f430a12016-08-17 11:55:50 +0000132target_link_libraries(liblldb PRIVATE ${LLDB_SYSTEM_LIBS})
Zachary Turner799770c2015-03-18 16:56:24 +0000133
Chris Bienemand3199f52016-09-21 21:02:16 +0000134if(LLDB_BUILD_FRAMEWORK)
Chris Bieneman9a6502f2016-10-14 17:09:55 +0000135 file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
Chris Bienemand3199f52016-09-21 21:02:16 +0000136 set_target_properties(liblldb PROPERTIES
137 OUTPUT_NAME LLDB
138 FRAMEWORK On
139 FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
Chris Bieneman9a6502f2016-10-14 17:09:55 +0000140 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}
141 PUBLIC_HEADER "${public_headers}")
142
143 # This works around a CMake bug where POST_BUILD steps are not applied to
144 # framework targets. This fix is merged into the CMake release branch and
145 # should be available with CMake 3.7 rc2:
146 # https://gitlab.kitware.com/cmake/cmake/issues/16363
147 if(CMAKE_VERSION VERSION_GREATER 3.6.99)
148 add_custom_command(TARGET liblldb POST_BUILD
149 COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLDB_SOURCE_DIR}/include/lldb/API $<TARGET_FILE_DIR:liblldb>/Headers)
150 else()
151 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Headers
152 COMMAND ${CMAKE_COMMAND} -E create_symlink ${LLDB_SOURCE_DIR}/include/lldb/API $<TARGET_FILE_DIR:liblldb>/Headers)
153 add_custom_target(lldb_header_symlink
154 DEPENDS ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Versions/${LLDB_FRAMEWORK_VERSION}/Headers)
155 endif()
Chris Bienemand3199f52016-09-21 21:02:16 +0000156endif()
157