-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
159 lines (132 loc) · 5.44 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# If we are not building as a part of LLVM, build LLDB as an
# standalone project, using LLVM as an external library:
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
project(lldb)
cmake_minimum_required(VERSION 2.8)
set(LLDB_PATH_TO_LLVM_SOURCE "" CACHE PATH
"Path to LLVM source code. Not necessary if using an installed LLVM.")
set(LLDB_PATH_TO_LLVM_BUILD "" CACHE PATH
"Path to the directory where LLVM was built or installed.")
set(LLDB_PATH_TO_CLANG_SOURCE "" CACHE PATH
"Path to Clang source code. Not necessary if using an installed Clang.")
set(LLDB_PATH_TO_CLANG_BUILD "" CACHE PATH
"Path to the directory where Clang was built or installed.")
set(LLDB_DISABLE_PYTHON 1 BOOL "Disables the Python scripting integration.")
if (LLDB_PATH_TO_LLVM_SOURCE)
if (NOT EXISTS "${LLDB_PATH_TO_LLVM_SOURCE}/cmake/config-ix.cmake")
message(FATAL_ERROR "Please set LLDB_PATH_TO_LLVM_SOURCE to the root "
"directory of LLVM source code.")
else()
get_filename_component(LLVM_MAIN_SRC_DIR ${LLDB_PATH_TO_LLVM_SOURCE}
ABSOLUTE)
list(APPEND CMAKE_MODULE_PATH "${LLVM_MAIN_SRC_DIR}/cmake/modules")
endif()
endif()
if (LLDB_PATH_TO_CLANG_SOURCE)
get_filename_component(CLANG_MAIN_SRC_DIR ${LLDB_PATH_TO_CLANG_SOURCE}
ABSOLUTE)
endif()
list(APPEND CMAKE_MODULE_PATH "${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake")
get_filename_component(PATH_TO_LLVM_BUILD ${LLDB_PATH_TO_LLVM_BUILD}
ABSOLUTE)
get_filename_component(PATH_TO_CLANG_BUILD ${LLDB_PATH_TO_CLANG_BUILD}
ABSOLUTE)
include(AddLLVM)
include("${LLDB_PATH_TO_LLVM_BUILD}/share/llvm/cmake/LLVMConfig.cmake")
include(HandleLLVMOptions)
set(PACKAGE_VERSION "${LLVM_PACKAGE_VERSION}")
set(LLVM_MAIN_INCLUDE_DIR "${LLVM_MAIN_SRC_DIR}/include")
set(LLVM_BINARY_DIR ${CMAKE_BINARY_DIR})
set(CLANG_MAIN_INCLUDE_DIR "${CLANG_MAIN_SRC_DIR}/include")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories("${PATH_TO_LLVM_BUILD}/include"
"${LLVM_MAIN_INCLUDE_DIR}"
"${PATH_TO_CLANG_BUILD}/include"
"${CLANG_MAIN_INCLUDE_DIR}"
"${CMAKE_CURRENT_SOURCE_DIR}/source")
link_directories("${PATH_TO_LLVM_BUILD}/lib")
link_directories("${PATH_TO_CLANG_BUILD}/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(LLDB_BUILT_STANDALONE 1)
if (LLDB_DISABLE_PYTHON)
add_definitions( -DLLDB_DISABLE_PYTHON )
endif()
endif()
macro(add_lldb_definitions)
# We don't want no semicolons on LLDB_DEFINITIONS:
foreach(arg ${ARGN})
set(LLDB_DEFINITIONS "${LLVM_DEFINITIONS} ${arg}")
endforeach(arg)
add_definitions( ${ARGN} )
endmacro(add_lldb_definitions)
# Disable MSVC warnings
if( MSVC )
add_lldb_definitions(
-wd4018 # Suppress 'warning C4018: '>=' : signed/unsigned mismatch'
-wd4068 # Suppress 'warning C4068: unknown pragma'
-wd4150 # Suppress 'warning C4150: deletion of pointer to incomplete type'
-wd4521 # Suppress 'warning C4521: 'type' : multiple copy constructors specified'
)
endif()
set(LLDB_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(LLDB_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
message(FATAL_ERROR "In-source builds are not allowed. CMake would overwrite "
"the makefiles distributed with LLDB. Please create a directory and run cmake "
"from there, passing the path to this source directory as the last argument. "
"This process created the file `CMakeCache.txt' and the directory "
"`CMakeFiles'. Please delete them.")
endif()
macro(add_lldb_library name)
llvm_process_sources(srcs ${ARGN})
if (MSVC_IDE OR XCODE)
string(REGEX MATCHALL "/[^/]+" split_path ${CMAKE_CURRENT_SOURCE_DIR})
list(GET split_path -1 dir)
file(GLOB_RECURSE headers
../../include/lldb${dir}/*.h)
set(srcs ${srcs} ${headers})
endif()
if (MODULE)
set(libkind MODULE)
elseif (SHARED_LIBRARY)
set(libkind SHARED)
else()
set(libkind)
endif()
add_library(${name} ${libkind} ${srcs})
if (LLVM_COMMON_DEPENDS)
add_dependencies(${name} ${LLVM_COMMON_DEPENDS})
endif()
target_link_libraries(${name} ${LLVM_USED_LIBS})
llvm_config(${name} ${LLVM_LINK_COMPONENTS})
target_link_libraries(${name} ${LLVM_COMMON_LIBS})
#target_link_libraries(${name} ${CLANG_USED_LIBS})
link_system_libs(${name})
install(TARGETS ${name}
LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
set_target_properties(${name} PROPERTIES FOLDER "lldb libraries")
endmacro(add_lldb_library)
macro(add_lldb_executable name)
add_llvm_executable(${name} ${ARGN})
target_link_libraries(${name} ${LLDB_USED_LIBS})
target_link_libraries(${name} ${CLANG_USED_LIBS})
set_target_properties(${name} PROPERTIES FOLDER "lldb executables")
endmacro(add_lldb_executable)
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)
install(DIRECTORY include/
DESTINATION include
FILES_MATCHING
PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
#add_subdirectory(include)
#add_subdirectory(scripts)
add_subdirectory(source)
#add_subdirectory(test)
add_subdirectory(tools)