1include_directories(.)
2
3if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
4include_directories(
5  Plugins/Process/Linux
6  Plugins/Process/POSIX
7  )
8endif ()
9
10if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
11include_directories(
12  Plugins/Process/FreeBSD
13  Plugins/Process/POSIX
14  )
15endif ()
16
17add_subdirectory(API)
18add_subdirectory(Breakpoint)
19add_subdirectory(Commands)
20add_subdirectory(Core)
21add_subdirectory(DataFormatters)
22add_subdirectory(Expression)
23add_subdirectory(Host)
24add_subdirectory(Interpreter)
25add_subdirectory(Plugins)
26add_subdirectory(Symbol)
27add_subdirectory(Target)
28add_subdirectory(Utility)
29
30set( LLDB_USED_LIBS
31  lldbAPI
32  lldbBreakpoint
33  lldbCommands
34  lldbDataFormatters
35  lldbHostCommon
36  lldbCore
37  lldbExpression
38  lldbInterpreter
39  lldbSymbol
40  lldbTarget  
41  lldbUtility
42  
43  # Plugins
44  lldbPluginDisassemblerLLVM
45  lldbPluginSymbolFileDWARF
46  lldbPluginSymbolFileSymtab
47  lldbPluginDynamicLoaderStatic
48  lldbPluginDynamicLoaderPosixDYLD
49  
50  lldbPluginObjectFileMachO
51  lldbPluginObjectFileELF
52  lldbPluginSymbolVendorELF
53  lldbPluginObjectContainerBSDArchive
54  lldbPluginObjectContainerMachOArchive
55  lldbPluginProcessGDBRemote  
56  lldbPluginProcessMachCore
57  lldbPluginProcessUtility
58  lldbPluginPlatformGDB
59  lldbPluginPlatformFreeBSD
60  lldbPluginPlatformLinux
61  lldbPluginObjectFileMachO
62  lldbPluginObjectContainerMachOArchive
63  lldbPluginObjectContainerBSDArchive
64  lldbPluginPlatformMacOSX
65  lldbPluginDynamicLoaderMacOSXDYLD
66  lldbPluginUnwindAssemblyInstEmulation
67  lldbPluginUnwindAssemblyX86
68  lldbPluginAppleObjCRuntime
69  lldbPluginCXXItaniumABI
70  lldbPluginABIMacOSX_arm
71  lldbPluginABIMacOSX_i386
72  lldbPluginABISysV_x86_64
73  lldbPluginInstructionARM
74  lldbPluginObjectFilePECOFF
75  lldbPluginOSPython
76  )
77
78# Windows-only libraries
79if ( CMAKE_SYSTEM_NAME MATCHES "Windows" )
80  list(APPEND LLDB_USED_LIBS
81    #lldbHostWindows
82    #lldbPluginPlatformWindows
83    #Ws2_32
84    )
85endif ()
86
87# Linux-only libraries
88if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
89  list(APPEND LLDB_USED_LIBS
90    lldbHostLinux
91    lldbPluginProcessLinux
92    lldbPluginProcessPOSIX
93    lldbPluginProcessElfCore
94    )
95endif ()
96
97# FreeBSD-only libraries
98if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
99  list(APPEND LLDB_USED_LIBS
100    lldbHostFreeBSD
101    lldbPluginProcessFreeBSD
102    lldbPluginProcessPOSIX
103    lldbPluginProcessElfCore
104    )
105endif ()
106
107# Darwin-only libraries
108if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
109  set(LLDB_VERS_GENERATED_FILE ${LLDB_BINARY_DIR}/source/LLDB_vers.c)
110  add_custom_command(OUTPUT ${LLDB_VERS_GENERATED_FILE}
111    COMMAND ${LLDB_SOURCE_DIR}/scripts/generate-vers.pl
112            ${LLDB_SOURCE_DIR}/lldb.xcodeproj/project.pbxproj
113            > ${LLDB_VERS_GENERATED_FILE})
114
115  set_source_files_properties(${LLDB_VERS_GENERATED_FILE} PROPERTIES GENERATED 1)
116  list(APPEND LLDB_USED_LIBS
117    lldbHostMacOSX
118    lldbPluginDynamicLoaderDarwinKernel
119    lldbPluginProcessMacOSXKernel
120    lldbPluginSymbolVendorMacOSX
121    )
122endif()
123
124set( CLANG_USED_LIBS
125  clangAnalysis
126  clangAST
127  clangBasic
128  clangCodeGen
129  clangDriver
130  clangEdit
131  clangFrontend
132  clangLex
133  clangParse
134  clangRewriteCore
135  clangRewriteFrontend
136  clangSema
137  clangSerialization
138  )  
139  
140set( LLDB_SYSTEM_LIBS
141  edit
142  python2.7
143  )
144
145set( LLVM_LINK_COMPONENTS
146  ${LLVM_TARGETS_TO_BUILD}
147  jit
148  interpreter
149  nativecodegen
150  asmparser
151  bitreader
152  bitwriter
153  codegen
154  ipo
155  selectiondag
156  bitreader
157  mc
158  mcjit
159  core
160  mcdisassembler
161  executionengine
162  )
163
164set_source_files_properties(${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp PROPERTIES GENERATED 1)
165set(SHARED_LIBRARY 1)
166
167add_lldb_library(liblldb
168  lldb.cpp
169  lldb-log.cpp
170  ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp
171  ${LLDB_VERS_GENERATED_FILE}
172  )
173set_target_properties(liblldb
174  PROPERTIES
175  OUTPUT_NAME lldb
176  VERSION ${LLDB_VERSION}
177  )
178add_dependencies(liblldb
179  ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp
180  ${LLDB_VERS_GENERATED_FILE}
181  )
182target_link_libraries(liblldb ${LLDB_SYSTEM_LIBS})
183
184# Determine LLDB revision and repository. GetSourceVersion and GetRepositoryPath are shell-scripts, and as
185# such will not work on Windows.
186if ( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" )
187  execute_process(COMMAND ${CMAKE_SOURCE_DIR}/utils/GetSourceVersion ${LLDB_SOURCE_DIR}
188                  OUTPUT_VARIABLE LLDB_REVISION)
189  if ( LLDB_REVISION )
190    string(REGEX REPLACE "(\r?\n)+$" "" LLDB_REVISION ${LLDB_REVISION})
191  endif()
192
193  execute_process(COMMAND ${CMAKE_SOURCE_DIR}/utils/GetRepositoryPath ${LLDB_SOURCE_DIR}
194                  OUTPUT_VARIABLE LLDB_REPOSITORY)
195  if ( LLDB_REPOSITORY )
196    # Replace newline characters with spaces
197    string(REGEX REPLACE "(\r?\n)+" " " LLDB_REPOSITORY ${LLDB_REPOSITORY})
198
199    # Remove trailing spaces
200    string(REGEX REPLACE "(\ )+$" "" LLDB_REPOSITORY ${LLDB_REPOSITORY})
201  endif()
202
203  set_property(
204    SOURCE lldb.cpp
205    PROPERTY COMPILE_DEFINITIONS "LLDB_REVISION=\"${LLDB_REVISION}\"" "LLDB_REPOSITORY=\"${LLDB_REPOSITORY}\"")
206endif ()
207# FIXME: implement svn/git revision and repository parsing solution on Windows. There is an SVN-only
208#        revision parsing solution in tools/clang/lib/Basic/CMakelists.txt.
209
210
211install(TARGETS liblldb
212  LIBRARY DESTINATION lib)
213