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