Louis Dionne | afa1afd | 2020-04-22 15:15:05 | [diff] [blame] | 1 | cmake_minimum_required(VERSION 3.13.4) |
Pavel Labath | 6512cad | 2015-07-17 15:50:48 | [diff] [blame] | 2 | |
Konrad Kleine | 0e79947 | 2019-05-22 13:23:15 | [diff] [blame] | 3 | # Add path for custom modules. |
Chris Bieneman | 2246972 | 2017-04-27 16:04:26 | [diff] [blame] | 4 | set(CMAKE_MODULE_PATH |
| 5 | ${CMAKE_MODULE_PATH} |
| 6 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake" |
| 7 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" |
| 8 | ) |
| 9 | |
Jonas Devlieghere | 7f24757 | 2019-07-17 16:47:02 | [diff] [blame] | 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) |
Haibo Huang | 79d117f | 2019-07-29 23:09:31 | [diff] [blame] | 13 | project(lldb) |
Jonas Devlieghere | 7f24757 | 2019-07-17 16:47:02 | [diff] [blame] | 14 | include(LLDBStandalone) |
Saleem Abdulrasool | e56ba374 | 2019-10-29 15:24:10 | [diff] [blame] | 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) |
Jonas Devlieghere | 7f24757 | 2019-07-17 16:47:02 | [diff] [blame] | 19 | endif() |
| 20 | |
Chris Bieneman | 2246972 | 2017-04-27 16:04:26 | [diff] [blame] | 21 | include(LLDBConfig) |
| 22 | include(AddLLDB) |
Todd Fiala | b6ee2f8 | 2014-05-28 17:06:04 | [diff] [blame] | 23 | |
Konrad Kleine | 0e79947 | 2019-05-22 13:23:15 | [diff] [blame] | 24 | # Define the LLDB_CONFIGURATION_xxx matching the build type. |
Jonas Devlieghere | a22301e | 2020-08-11 05:45:23 | [diff] [blame] | 25 | if(uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" ) |
| 26 | add_definitions(-DLLDB_CONFIGURATION_DEBUG) |
Chris Bieneman | e142631 | 2017-07-28 15:39:50 | [diff] [blame] | 27 | endif() |
| 28 | |
Jonas Devlieghere | 9d0c5f9 | 2019-02-12 00:30:21 | [diff] [blame] | 29 | if (WIN32) |
| 30 | add_definitions(-D_ENABLE_EXTENDED_ALIGNED_STORAGE) |
| 31 | endif() |
| 32 | |
Jonas Devlieghere | 4e26cf2 | 2019-12-13 18:37:33 | [diff] [blame] | 33 | if (LLDB_ENABLE_PYTHON) |
Martin Storsjö | 3f03877 | 2021-05-05 10:26:56 | [diff] [blame] | 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) |
Haibo Huang | 61f471a | 2019-10-07 23:49:01 | [diff] [blame] | 40 | |
Martin Storsjö | 3f03877 | 2021-05-05 10:26:56 | [diff] [blame] | 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 | |
Haibo Huang | 61f471a | 2019-10-07 23:49:01 | [diff] [blame] | 50 | set(LLDB_PYTHON_RELATIVE_PATH ${LLDB_PYTHON_DEFAULT_RELATIVE_PATH} |
| 51 | CACHE STRING "Path where Python modules are installed, relative to install prefix") |
Todd Fiala | 8422c5a | 2014-07-04 06:43:47 | [diff] [blame] | 52 | endif () |
Raphael Isemann | 6f4fb4e | 2019-07-12 15:30:55 | [diff] [blame] | 53 | |
Martin Storsjö | 9a3fab9 | 2019-12-22 08:01:09 | [diff] [blame] | 54 | if (LLDB_ENABLE_PYTHON OR LLDB_ENABLE_LUA) |
Jonas Devlieghere | 6498aff | 2020-01-09 15:57:59 | [diff] [blame] | 55 | add_subdirectory(bindings) |
Martin Storsjö | 9a3fab9 | 2019-12-22 08:01:09 | [diff] [blame] | 56 | endif () |
Jonas Devlieghere | bf03e17 | 2019-12-08 23:32:57 | [diff] [blame] | 57 | |
Raphael Isemann | 5c5408ce | 2019-08-15 07:29:53 | [diff] [blame] | 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. |
Michele Scandale | 53880b8 | 2020-07-17 23:43:05 | [diff] [blame] | 63 | if(LLVM_ENABLE_MODULES) |
Raphael Isemann | 5c5408ce | 2019-08-15 07:29:53 | [diff] [blame] | 64 | list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen) |
| 65 | endif() |
| 66 | |
Manoj Gupta | 1f7b25ea | 2021-08-13 20:25:14 | [diff] [blame^] | 67 | if(CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE AND NOT LLDB_TABLEGEN_EXE) |
Nathan Lanza | 0c6ad3d | 2019-07-18 00:21:57 | [diff] [blame] | 68 | set(LLVM_USE_HOST_TOOLS ON) |
| 69 | include(CrossCompile) |
Nathan Lanza | 01eb3ab | 2019-07-18 23:40:23 | [diff] [blame] | 70 | if (NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR) |
Nathan Lanza | 0c6ad3d | 2019-07-18 00:21:57 | [diff] [blame] | 71 | message(FATAL_ERROR |
Nathan Lanza | 01eb3ab | 2019-07-18 23:40:23 | [diff] [blame] | 72 | "Crosscompiling standalone requires the variables NATIVE_{CLANG,LLVM}_DIR |
Nathan Lanza | 0c6ad3d | 2019-07-18 00:21:57 | [diff] [blame] | 73 | for building the native lldb-tblgen used during the build process.") |
| 74 | endif() |
| 75 | llvm_create_cross_target(lldb NATIVE "" Release |
Nathan Lanza | 01eb3ab | 2019-07-18 23:40:23 | [diff] [blame] | 76 | -DLLVM_DIR=${NATIVE_LLVM_DIR} |
| 77 | -DClang_DIR=${NATIVE_Clang_DIR}) |
Nathan Lanza | 0c6ad3d | 2019-07-18 00:21:57 | [diff] [blame] | 78 | endif() |
| 79 | |
Jonas Devlieghere | 7070a0b | 2019-07-26 18:14:04 | [diff] [blame] | 80 | # TableGen |
Raphael Isemann | 6f4fb4e | 2019-07-12 15:30:55 | [diff] [blame] | 81 | add_subdirectory(utils/TableGen) |
Jonas Devlieghere | 7070a0b | 2019-07-26 18:14:04 | [diff] [blame] | 82 | |
Joerg Sonnenberger | 340a175 | 2013-09-25 10:37:32 | [diff] [blame] | 83 | add_subdirectory(source) |
Joerg Sonnenberger | 340a175 | 2013-09-25 10:37:32 | [diff] [blame] | 84 | add_subdirectory(tools) |
Jonas Devlieghere | 8c3513f | 2019-04-29 16:29:10 | [diff] [blame] | 85 | add_subdirectory(docs) |
Chris Bieneman | cc59060 | 2017-10-06 22:21:36 | [diff] [blame] | 86 | |
Jonas Devlieghere | c135744 | 2020-08-11 15:43:44 | [diff] [blame] | 87 | if (LLDB_ENABLE_PYTHON) |
Jonas Devlieghere | 9a3dbc9 | 2020-07-30 00:56:38 | [diff] [blame] | 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() |
Jonas Devlieghere | c135744 | 2020-08-11 15:43:44 | [diff] [blame] | 93 | get_target_property(lldb_python_bindings_dir swig_wrapper_python BINARY_DIR) |
António Afonso | 5238193 | 2020-08-22 18:53:08 | [diff] [blame] | 94 | finish_swig_python("lldb-python" "${lldb_python_bindings_dir}" "${lldb_python_target_dir}") |
Jonas Devlieghere | 9a3dbc9 | 2020-07-30 00:56:38 | [diff] [blame] | 95 | endif() |
| 96 | |
Stefan Granitz | bb3df52 | 2019-01-11 18:11:04 | [diff] [blame] | 97 | option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${LLVM_INCLUDE_TESTS}) |
Chris Bieneman | cc59060 | 2017-10-06 22:21:36 | [diff] [blame] | 98 | if(LLDB_INCLUDE_TESTS) |
| 99 | add_subdirectory(test) |
| 100 | add_subdirectory(unittests) |
Jonas Devlieghere | e1f6b68 | 2020-01-17 06:30:03 | [diff] [blame] | 101 | add_subdirectory(utils) |
Chris Bieneman | cc59060 | 2017-10-06 22:21:36 | [diff] [blame] | 102 | endif() |
Zachary Turner | aeda626 | 2015-02-17 22:20:29 | [diff] [blame] | 103 | |
Stefan Granitz | 6454a20 | 2019-07-18 16:44:45 | [diff] [blame] | 104 | if(LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE) |
Stefan Granitz | 05adc0f | 2019-07-10 11:09:11 | [diff] [blame] | 105 | llvm_distribution_add_targets() |
| 106 | endif() |