summaryrefslogtreecommitdiffstats
path: root/lldb/CMakeLists.txt
blob: 5b2a109c9eea8acdd3fe78db7846bcffaa2ce32e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
cmake_minimum_required(VERSION 3.4.3)

# 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)

# 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()

if (CMAKE_SYSTEM_NAME MATCHES "Windows|Android")
  set(LLDB_DEFAULT_DISABLE_LIBEDIT 1)
else()
  set(LLDB_DEFAULT_DISABLE_LIBEDIT 0)
endif ()

# 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 )
else()
  find_package(LibEdit REQUIRED)
endif()

if(APPLE)
  add_definitions(-DLLDB_USE_OS_LOG)
endif()

if(LLDB_BUILD_FRAMEWORK)
  set(LLDB_FRAMEWORK_DIR
    ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${LLDB_FRAMEWORK_INSTALL_DIR})
endif()

add_subdirectory(docs)
if (NOT LLDB_DISABLE_PYTHON)
  if(LLDB_USE_SYSTEM_SIX)
    set(SIX_EXTRA_ARGS "--useSystemSix")
  endif()

  set(LLDB_PYTHON_TARGET_DIR ${LLDB_BINARY_DIR}/scripts)
  set(LLDB_WRAP_PYTHON ${LLDB_BINARY_DIR}/scripts/LLDBWrapPython.cpp)
  if(LLDB_BUILD_FRAMEWORK)
    set(LLDB_PYTHON_TARGET_DIR ${LLDB_FRAMEWORK_DIR})
    set(LLDB_WRAP_PYTHON ${LLDB_PYTHON_TARGET_DIR}/LLDBWrapPython.cpp)
  else()
    # Don't set -m when building the framework.
    set(FINISH_EXTRA_ARGS "-m")
  endif()


  add_subdirectory(scripts)
endif ()

add_subdirectory(source)
add_subdirectory(tools)

option(LLDB_INCLUDE_TESTS "Generate build targets for the LLDB unit tests."
  ${LLVM_INCLUDE_TESTS})
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)
if(LLDB_INCLUDE_TESTS)
  if (NOT LLDB_TEST_USE_CUSTOM_C_COMPILER AND TARGET clang)
    set(LLDB_DEFAULT_TEST_C_COMPILER "${LLVM_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/clang${CMAKE_EXECUTABLE_SUFFIX}")
  else()
    set(LLDB_DEFAULT_TEST_C_COMPILER "")
  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()
    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()

  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)
    list(APPEND LLDB_TEST_DEPS yaml2obj dsymutil)
  endif()

  if(TARGET liblldb)
    list(APPEND LLDB_TEST_DEPS liblldb)
  endif()

  if(TARGET clang)
    list(APPEND LLDB_TEST_DEPS clang)
  endif()

  add_subdirectory(test)
  add_subdirectory(unittests)
  add_subdirectory(lit)
  add_subdirectory(utils/lldb-dotest)
endif()

if (NOT LLDB_DISABLE_PYTHON)
    # 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=${LLDB_PYTHON_TARGET_DIR}
               --prefix=${CMAKE_BINARY_DIR}
               --cmakeBuildConfiguration=${CMAKE_CFG_INTDIR}
               --lldbLibDir=lib${LLVM_LIBDIR_SUFFIX}
               ${SIX_EXTRA_ARGS}
               ${FINISH_EXTRA_ARGS}
        VERBATIM
        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/finishSwigWrapperClasses.py
        DEPENDS ${LLDB_PYTHON_TARGET_DIR}/lldb.py
        COMMENT "Python script sym-linking LLDB Python API")
    # We depend on liblldb being built before we can do this step.
    add_dependencies(finish_swig liblldb lldb-argdumper)

    # If we build the readline module, we depend on that happening
    # first.
    if (TARGET readline)
        add_dependencies(finish_swig readline)
    endif()

    # Ensure we do the python post-build step when building lldb.
    add_dependencies(lldb finish_swig)

    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()

    # 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
            COMMAND ${CMAKE_COMMAND} -E copy ${PYTHON_DLL_NATIVE_PATH} ${LLDB_BIN_DIR} VERBATIM
            COMMENT "Copying Python DLL to LLDB binaries directory.")
    endif ()
endif ()
OpenPOWER on IntegriCloud