blob: 594c769141b437538a8e189283af52407c2b6361 [file] [log] [blame]
Louis Dionneafa1afd2020-04-22 15:15:051cmake_minimum_required(VERSION 3.13.4)
Pavel Labath6512cad2015-07-17 15:50:482
Konrad Kleine0e799472019-05-22 13:23:153# Add path for custom modules.
Chris Bieneman22469722017-04-27 16:04:264set(CMAKE_MODULE_PATH
5 ${CMAKE_MODULE_PATH}
6 "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
7 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
8 )
9
Jonas Devlieghere7f247572019-07-17 16:47:0210# If we are not building as part of LLVM, build LLDB as a standalone project,
11# using LLVM as an external library.
12if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
Haibo Huang79d117f2019-07-29 23:09:3113 project(lldb)
Jonas Devlieghere7f247572019-07-17 16:47:0214 include(LLDBStandalone)
Saleem Abdulrasoole56ba3742019-10-29 15:24:1015
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)
Jonas Devlieghere7f247572019-07-17 16:47:0219endif()
20
Chris Bieneman22469722017-04-27 16:04:2621include(LLDBConfig)
22include(AddLLDB)
Todd Fialab6ee2f82014-05-28 17:06:0423
Konrad Kleine0e799472019-05-22 13:23:1524# Define the LLDB_CONFIGURATION_xxx matching the build type.
Jonas Devliegherea22301e2020-08-11 05:45:2325if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
26 add_definitions(-DLLDB_CONFIGURATION_DEBUG)
Chris Bienemane1426312017-07-28 15:39:5027endif()
28
Jonas Devlieghere9d0c5f92019-02-12 00:30:2129if (WIN32)
30 add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE)
31endif()
32
Jonas Devlieghere4e26cf22019-12-13 18:37:3333if (LLDB_ENABLE_PYTHON)
Martin Storsjö3f038772021-05-05 10:26:5634 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)
Haibo Huang61f471a2019-10-07 23:49:0140
Martin Storsjö3f038772021-05-05 10:26:5641 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
Haibo Huang61f471a2019-10-07 23:49:0150 set(LLDB_PYTHON_RELATIVE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH}
51 CACHE STRING "Path where Python modules are installed, relative to install prefix")
Todd Fiala8422c5a2014-07-04 06:43:4752endif ()
Raphael Isemann6f4fb4e2019-07-12 15:30:5553
Martin Storsjö9a3fab92019-12-22 08:01:0954if (LLDB_ENABLE_PYTHON OR LLDB_ENABLE_LUA)
Jonas Devlieghere6498aff2020-01-09 15:57:5955 add_subdirectory(bindings)
Martin Storsjö9a3fab92019-12-22 08:01:0956endif ()
Jonas Devliegherebf03e172019-12-08 23:32:5757
Raphael Isemann5c5408ce2019-08-15 07:29:5358# 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.
Michele Scandale53880b82020-07-17 23:43:0563if(LLVM_ENABLE_MODULES)
Raphael Isemann5c5408ce2019-08-15 07:29:5364 list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
65endif()
66
Manoj Gupta1f7b25ea2021-08-13 20:25:1467if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE AND NOT LLDB_TABLEGEN_EXE)
Nathan Lanza0c6ad3d2019-07-18 00:21:5768 set(LLVM_USE_HOST_TOOLS ON)
69 include(CrossCompile)
Nathan Lanza01eb3ab2019-07-18 23:40:2370 if (NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR)
Nathan Lanza0c6ad3d2019-07-18 00:21:5771 message(FATAL_ERROR
Nathan Lanza01eb3ab2019-07-18 23:40:2372 "Crosscompiling standalone requires the variables NATIVE_{CLANG,LLVM}_DIR
Nathan Lanza0c6ad3d2019-07-18 00:21:5773 for building the native lldb-tblgen used during the build process.")
74 endif()
75 llvm_create_cross_target(lldb NATIVE "" Release
Nathan Lanza01eb3ab2019-07-18 23:40:2376 -DLLVM_DIR=${NATIVE_LLVM_DIR}
77 -DClang_DIR=${NATIVE_Clang_DIR})
Nathan Lanza0c6ad3d2019-07-18 00:21:5778endif()
79
Jonas Devlieghere7070a0b2019-07-26 18:14:0480# TableGen
Raphael Isemann6f4fb4e2019-07-12 15:30:5581add_subdirectory(utils/TableGen)
Jonas Devlieghere7070a0b2019-07-26 18:14:0482
Joerg Sonnenberger340a1752013-09-25 10:37:3283add_subdirectory(source)
Joerg Sonnenberger340a1752013-09-25 10:37:3284add_subdirectory(tools)
Jonas Devlieghere8c3513f2019-04-29 16:29:1085add_subdirectory(docs)
Chris Bienemancc590602017-10-06 22:21:3686
Jonas Devliegherec1357442020-08-11 15:43:4487if (LLDB_ENABLE_PYTHON)
Jonas Devlieghere9a3dbc92020-07-30 00:56:3888 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()
Jonas Devliegherec1357442020-08-11 15:43:4493 get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR)
António Afonso52381932020-08-22 18:53:0894 finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}")
Jonas Devlieghere9a3dbc92020-07-30 00:56:3895endif()
96
Stefan Granitzbb3df522019-01-11 18:11:0497option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS})
Chris Bienemancc590602017-10-06 22:21:3698if(LLDB_INCLUDE_TESTS)
99 add_subdirectory(test)
100 add_subdirectory(unittests)
Jonas Devliegheree1f6b682020-01-17 06:30:03101 add_subdirectory(utils)
Chris Bienemancc590602017-10-06 22:21:36102endif()
Zachary Turneraeda6262015-02-17 22:20:29103
Stefan Granitz6454a202019-07-18 16:44:45104if(LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE)
Stefan Granitz05adc0f2019-07-10 11:09:11105 llvm_distribution_add_targets()
106endif()