blob: 7e1e66bee3b20f2351311525fdf58ba69826911c [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
Chris Bieneman679d02f2016-12-15 18:18:47 +000011if(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
Chris Bienemand3199f52016-09-21 21:02:16 +000015if (LLDB_BUILD_FRAMEWORK AND NOT APPLE)
16 message(FATAL_ERROR "LLDB.framework cannot be generated unless targeting Apple platforms.")
17endif()
18
Zachary Turner799770c2015-03-18 16:56:24 +000019add_lldb_library(liblldb SHARED
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000020 SBAddress.cpp
Oleksiy Vyalov71d08b32015-02-16 00:04:19 +000021 SBAttachInfo.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000022 SBBlock.cpp
23 SBBreakpoint.cpp
24 SBBreakpointLocation.cpp
25 SBBroadcaster.cpp
26 SBCommandInterpreter.cpp
27 SBCommandReturnObject.cpp
28 SBCommunication.cpp
29 SBCompileUnit.cpp
30 SBData.cpp
31 SBDebugger.cpp
32 SBDeclaration.cpp
33 SBError.cpp
34 SBEvent.cpp
Chandler Carruthb8a4ecb2014-10-01 21:33:28 +000035 SBExecutionContext.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000036 SBExpressionOptions.cpp
37 SBFileSpec.cpp
38 SBFileSpecList.cpp
39 SBFrame.cpp
40 SBFunction.cpp
41 SBHostOS.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000042 SBInstruction.cpp
43 SBInstructionList.cpp
Ilia K7f836242015-04-28 12:51:16 +000044 SBLanguageRuntime.cpp
Oleksiy Vyalov1ef7b2c2015-02-04 23:19:15 +000045 SBLaunchInfo.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000046 SBLineEntry.cpp
47 SBListener.cpp
Howard Hellyer260368432016-06-23 08:35:37 +000048 SBMemoryRegionInfo.cpp
49 SBMemoryRegionInfoList.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000050 SBModule.cpp
51 SBModuleSpec.cpp
Ed Maste53414042013-11-21 14:38:22 +000052 SBPlatform.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000053 SBProcess.cpp
Jason Molenda5e8dce42013-12-13 00:29:16 +000054 SBQueue.cpp
55 SBQueueItem.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000056 SBSection.cpp
57 SBSourceManager.cpp
58 SBStream.cpp
59 SBStringList.cpp
Todd Fiala75930012016-08-19 04:21:48 +000060 SBStructuredData.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000061 SBSymbol.cpp
62 SBSymbolContext.cpp
63 SBSymbolContextList.cpp
64 SBTarget.cpp
65 SBThread.cpp
Kuba Breckaaaa0b812014-09-06 01:22:55 +000066 SBThreadCollection.cpp
Todd Fiala8a3716b2014-09-30 15:58:56 +000067 SBThreadPlan.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000068 SBType.cpp
69 SBTypeCategory.cpp
Todd Fiala732215f2014-06-02 20:55:29 +000070 SBTypeEnumMember.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000071 SBTypeFilter.cpp
72 SBTypeFormat.cpp
73 SBTypeNameSpecifier.cpp
74 SBTypeSummary.cpp
75 SBTypeSynthetic.cpp
76 SBValue.cpp
77 SBValueList.cpp
Zachary Turner51f96ee2015-02-17 17:55:50 +000078 SBVariablesOptions.cpp
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000079 SBWatchpoint.cpp
Todd Fiala802dc4022014-06-23 19:30:49 +000080 SBUnixSignals.cpp
Zachary Turnere6e2bb32015-03-31 21:03:22 +000081 SystemInitializerFull.cpp
Zachary Turner799770c2015-03-18 16:56:24 +000082 ${LLDB_WRAP_PYTHON}
Joerg Sonnenberger340a1752013-09-25 10:37:32 +000083 )
Zachary Turner799770c2015-03-18 16:56:24 +000084
Zachary Turnerd6ef2842016-10-05 17:07:16 +000085if (LLVM_ENABLE_WERROR)
86 if (MSVC)
87 set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " /W0")
88 else()
89 set_property(SOURCE ${LLDB_WRAP_PYTHON} APPEND_STRING PROPERTY COMPILE_FLAGS " -w")
90 endif()
91endif()
92
Zachary Turner2c1f46d2015-07-30 20:28:07 +000093# This should not be part of LLDBDependencies.cmake, because we don't
94# want every single library taking a dependency on the script interpreters.
95target_link_libraries(liblldb PRIVATE
96 lldbPluginScriptInterpreterNone
97 lldbPluginScriptInterpreterPython
98 )
99
Zachary Turner799770c2015-03-18 16:56:24 +0000100set_target_properties(liblldb
101 PROPERTIES
102 VERSION ${LLDB_VERSION}
103 )
104
Bruce Mitchener3921fc72015-09-04 00:00:41 +0000105if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
Todd Fialad6f84062015-10-14 14:52:15 +0000106 if (NOT LLDB_EXPORT_ALL_SYMBOLS)
107 # If we're not exporting all symbols, we'll want to explicitly set
108 # the exported symbols here. This prevents 'log enable --stack ...'
109 # from working on some systems but limits the liblldb size.
Todd Fialafe68f092016-10-29 00:29:15 +0000110 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb namespace")
Todd Fialad6f84062015-10-14 14:52:15 +0000111 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb.exports)
112 else()
113 # Don't use an explicit export. Instead, tell the linker to
114 # export all symbols.
Todd Fialafe68f092016-10-29 00:29:15 +0000115 MESSAGE("-- Symbols (liblldb): exporting all symbols from the lldb and lldb_private namespaces")
116 add_llvm_symbol_exports(liblldb ${CMAKE_CURRENT_SOURCE_DIR}/liblldb-private.exports)
Todd Fialad6f84062015-10-14 14:52:15 +0000117 endif()
Bruce Mitchener3921fc72015-09-04 00:00:41 +0000118endif()
119
Zachary Turner799770c2015-03-18 16:56:24 +0000120if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
121 # Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs,
122 # so only it needs to explicitly link against ${PYTHON_LIBRARY}
123 if (MSVC AND NOT LLDB_DISABLE_PYTHON)
124 target_link_libraries(liblldb PRIVATE ${PYTHON_LIBRARY})
125 endif()
126else()
127 set_target_properties(liblldb
128 PROPERTIES
129 OUTPUT_NAME lldb
130 )
131endif()
132
Bruce Mitchener6ec5d612015-10-09 03:40:55 +0000133if (LLDB_WRAP_PYTHON)
Zachary Turner799770c2015-03-18 16:56:24 +0000134 add_dependencies(liblldb swig_wrapper)
135endif()
Pavel Labath2f430a12016-08-17 11:55:50 +0000136target_link_libraries(liblldb PRIVATE ${LLDB_SYSTEM_LIBS})
Zachary Turner799770c2015-03-18 16:56:24 +0000137
Chris Bienemand3199f52016-09-21 21:02:16 +0000138if(LLDB_BUILD_FRAMEWORK)
Chris Bieneman9a6502f2016-10-14 17:09:55 +0000139 file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
Chris Bienemand3199f52016-09-21 21:02:16 +0000140 set_target_properties(liblldb PROPERTIES
141 OUTPUT_NAME LLDB
142 FRAMEWORK On
143 FRAMEWORK_VERSION ${LLDB_FRAMEWORK_VERSION}
Chris Bieneman9a6502f2016-10-14 17:09:55 +0000144 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}
145 PUBLIC_HEADER "${public_headers}")
146
Chris Bieneman679d02f2016-12-15 18:18:47 +0000147 add_custom_command(TARGET liblldb POST_BUILD
148 COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_FILE_DIR:liblldb>/Versions/${LLDB_FRAMEWORK_VERSION}
149 COMMAND ${CMAKE_COMMAND} -E copy_directory ${LLDB_SOURCE_DIR}/include/lldb/API $<TARGET_FILE_DIR:liblldb>/Headers
Chris Bienemanb9fc4722016-10-31 22:31:07 +0000150 COMMAND ${CMAKE_COMMAND} -E create_symlink Versions/Current/Headers ${CMAKE_BINARY_DIR}/${LLDB_FRAMEWORK_INSTALL_DIR}/LLDB.framework/Headers
Chris Bieneman679d02f2016-12-15 18:18:47 +0000151 COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/clang/${LLDB_VERSION} $<TARGET_FILE_DIR:liblldb>/Resources/Clang
Chris Bienemanb9fc4722016-10-31 22:31:07 +0000152 )
Chris Bienemand3199f52016-09-21 21:02:16 +0000153endif()
154