2016-06-01 04:21:44 +08:00
cmake_minimum_required ( VERSION 3.4.3 )
2015-07-17 23:50:48 +08:00
2017-04-28 00:04:26 +08:00
# Add path for custom modules
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 "
)
include ( LLDBStandalone )
include ( LLDBConfig )
include ( AddLLDB )
2014-05-29 01:06:04 +08:00
2017-10-05 04:23:56 +08:00
# Define the LLDB_CONFIGURATION_xxx matching the build type
if ( uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG" )
add_definitions ( -DLLDB_CONFIGURATION_DEBUG )
else ( )
add_definitions ( -DLLDB_CONFIGURATION_RELEASE )
endif ( )
2017-01-17 19:55:00 +08:00
if ( CMAKE_SYSTEM_NAME MATCHES "Windows|Android" )
2015-10-07 08:01:06 +08:00
set ( LLDB_DEFAULT_DISABLE_LIBEDIT 1 )
else ( )
set ( LLDB_DEFAULT_DISABLE_LIBEDIT 0 )
endif ( )
2015-10-07 06:21:08 +08:00
# We need libedit support to go down both the source and
# the scripts directories.
set ( LLDB_DISABLE_LIBEDIT ${ LLDB_DEFAULT_DISABLE_LIBEDIT } CACHE BOOL "Disables the use of editline." )
if ( LLDB_DISABLE_LIBEDIT )
add_definitions ( -DLLDB_DISABLE_LIBEDIT )
2018-05-23 07:24:46 +08:00
else ( )
find_package ( LibEdit REQUIRED )
2015-10-07 06:21:08 +08:00
endif ( )
2017-07-28 23:39:50 +08:00
if ( APPLE )
add_definitions ( -DLLDB_USE_OS_LOG )
endif ( )
2018-06-19 02:27:16 +08:00
# lldb-suite is a dummy target that encompasses all the necessary tools and
# libraries for building a fully-functioning liblldb.
add_custom_target ( lldb-suite )
2018-07-18 02:28:51 +08:00
set ( LLDB_SUITE_TARGET lldb-suite )
2018-06-19 02:27:16 +08:00
option ( LLDB_BUILD_FRAMEWORK "Build the Darwin LLDB.framework" Off )
2018-05-29 20:30:27 +08:00
if ( LLDB_BUILD_FRAMEWORK )
2018-06-19 02:27:16 +08:00
if ( CMAKE_VERSION VERSION_LESS 3.7 )
message ( FATAL_ERROR "LLDB_BUILD_FRAMEWORK is not supported on CMake < 3.7" )
endif ( )
if ( NOT APPLE )
message ( FATAL_ERROR "LLDB.framework can only be generated when targeting Apple platforms" )
endif ( )
2018-06-19 10:59:30 +08:00
# These are used to fill out LLDB-Info.plist. These are relevant when building
# the framework, and must be defined before building liblldb.
set ( PRODUCT_NAME "LLDB" )
set ( EXECUTABLE_NAME "LLDB" )
set ( CURRENT_PROJECT_VERSION "360.99.0" )
2018-07-28 07:38:58 +08:00
set ( LLDB_SUITE_TARGET lldb-framework )
set ( LLDB_FRAMEWORK_DIR
$ { C M A K E _ B I N A R Y _ D I R } / $ { C M A K E _ C F G _ I N T D I R } / $ { L L D B _ F R A M E W O R K _ I N S T A L L _ D I R } )
2018-05-29 20:30:27 +08:00
endif ( )
2013-09-25 18:37:32 +08:00
add_subdirectory ( docs )
2015-04-07 23:30:23 +08:00
if ( NOT LLDB_DISABLE_PYTHON )
2017-02-04 08:20:24 +08:00
if ( LLDB_USE_SYSTEM_SIX )
set ( SIX_EXTRA_ARGS "--useSystemSix" )
endif ( )
2016-09-22 05:02:16 +08:00
set ( LLDB_PYTHON_TARGET_DIR ${ LLDB_BINARY_DIR } /scripts )
2017-07-26 04:30:35 +08:00
set ( LLDB_WRAP_PYTHON ${ LLDB_BINARY_DIR } /scripts/LLDBWrapPython.cpp )
2016-09-22 05:02:16 +08:00
if ( LLDB_BUILD_FRAMEWORK )
2018-07-28 07:38:58 +08:00
set ( LLDB_PYTHON_TARGET_DIR ${ LLDB_FRAMEWORK_DIR } )
2017-07-26 04:30:35 +08:00
set ( LLDB_WRAP_PYTHON ${ LLDB_PYTHON_TARGET_DIR } /LLDBWrapPython.cpp )
2016-09-22 05:02:16 +08:00
else ( )
# Don't set -m when building the framework.
set ( FINISH_EXTRA_ARGS "-m" )
endif ( )
2017-07-26 04:30:35 +08:00
2016-09-22 05:02:16 +08:00
2014-07-04 14:43:47 +08:00
add_subdirectory ( scripts )
endif ( )
2018-02-14 07:05:46 +08:00
2013-09-25 18:37:32 +08:00
add_subdirectory ( source )
add_subdirectory ( tools )
2017-10-07 06:21:36 +08:00
option ( LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests."
$ { L L V M _ I N C L U D E _ T E S T S } )
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
2018-07-04 22:34:32 +08:00
# The difference between the following two paths is significant. The path to
# LLDB will point to LLDB's binary directory, while the other will point to
# LLVM's binary directory in case the two differ.
2018-07-04 22:38:21 +08:00
set ( LLDB_DEFAULT_TEST_EXECUTABLE "${LLVM_RUNTIME_OUTPUT_INTDIR}/lldb${CMAKE_EXECUTABLE_SUFFIX}" )
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-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" )
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 ( )
if ( TARGET lldb-server )
list ( APPEND LLDB_TEST_DEPS lldb-server )
endif ( )
if ( TARGET debugserver )
if ( NOT CMAKE_HOST_APPLE OR LLDB_CODESIGN_IDENTITY )
list ( APPEND LLDB_TEST_DEPS debugserver )
endif ( )
endif ( )
if ( TARGET lldb-mi )
list ( APPEND LLDB_TEST_DEPS lldb-mi )
endif ( )
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 ( )
if ( TARGET clang )
list ( APPEND LLDB_TEST_DEPS clang )
endif ( )
2018-07-04 21:59:25 +08:00
if ( TARGET dsymutil )
list ( APPEND LLDB_TEST_DEPS dsymutil )
endif ( )
2017-10-07 06:21:36 +08:00
add_subdirectory ( test )
add_subdirectory ( unittests )
add_subdirectory ( lit )
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
2018-07-28 07:38:58 +08:00
if ( LLDB_BUILD_FRAMEWORK )
add_custom_target ( lldb-framework )
include ( LLDBFramework )
endif ( )
2015-09-08 13:00:22 +08:00
if ( NOT LLDB_DISABLE_PYTHON )
2016-12-17 00:38:25 +08:00
# Add a Post-Build Event to copy over Python files and create the symlink
# to liblldb.so for the Python API(hardlink on Windows)
add_custom_target ( finish_swig ALL
C O M M A N D
$ { P Y T H O N _ E X E C U T A B L E } $ { C M A K E _ C U R R E N T _ 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
- - s r c R o o t = $ { L L D B _ S O U R C E _ D I R }
- - t a r g e t D i r = $ { L L D B _ P Y T H O N _ T A R G E T _ D I R }
2018-06-05 07:47:36 +08:00
- - c f g B l d D i r = $ { L L D B _ P Y T H O N _ T A R G E T _ 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 }
2017-02-04 08:20:24 +08:00
$ { S I X _ E X T R A _ A R G S }
2016-12-17 00:38:25 +08:00
$ { F I N I S H _ E X T R A _ A R G S }
V E R B A T I M
2015-02-18 06:20:29 +08:00
D E P E N D S $ { C M A K E _ C U R R E N T _ 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
2018-06-05 07:47:36 +08:00
D E P E N D S $ { L L D B _ P Y T H O N _ T A R G E T _ 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
# We depend on liblldb and lldb-argdumper being built before we can do this step.
2018-07-18 02:28:51 +08:00
add_dependencies ( finish_swig ${ LLDB_SUITE_TARGET } )
2015-09-16 23:34:06 +08:00
2015-10-04 09:28:51 +08:00
# If we build the readline module, we depend on that happening
# first.
if ( TARGET readline )
add_dependencies ( finish_swig readline )
endif ( )
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
2018-06-19 02:27:16 +08:00
if ( LLDB_BUILD_FRAMEWORK )
# The target to install libLLDB needs to depend on finish_swig so that the
2016-12-16 02:19:10 +08:00
# framework build properly copies over the Python files.
add_dependencies ( install-liblldb finish_swig )
endif ( )
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 ( )