]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - CMakeLists.txt
Vendor import of lldb trunk r290819:
[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 (__ANDROID_NDK__ OR (CMAKE_SYSTEM_NAME MATCHES "Windows"))
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   set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
24   if(LLDB_BUILD_FRAMEWORK)
25     set(LLDB_PYTHON_TARGET_DIR
26       ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
27   else()
28     # Don't set -m when building the framework.
29     set(FINISH_EXTRA_ARGS "-m")
30   endif()
31   set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp)
32
33   add_subdirectory(scripts)
34 endif ()
35 add_subdirectory(source)
36 add_subdirectory(test)
37 add_subdirectory(tools)
38 add_subdirectory(unittests)
39 add_subdirectory(lit)
40
41 if (NOT LLDB_DISABLE_PYTHON)
42     # Add a Post-Build Event to copy over Python files and create the symlink
43     # to liblldb.so for the Python API(hardlink on Windows)
44     add_custom_target(finish_swig ALL
45         COMMAND
46            ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
47                --srcRoot=${LLDB_SOURCE_DIR}
48                --targetDir=${LLDB_PYTHON_TARGET_DIR}
49                --cfgBldDir=${CMAKE_CURRENT_BINARY_DIR}/scripts
50                --prefix=${CMAKE_BINARY_DIR}
51                --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
52                --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
53                ${FINISH_EXTRA_ARGS}
54         VERBATIM
55         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
56         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/scripts/lldb.py
57         COMMENT "Python script sym-linking LLDB Python API")
58     # We depend on liblldb being built before we can do this step.
59     add_dependencies(finish_swig liblldb lldb-argdumper)
60
61     # If we build the readline module, we depend on that happening
62     # first.
63     if (TARGET readline)
64         add_dependencies(finish_swig readline)
65     endif()
66
67     # Ensure we do the python post-build step when building lldb.
68     add_dependencies(lldb finish_swig)
69
70     if(LLDB_BUILD_FRAMEWORK)
71       # The target to install libLLDB needs to depend on finish swig so that the
72       # framework build properly copies over the Python files.
73       add_dependencies(install-liblldb finish_swig)
74     endif()
75
76     # Add a Post-Build Event to copy the custom Python DLL to the lldb binaries dir so that Windows can find it when launching
77     # lldb.exe or any other executables that were linked with liblldb.
78     if (WIN32 AND NOT "${PYTHON_DLL}" STREQUAL "")
79         # When using the Visual Studio CMake generator the lldb binaries end up in Release/bin, Debug/bin etc.
80         file(TO_NATIVE_PATH "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin" LLDB_BIN_DIR)
81         file(TO_NATIVE_PATH "${PYTHON_DLL}" PYTHON_DLL_NATIVE_PATH)
82         add_custom_command(
83             TARGET finish_swig
84             POST_BUILD
85             COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_DLL_NATIVE_PATH} ${LLDB_BIN_DIR} VERBATIM
86             COMMENT "Copying Python DLL to LLDB binaries directory.")
87     endif ()
88 endif ()