llvm-project/lldb/unittests/CMakeLists.txt
Jonas Devlieghere ed294c28ac
[lldb] Move MCP protocol into its own library (NFC) (#152059)
This PR moves the MCP protocol code into its own library
(`lldbProtocolMCP`) so the code can be shared between the
`ProtocolServerMCP` plugin in LLDB as well as `lldb-mcp`. The goal is to
do the same thing for DAP (which, for now, would be used exclusively
from `lldb-dap`).

To make it clear that it's neither part of the `lldb` nor the
`lldb_private` namespace, I created a new `lldb_protocol` namespace.

Depending on how much code would be reused by lldb-dap, we may move more
code into the protocol library.
2025-08-05 09:48:26 -07:00

89 lines
2.4 KiB
CMake

add_custom_target(LLDBUnitTests)
set_target_properties(LLDBUnitTests PROPERTIES FOLDER "LLDB/Tests")
add_dependencies(lldb-unit-test-deps LLDBUnitTests)
include_directories(${LLDB_SOURCE_ROOT})
include_directories(${LLDB_PROJECT_ROOT}/unittests)
if (CXX_SUPPORTS_SUGGEST_OVERRIDE_FLAG)
add_compile_options("-Wno-suggest-override")
endif()
function(add_lldb_unittest test_name)
cmake_parse_arguments(ARG
""
""
"LINK_LIBS;LINK_COMPONENTS"
${ARGN})
if (NOT ${test_name} MATCHES "Tests$")
message(FATAL_ERROR "Unit test name must end with 'Tests' for lit to find it.")
endif()
list(APPEND LLVM_LINK_COMPONENTS ${ARG_LINK_COMPONENTS})
add_unittest(LLDBUnitTests
${test_name}
${ARG_UNPARSED_ARGUMENTS}
)
add_custom_command(
TARGET ${test_name}
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/Inputs)
target_link_libraries(${test_name} PRIVATE ${ARG_LINK_LIBS})
endfunction()
function(add_unittest_inputs test_name inputs)
foreach (INPUT ${inputs})
add_custom_command(
TARGET ${test_name}
POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy ${CMAKE_CURRENT_SOURCE_DIR}/Inputs/${INPUT} ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/Inputs
COMMENT "Copying ${INPUT} to binary directory.")
endforeach()
endfunction()
add_subdirectory(TestingSupport)
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
# FIXME: Tests linking against libLLDB don't work on Windows.
add_subdirectory(API)
add_subdirectory(DAP)
endif()
add_subdirectory(ABI)
add_subdirectory(Breakpoint)
add_subdirectory(Callback)
add_subdirectory(Core)
add_subdirectory(DataFormatter)
add_subdirectory(Disassembler)
add_subdirectory(Editline)
add_subdirectory(Expression)
add_subdirectory(Host)
add_subdirectory(Instruction)
add_subdirectory(Interpreter)
add_subdirectory(Language)
add_subdirectory(ObjectFile)
add_subdirectory(Platform)
add_subdirectory(Process)
add_subdirectory(Protocol)
add_subdirectory(ScriptInterpreter)
add_subdirectory(Signals)
add_subdirectory(Symbol)
add_subdirectory(SymbolFile)
add_subdirectory(Target)
add_subdirectory(Thread)
add_subdirectory(UnwindAssembly)
add_subdirectory(Utility)
add_subdirectory(ValueObject)
add_subdirectory(tools)
if(LLDB_ENABLE_PROTOCOL_SERVERS)
add_subdirectory(ProtocolServer)
endif()
if(LLDB_CAN_USE_DEBUGSERVER AND LLDB_TOOL_DEBUGSERVER_BUILD AND NOT LLDB_USE_SYSTEM_DEBUGSERVER)
add_subdirectory(debugserver)
endif()