2016-06-01 04:21:44 +08:00
cmake_minimum_required ( VERSION 3.4.3 )
2015-07-17 23:50:48 +08:00
2019-02-18 18:09:29 +08:00
if ( POLICY CMP0075 )
cmake_policy ( SET CMP0075 NEW )
endif ( )
2019-05-22 21:23:15 +08:00
# Add path for custom modules.
2017-04-28 00:04:26 +08:00
set ( CMAKE_MODULE_PATH
$ { C M A K E _ M O D U L E _ P A T H }
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e "
" $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / c m a k e / m o d u l e s "
)
2019-07-18 00:47:02 +08:00
# If we are not building as part of LLVM, build LLDB as a standalone project,
# using LLVM as an external library.
if ( CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR )
2019-07-30 07:09:31 +08:00
project ( lldb )
2019-07-18 00:47:02 +08:00
include ( LLDBStandalone )
endif ( )
2017-04-28 00:04:26 +08:00
include ( LLDBConfig )
include ( AddLLDB )
2014-05-29 01:06:04 +08:00
2019-05-22 21:23:15 +08:00
# Define the LLDB_CONFIGURATION_xxx matching the build type.
2017-10-05 04:23:56 +08:00
if ( uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
add_definitions ( -DLLDB_CONFIGURATION_DEBUG )
else ( )
add_definitions ( -DLLDB_CONFIGURATION_RELEASE )
endif ( )
2017-07-28 23:39:50 +08:00
if ( APPLE )
add_definitions ( -DLLDB_USE_OS_LOG )
endif ( )
2019-02-12 08:30:21 +08:00
if ( WIN32 )
add_definitions ( -D_ENABLE_EXTENDED_ALIGNED_STORAGE )
endif ( )
2015-04-07 23:30:23 +08:00
if ( NOT LLDB_DISABLE_PYTHON )
2014-07-04 14:43:47 +08:00
add_subdirectory ( scripts )
endif ( )
[lldb] Let table gen create command option initializers.
Summary:
We currently have man large arrays containing initializers for our command options.
These tables are tricky maintain as we don't have any good place to check them for consistency and
it's also hard to read (`nullptr, {}, 0` is not very descriptive).
This patch fixes this by letting table gen generate those tables. This way we can have a more readable
syntax for this (especially for all the default arguments) and we can let TableCheck check them
for consistency (e.g. an option with an optional argument can't have `eArgTypeNone`, naming of flags', etc.).
Also refactoring the related data structures can now be done without changing the hundred of option initializers.
For example, this line:
```
{LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide aliases in the command list."},
```
becomes this:
```
def hide_aliases : Option<"hide-aliases", "a">, Desc<"Hide aliases in the command list.">;
```
For now I just moved a few initializers to the new format to demonstrate the change. I'll slowly migrate the other
option initializers tables in separate patches.
Reviewers: JDevlieghere, davide, sgraenitz
Reviewed By: JDevlieghere
Subscribers: jingham, xiaobai, labath, mgorny, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D64365
llvm-svn: 365908
2019-07-12 23:30:55 +08:00
2019-07-18 08:21:57 +08:00
if ( CMAKE_CROSSCOMPILING AND LLDB_BUILT_STANDALONE )
set ( LLVM_USE_HOST_TOOLS ON )
include ( CrossCompile )
2019-07-19 07:40:23 +08:00
if ( NOT NATIVE_LLVM_DIR OR NOT NATIVE_Clang_DIR )
2019-07-18 08:21:57 +08:00
message ( FATAL_ERROR
2019-07-19 07:40:23 +08:00
" C r o s s c o m p i l i n g s t a n d a l o n e r e q u i r e s t h e v a r i a b l e s N A T I V E _ { C L A N G , L L V M } _ D I R
2019-07-18 08:21:57 +08:00
f o r b u i l d i n g t h e n a t i v e l l d b - t b l g e n u s e d d u r i n g t h e b u i l d p r o c e s s . " )
endif ( )
llvm_create_cross_target ( lldb NATIVE "" Release
2019-07-19 07:40:23 +08:00
- D L L V M _ D I R = $ { N A T I V E _ L L V M _ D I R }
- D C l a n g _ D I R = $ { N A T I V E _ C l a n g _ D I R } )
2019-07-18 08:21:57 +08:00
endif ( )
2019-07-27 02:14:04 +08:00
# TableGen
[lldb] Let table gen create command option initializers.
Summary:
We currently have man large arrays containing initializers for our command options.
These tables are tricky maintain as we don't have any good place to check them for consistency and
it's also hard to read (`nullptr, {}, 0` is not very descriptive).
This patch fixes this by letting table gen generate those tables. This way we can have a more readable
syntax for this (especially for all the default arguments) and we can let TableCheck check them
for consistency (e.g. an option with an optional argument can't have `eArgTypeNone`, naming of flags', etc.).
Also refactoring the related data structures can now be done without changing the hundred of option initializers.
For example, this line:
```
{LLDB_OPT_SET_ALL, false, "hide-aliases", 'a', OptionParser::eNoArgument, nullptr, {}, 0, eArgTypeNone, "Hide aliases in the command list."},
```
becomes this:
```
def hide_aliases : Option<"hide-aliases", "a">, Desc<"Hide aliases in the command list.">;
```
For now I just moved a few initializers to the new format to demonstrate the change. I'll slowly migrate the other
option initializers tables in separate patches.
Reviewers: JDevlieghere, davide, sgraenitz
Reviewed By: JDevlieghere
Subscribers: jingham, xiaobai, labath, mgorny, abidh, lldb-commits
Tags: #lldb
Differential Revision: https://reviews.llvm.org/D64365
llvm-svn: 365908
2019-07-12 23:30:55 +08:00
add_subdirectory ( utils/TableGen )
2019-07-27 02:14:04 +08:00
2013-09-25 18:37:32 +08:00
add_subdirectory ( source )
add_subdirectory ( tools )
2019-04-30 00:29:10 +08:00
add_subdirectory ( docs )
2017-10-07 06:21:36 +08:00
2019-01-12 02:11:04 +08:00
option ( LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests." ${ LLVM_INCLUDE_TESTS } )
2018-02-21 08:05:51 +08:00
option ( LLDB_TEST_USE_CUSTOM_C_COMPILER "Use the C compiler provided via LLDB_TEST_C_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF )
option ( LLDB_TEST_USE_CUSTOM_CXX_COMPILER "Use the C++ compiler provided via LLDB_TEST_CXX_COMPILER for building test inferiors (instead of the just-built compiler). Defaults to OFF." OFF )
2017-10-07 06:21:36 +08:00
if ( LLDB_INCLUDE_TESTS )
2018-07-04 21:59:25 +08:00
2019-01-12 01:51:33 +08:00
# Set the path to the default lldb test executable.
2018-07-04 22:38:21 +08:00
set ( LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}" )
2018-09-19 03:31:47 +08:00
2019-01-12 01:51:33 +08:00
# Set the paths to default llvm tools.
2018-07-04 21:59:25 +08:00
set ( LLDB_DEFAULT_TEST_DSYMUTIL "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/dsymutil${CMAKE_EXECUTABLE_SUFFIX}" )
2018-09-19 03:31:47 +08:00
set ( LLDB_DEFAULT_TEST_FILECHECK "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/FileCheck${CMAKE_EXECUTABLE_SUFFIX}" )
2018-07-04 21:59:25 +08:00
2018-02-21 08:05:51 +08:00
if ( NOT LLDB_TEST_USE_CUSTOM_C_COMPILER AND TARGET clang )
2018-02-08 10:13:48 +08:00
set ( LLDB_DEFAULT_TEST_C_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}" )
2017-10-27 10:24:04 +08:00
else ( )
set ( LLDB_DEFAULT_TEST_C_COMPILER "" )
2018-02-21 08:05:51 +08:00
endif ( )
if ( NOT LLDB_TEST_USE_CUSTOM_CXX_COMPILER AND TARGET clang )
set ( LLDB_DEFAULT_TEST_CXX_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}" )
else ( )
2017-10-27 10:24:04 +08:00
set ( LLDB_DEFAULT_TEST_CXX_COMPILER "" )
endif ( )
2018-07-04 21:59:25 +08:00
set ( LLDB_TEST_EXECUTABLE "${LLDB_DEFAULT_TEST_EXECUTABLE}" CACHE PATH "lldb executable used for testing" )
2017-10-27 10:24:04 +08:00
set ( LLDB_TEST_C_COMPILER "${LLDB_DEFAULT_TEST_C_COMPILER}" CACHE PATH "C Compiler to use for building LLDB test inferiors" )
set ( LLDB_TEST_CXX_COMPILER "${LLDB_DEFAULT_TEST_CXX_COMPILER}" CACHE PATH "C++ Compiler to use for building LLDB test inferiors" )
2018-07-04 21:59:25 +08:00
set ( LLDB_TEST_DSYMUTIL "${LLDB_DEFAULT_TEST_DSYMUTIL}" CACHE PATH "dsymutil used for generating dSYM bundles" )
2018-09-19 03:31:47 +08:00
set ( LLDB_TEST_FILECHECK "${LLDB_DEFAULT_TEST_FILECHECK}" CACHE PATH "FileCheck used for testing purposes" )
2017-10-27 10:24:04 +08:00
if ( ( "${LLDB_TEST_C_COMPILER}" STREQUAL "" ) OR
( " $ { L L D B _ T E S T _ C X X _ C O M P I L E R } " S T R E Q U A L " " ) )
message ( FATAL_ERROR "LLDB test compilers not specified. Tests will not run" )
endif ( )
2018-05-04 00:54:10 +08:00
set ( LLDB_TEST_DEPS lldb )
# darwin-debug is an hard dependency for the testsuite.
if ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
list ( APPEND LLDB_TEST_DEPS darwin-debug )
endif ( )
2019-04-18 07:43:01 +08:00
# lldb-test is an hard dependency for the testsuite.
list ( APPEND LLDB_TEST_DEPS lldb-test )
2018-05-04 00:54:10 +08:00
if ( TARGET lldb-server )
list ( APPEND LLDB_TEST_DEPS lldb-server )
endif ( )
2019-03-27 02:36:44 +08:00
if ( TARGET lldb-vscode )
list ( APPEND LLDB_TEST_DEPS lldb-vscode )
endif ( )
2019-02-08 02:41:59 +08:00
if ( TARGET lldb-instr )
list ( APPEND LLDB_TEST_DEPS lldb-instr )
endif ( )
2018-05-04 00:54:10 +08:00
if ( NOT LLDB_BUILT_STANDALONE )
2018-07-04 21:59:25 +08:00
list ( APPEND LLDB_TEST_DEPS yaml2obj )
2018-05-04 00:54:10 +08:00
endif ( )
if ( TARGET liblldb )
list ( APPEND LLDB_TEST_DEPS liblldb )
endif ( )
2019-01-10 00:25:31 +08:00
# Add dependencies if we test with the in-tree clang.
# This works with standalone builds as they import the clang target.
2018-05-04 00:54:10 +08:00
if ( TARGET clang )
list ( APPEND LLDB_TEST_DEPS clang )
2018-12-19 04:59:23 +08:00
if ( APPLE )
2019-01-10 00:25:31 +08:00
# If we build clang, we should build libcxx.
# FIXME: Standalone builds should import the cxx target as well.
if ( LLDB_BUILT_STANDALONE )
# For now check that the include directory exists.
2019-01-10 00:25:37 +08:00
set ( cxx_dir "${LLVM_BINARY_DIR}/include/c++" )
2019-01-10 00:25:31 +08:00
if ( NOT EXISTS ${ cxx_dir } )
message ( WARNING "LLDB test suite requires libc++ in llvm/projects/libcxx or an existing build symlinked to ${cxx_dir}" )
endif ( )
else ( )
2019-05-15 16:59:02 +08:00
# We require libcxx for the test suite, so if we aren't building it,
# try to provide a helpful error about how to resolve the situation.
if ( NOT TARGET cxx )
if ( LLVM_ENABLE_PROJECTS STREQUAL "" )
# If `LLVM_ENABLE_PROJECTS` is not being used (implying that we are
# using the old layout), suggest checking it out.
message ( FATAL_ERROR
" L L D B t e s t s u i t e r e q u i r e s l i b c + + , b u t i t i s c u r r e n t l y d i s a b l e d . "
" P l e a s e c h e c k o u t ` l i b c x x ` i n ` l l v m / p r o j e c t s ` o r d i s a b l e t e s t s "
" v i a ` L L D B _ I N C L U D E _ T E S T S = O F F ` . " )
else ( )
# If `LLVM_ENABLE_PROJECTS` is being used, suggest adding it.
message ( FATAL_ERROR
" L L D B t e s t s u i t e r e q u i r e s l i b c + + , b u t i t i s c u r r e n t l y d i s a b l e d . "
" P l e a s e a d d ` l i b c x x ` t o ` L L V M _ E N A B L E _ P R O J E C T S ` o r d i s a b l e t e s t s "
" v i a ` L L D B _ I N C L U D E _ T E S T S = O F F ` . " )
endif ( )
endif ( )
2019-01-10 00:25:31 +08:00
list ( APPEND LLDB_TEST_DEPS cxx )
endif ( )
2018-12-19 04:59:23 +08:00
endif ( )
2018-05-04 00:54:10 +08:00
endif ( )
2018-07-04 21:59:25 +08:00
if ( TARGET dsymutil )
list ( APPEND LLDB_TEST_DEPS dsymutil )
endif ( )
2019-05-29 19:26:06 +08:00
if ( TARGET lldb-framework )
list ( APPEND LLDB_TEST_DEPS lldb-framework )
endif ( )
2019-04-30 03:44:43 +08:00
add_custom_target ( lldb-test-deps )
add_dependencies ( lldb-test-deps ${ LLDB_TEST_DEPS } )
2019-05-28 17:29:05 +08:00
set_target_properties ( lldb-test-deps PROPERTIES FOLDER "lldb misc" )
2019-01-18 06:25:20 +08:00
2017-10-07 06:21:36 +08:00
add_subdirectory ( test )
add_subdirectory ( unittests )
add_subdirectory ( lit )
2019-04-26 21:21:46 +08:00
add_subdirectory ( utils/lit-cpuid )
2018-05-04 00:54:10 +08:00
add_subdirectory ( utils/lldb-dotest )
2017-10-07 06:21:36 +08:00
endif ( )
2015-02-18 06:20:29 +08:00
2015-09-08 13:00:22 +08:00
if ( NOT LLDB_DISABLE_PYTHON )
[CMake] Revised LLDB.framework builds
Summary:
Add features to LLDB CMake builds that have so far only been available in Xcode. Clean up a few inconveniences and prepare further improvements.
Options:
* `LLDB_FRAMEWORK_BUILD_DIR` determines target directory (in build-tree)
* `LLDB_FRAMEWORK_INSTALL_DIR` **only** determines target directory in install-tree
* `LLVM_EXTERNALIZE_DEBUGINFO` allows externalized debug info (dSYM on Darwin, emitted to `bin`)
* `LLDB_FRAMEWORK_TOOLS` determines which executables will be copied to the framework's Resources (dropped symlinking, removed INCLUDE_IN_SUITE, removed dummy targets)
Other changes:
* clean up `add_lldb_executable()`
* include `LLDBFramework.cmake` from `source/API/CMakeLists.txt`
* use `*.plist.in` files, which are typical for CMake and independent from Xcode
* add clang headers to the framework bundle
Reviewers: xiaobai, JDevlieghere, aprantl, davide, beanz, stella.stamenova, clayborg, labath
Reviewed By: aprantl
Subscribers: friss, mgorny, lldb-commits, #lldb
Differential Revision: https://reviews.llvm.org/D55328
llvm-svn: 350391
2019-01-04 20:46:50 +08:00
if ( NOT LLDB_BUILD_FRAMEWORK )
set ( use_python_wrapper_from_src_dir -m )
endif ( )
if ( LLDB_USE_SYSTEM_SIX )
set ( use_six_py_from_system --useSystemSix )
endif ( )
2019-01-04 20:47:02 +08:00
get_target_property ( lldb_scripts_dir swig_wrapper BINARY_DIR )
get_target_property ( liblldb_build_dir liblldb LIBRARY_OUTPUT_DIRECTORY )
[CMake] Revised LLDB.framework builds
Summary:
Add features to LLDB CMake builds that have so far only been available in Xcode. Clean up a few inconveniences and prepare further improvements.
Options:
* `LLDB_FRAMEWORK_BUILD_DIR` determines target directory (in build-tree)
* `LLDB_FRAMEWORK_INSTALL_DIR` **only** determines target directory in install-tree
* `LLVM_EXTERNALIZE_DEBUGINFO` allows externalized debug info (dSYM on Darwin, emitted to `bin`)
* `LLDB_FRAMEWORK_TOOLS` determines which executables will be copied to the framework's Resources (dropped symlinking, removed INCLUDE_IN_SUITE, removed dummy targets)
Other changes:
* clean up `add_lldb_executable()`
* include `LLDBFramework.cmake` from `source/API/CMakeLists.txt`
* use `*.plist.in` files, which are typical for CMake and independent from Xcode
* add clang headers to the framework bundle
Reviewers: xiaobai, JDevlieghere, aprantl, davide, beanz, stella.stamenova, clayborg, labath
Reviewed By: aprantl
Subscribers: friss, mgorny, lldb-commits, #lldb
Differential Revision: https://reviews.llvm.org/D55328
llvm-svn: 350391
2019-01-04 20:46:50 +08:00
2016-12-17 00:38:25 +08:00
# Add a Post-Build Event to copy over Python files and create the symlink
2019-05-22 21:23:15 +08:00
# to liblldb.so for the Python API(hardlink on Windows).
2016-12-17 00:38:25 +08:00
add_custom_target ( finish_swig ALL
C O M M A N D
2019-01-04 20:47:02 +08:00
$ { P Y T H O N _ E X E C U T A B L E } $ { L L D B _ S O U R C E _ D I R } / s c r i p t s / f i n i s h S w i g W r a p p e r C l a s s e s . p y
2016-12-17 00:38:25 +08:00
- - s r c R o o t = $ { L L D B _ S O U R C E _ D I R }
2019-01-04 20:47:02 +08:00
- - t a r g e t D i r = $ { l i b l l d b _ b u i l d _ d i r }
- - c f g B l d D i r = $ { l l d b _ s c r i p t s _ d i r }
2016-12-17 00:38:25 +08:00
- - p r e f i x = $ { C M A K E _ B I N A R Y _ D I R }
- - c m a k e B u i l d C o n f i g u r a t i o n = $ { C M A K E _ C F G _ I N T D I R }
- - l l d b L i b D i r = l i b $ { L L V M _ L I B D I R _ S U F F I X }
[CMake] Revised LLDB.framework builds
Summary:
Add features to LLDB CMake builds that have so far only been available in Xcode. Clean up a few inconveniences and prepare further improvements.
Options:
* `LLDB_FRAMEWORK_BUILD_DIR` determines target directory (in build-tree)
* `LLDB_FRAMEWORK_INSTALL_DIR` **only** determines target directory in install-tree
* `LLVM_EXTERNALIZE_DEBUGINFO` allows externalized debug info (dSYM on Darwin, emitted to `bin`)
* `LLDB_FRAMEWORK_TOOLS` determines which executables will be copied to the framework's Resources (dropped symlinking, removed INCLUDE_IN_SUITE, removed dummy targets)
Other changes:
* clean up `add_lldb_executable()`
* include `LLDBFramework.cmake` from `source/API/CMakeLists.txt`
* use `*.plist.in` files, which are typical for CMake and independent from Xcode
* add clang headers to the framework bundle
Reviewers: xiaobai, JDevlieghere, aprantl, davide, beanz, stella.stamenova, clayborg, labath
Reviewed By: aprantl
Subscribers: friss, mgorny, lldb-commits, #lldb
Differential Revision: https://reviews.llvm.org/D55328
llvm-svn: 350391
2019-01-04 20:46:50 +08:00
$ { u s e _ p y t h o n _ w r a p p e r _ f r o m _ s r c _ d i r }
$ { u s e _ s i x _ p y _ f r o m _ s y s t e m }
2016-12-17 00:38:25 +08:00
V E R B A T I M
2019-01-04 20:47:02 +08:00
D E P E N D S $ { L L D B _ S O U R C E _ D I R } / s c r i p t s / f i n i s h S w i g W r a p p e r C l a s s e s . p y
D E P E N D S $ { l l d b _ s c r i p t s _ d i r } / l l d b . p y
2015-02-18 06:20:29 +08:00
C O M M E N T " P y t h o n s c r i p t s y m - l i n k i n g L L D B P y t h o n A P I " )
2018-06-19 02:27:16 +08:00
2019-08-06 07:54:13 +08:00
add_dependencies ( finish_swig swig_wrapper liblldb lldb-argdumper )
2019-05-28 17:29:05 +08:00
set_target_properties ( finish_swig swig_wrapper PROPERTIES FOLDER "lldb misc" )
2015-10-04 09:28:51 +08:00
2015-09-16 23:34:06 +08:00
# Ensure we do the python post-build step when building lldb.
add_dependencies ( lldb finish_swig )
2015-10-01 15:55:44 +08:00
# Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
# lldb.exe or any other executables that were linked with liblldb.
if ( WIN32 AND NOT "${PYTHON_DLL}" STREQUAL "" )
# When using the Visual Studio CMake generator the lldb binaries end up in Release/bin, Debug/bin etc.
file ( TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin" LLDB_BIN_DIR )
file ( TO_NATIVE_PATH "${PYTHON_DLL}" PYTHON_DLL_NATIVE_PATH )
add_custom_command (
T A R G E T f i n i s h _ s w i g
P O S T _ B U I L D
2016-12-17 00:38:25 +08:00
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y $ { P Y T H O N _ D L L _ N A T I V E _ P A T H } $ { L L D B _ B I N _ D I R } V E R B A T I M
2015-10-01 15:55:44 +08:00
C O M M E N T " C o p y i n g P y t h o n D L L t o L L D B b i n a r i e s d i r e c t o r y . " )
endif ( )
2015-02-18 06:20:29 +08:00
endif ( )
2019-07-10 19:09:11 +08:00
2019-07-19 00:44:45 +08:00
if ( LLDB_BUILT_STANDALONE AND NOT LLVM_ENABLE_IDE )
2019-07-10 19:09:11 +08:00
llvm_distribution_add_targets ( )
endif ( )