]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - CMakeLists.txt
Vendor import of lldb trunk r301441:
[FreeBSD/FreeBSD.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.4.3)
2
3 include(cmake/modules/LLDBStandalone.cmake)
4 include(cmake/modules/LLDBConfig.cmake)
5 include(cmake/modules/AddLLDB.cmake)
6
7 if (CMAKE_SYSTEM_NAME MATCHES "Windows|Android")
8   set(LLDB_DEFAULT_DISABLE_LIBEDIT 1)
9 else()
10   set(LLDB_DEFAULT_DISABLE_LIBEDIT 0)
11 endif ()
12
13 # We need libedit support to go down both the source and
14 # the scripts directories.
15 set(LLDB_DISABLE_LIBEDIT ${LLDB_DEFAULT_DISABLE_LIBEDIT} CACHE BOOL "Disables the use of editline.")
16 if (LLDB_DISABLE_LIBEDIT)
17   add_definitions( -DLLDB_DISABLE_LIBEDIT )
18 endif()
19
20 # add_subdirectory(include)
21 add_subdirectory(docs)
22 if (NOT LLDB_DISABLE_PYTHON)
23   if(LLDB_USE_SYSTEM_SIX)
24     set(SIX_EXTRA_ARGS "--useSystemSix")
25   endif()
26
27   set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
28   if(LLDB_BUILD_FRAMEWORK)
29     set(LLDB_PYTHON_TARGET_DIR
30       ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
31   else()
32     # Don't set -m when building the framework.
33     set(FINISH_EXTRA_ARGS "-m")
34   endif()
35   set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
36
37   add_subdirectory(scripts)
38 endif ()
39 add_subdirectory(source)
40 add_subdirectory(test)
41 add_subdirectory(tools)
42 add_subdirectory(unittests)
43 add_subdirectory(lit)
44
45 if (NOT LLDB_DISABLE_PYTHON)
46     # Add a Post-Build Event to copy over Python files and create the symlink
47     # to liblldb.so for the Python API(hardlink on Windows)
48     add_custom_target(finish_swig ALL
49         COMMAND
50            ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
51                --srcRoot=${LLDB_SOURCE_DIR}
52                --targetDir=${LLDB_PYTHON_TARGET_DIR}
53                --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts
54                --prefix=${CMAKE_BINARY_DIR}
55                --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
56                --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
57                ${SIX_EXTRA_ARGS}
58                ${FINISH_EXTRA_ARGS}
59         VERBATIM
60         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
61         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scripts/lldb.py
62         COMMENT "Python script sym-linking LLDB Python API")
63     # We depend on liblldb being built before we can do this step.
64     add_dependencies(finish_swig liblldb lldb-argdumper)
65
66     # If we build the readline module, we depend on that happening
67     # first.
68     if (TARGET readline)
69         add_dependencies(finish_swig readline)
70     endif()
71
72     # Ensure we do the python post-build step when building lldb.
73     add_dependencies(lldb finish_swig)
74
75     if(LLDB_BUILD_FRAMEWORK)
76       # The target to install libLLDB needs to depend on finish swig so that the
77       # framework build properly copies over the Python files.
78       add_dependencies(install-liblldb finish_swig)
79     endif()
80
81     # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
82     # lldb.exe or any other executables that were linked with liblldb.
83     if (WIN32 AND NOT "${PYTHON_DLL}" STREQUAL "")
84         # When using the Visual Studio CMake generator the lldb binaries end up in Release/bin, Debug/bin etc.
85         file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin" LLDB_BIN_DIR)
86         file(TO_NATIVE_PATH "${PYTHON_DLL}" PYTHON_DLL_NATIVE_PATH)
87         add_custom_command(
88             TARGET finish_swig
89             POST_BUILD
90             COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_DLL_NATIVE_PATH} ${LLDB_BIN_DIR} VERBATIM
91             COMMENT "Copying Python DLL to LLDB binaries directory.")
92     endif ()
93 endif ()