207
|
1 cmake_minimum_required(VERSION 3.13.4)
|
150
|
2
|
|
3 # Add path for custom modules.
|
|
4 set(CMAKE_MODULE_PATH
|
|
5 ${CMAKE_MODULE_PATH}
|
|
6 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
7 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
|
|
8 )
|
|
9
|
|
10 # If we are not building as part of LLVM, build LLDB as a standalone project,
|
|
11 # using LLVM as an external library.
|
|
12 if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
|
|
13 project(lldb)
|
|
14 include(LLDBStandalone)
|
|
15
|
|
16 set(CMAKE_CXX_STANDARD 14 CACHE STRING "C++ standard to conform to")
|
|
17 set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
|
18 set(CMAKE_CXX_EXTENSIONS NO)
|
|
19 endif()
|
|
20
|
|
21 include(LLDBConfig)
|
|
22 include(AddLLDB)
|
|
23
|
|
24 # Define the LLDB_CONFIGURATION_xxx matching the build type.
|
207
|
25 if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
|
|
26 add_definitions(-DLLDB_CONFIGURATION_DEBUG)
|
150
|
27 endif()
|
|
28
|
|
29 if (WIN32)
|
|
30 add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
|
|
31 endif()
|
|
32
|
|
33 if (LLDB_ENABLE_PYTHON)
|
207
|
34 if (NOT CMAKE_CROSSCOMPILING)
|
|
35 execute_process(
|
|
36 COMMAND ${Python3_EXECUTABLE}
|
|
37 -c "import distutils.sysconfig; print(distutils.sysconfig.get_python_lib(True, False, ''))"
|
|
38 OUTPUT_VARIABLE LLDB_PYTHON_DEFAULT_RELATIVE_PATH
|
|
39 OUTPUT_STRIP_TRAILING_WHITESPACE)
|
150
|
40
|
207
|
41 file(TO_CMAKE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} LLDB_PYTHON_DEFAULT_RELATIVE_PATH)
|
|
42 else ()
|
|
43 if ("${LLDB_PYTHON_RELATIVE_PATH}" STREQUAL "")
|
|
44 message(FATAL_ERROR
|
|
45 "Crosscompiling LLDB with Python requires manually setting
|
|
46 LLDB_PYTHON_RELATIVE_PATH.")
|
|
47 endif ()
|
|
48 endif ()
|
|
49
|
150
|
50 set(LLDB_PYTHON_RELATIVE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH}
|
|
51 CACHE STRING "Path where Python modules are installed, relative to install prefix")
|
|
52 endif ()
|
|
53
|
|
54 if (LLDB_ENABLE_PYTHON OR LLDB_ENABLE_LUA)
|
|
55 add_subdirectory(bindings)
|
|
56 endif ()
|
|
57
|
|
58 # We need the headers generated by instrinsics_gen before we can compile
|
|
59 # any source file in LLDB as the imported Clang modules might include
|
|
60 # some of these generated headers. This approach is copied from Clang's main
|
|
61 # CMakeLists.txt, so it should kept in sync the code in Clang which was added
|
|
62 # in llvm-svn 308844.
|
207
|
63 if(LLVM_ENABLE_MODULES)
|
150
|
64 list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
|
|
65 endif()
|
|
66
|
|
67 if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE)
|
|
68 set(LLVM_USE_HOST_TOOLS ON)
|
|
69 include(CrossCompile)
|
|
70 if (NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR)
|
|
71 message(FATAL_ERROR
|
|
72 "Crosscompiling standalone requires the variables NATIVE_{CLANG,LLVM}_DIR
|
|
73 for building the native lldb-tblgen used during the build process.")
|
|
74 endif()
|
|
75 llvm_create_cross_target(lldb NATIVE "" Release
|
|
76 -DLLVM_DIR=${NATIVE_LLVM_DIR}
|
|
77 -DClang_DIR=${NATIVE_Clang_DIR})
|
|
78 endif()
|
|
79
|
|
80 # TableGen
|
|
81 add_subdirectory(utils/TableGen)
|
|
82
|
|
83 add_subdirectory(source)
|
|
84 add_subdirectory(tools)
|
|
85 add_subdirectory(docs)
|
|
86
|
207
|
87 if (LLDB_ENABLE_PYTHON)
|
|
88 if(LLDB_BUILD_FRAMEWORK)
|
|
89 set(lldb_python_target_dir "${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}/LLDB.framework/Resources/Python/lldb")
|
|
90 else()
|
|
91 set(lldb_python_target_dir "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_PYTHON_RELATIVE_PATH}/lldb")
|
|
92 endif()
|
|
93 get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR)
|
|
94 finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}")
|
|
95 endif()
|
|
96
|
150
|
97 option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
|
|
98 if(LLDB_INCLUDE_TESTS)
|
|
99 add_subdirectory(test)
|
|
100 add_subdirectory(unittests)
|
|
101 add_subdirectory(utils)
|
|
102 endif()
|
|
103
|
|
104 if(LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE)
|
|
105 llvm_distribution_add_targets()
|
|
106 endif()
|