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
|
|
|
|
${CMAKE_MODULE_PATH}
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules"
|
|
|
|
)
|
|
|
|
|
|
|
|
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 )
|
|
|
|
endif()
|
|
|
|
|
2017-07-28 23:39:50 +08:00
|
|
|
if(APPLE)
|
|
|
|
add_definitions(-DLLDB_USE_OS_LOG)
|
|
|
|
endif()
|
|
|
|
|
2015-10-07 06:21:08 +08:00
|
|
|
# add_subdirectory(include)
|
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)
|
|
|
|
set(LLDB_PYTHON_TARGET_DIR
|
|
|
|
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_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 ()
|
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."
|
|
|
|
${LLVM_INCLUDE_TESTS})
|
|
|
|
if(LLDB_INCLUDE_TESTS)
|
2017-10-27 10:24:04 +08:00
|
|
|
if (TARGET clang)
|
|
|
|
set(LLDB_DEFAULT_TEST_C_COMPILER "${LLVM_BINARY_DIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}")
|
|
|
|
set(LLDB_DEFAULT_TEST_CXX_COMPILER "${LLVM_BINARY_DIR}/bin/clang++${CMAKE_EXECUTABLE_SUFFIX}")
|
|
|
|
else()
|
|
|
|
set(LLDB_DEFAULT_TEST_C_COMPILER "")
|
|
|
|
set(LLDB_DEFAULT_TEST_CXX_COMPILER "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
|
|
if (("${LLDB_TEST_C_COMPILER}" STREQUAL "") OR
|
|
|
|
("${LLDB_TEST_CXX_COMPILER}" STREQUAL ""))
|
|
|
|
message(FATAL_ERROR "LLDB test compilers not specified. Tests will not run")
|
|
|
|
endif()
|
|
|
|
|
2017-10-07 06:21:36 +08:00
|
|
|
add_subdirectory(test)
|
|
|
|
add_subdirectory(unittests)
|
|
|
|
add_subdirectory(lit)
|
|
|
|
endif()
|
2015-02-18 06:20:29 +08:00
|
|
|
|
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
|
|
|
|
COMMAND
|
|
|
|
${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
|
|
|
|
--srcRoot=${LLDB_SOURCE_DIR}
|
|
|
|
--targetDir=${LLDB_PYTHON_TARGET_DIR}
|
|
|
|
--cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts
|
|
|
|
--prefix=${CMAKE_BINARY_DIR}
|
|
|
|
--cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
|
|
|
|
--lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
|
2017-02-04 08:20:24 +08:00
|
|
|
${SIX_EXTRA_ARGS}
|
2016-12-17 00:38:25 +08:00
|
|
|
${FINISH_EXTRA_ARGS}
|
|
|
|
VERBATIM
|
2015-02-18 06:20:29 +08:00
|
|
|
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
|
2015-11-19 05:09:55 +08:00
|
|
|
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scripts/lldb.py
|
2015-02-18 06:20:29 +08:00
|
|
|
COMMENT "Python script sym-linking LLDB Python API")
|
2015-09-16 23:34:06 +08:00
|
|
|
# We depend on liblldb being built before we can do this step.
|
2015-10-29 22:14:24 +08:00
|
|
|
add_dependencies(finish_swig liblldb lldb-argdumper)
|
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
|
|
|
|
2016-12-16 02:19:10 +08:00
|
|
|
if(LLDB_BUILD_FRAMEWORK)
|
|
|
|
# The target to install libLLDB needs to depend on finish swig so that the
|
|
|
|
# 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(
|
|
|
|
TARGET finish_swig
|
|
|
|
POST_BUILD
|
2016-12-17 00:38:25 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_DLL_NATIVE_PATH} ${LLDB_BIN_DIR} VERBATIM
|
2015-10-01 15:55:44 +08:00
|
|
|
COMMENT "Copying Python DLL to LLDB binaries directory.")
|
|
|
|
endif ()
|
2015-02-18 06:20:29 +08:00
|
|
|
endif ()
|