# CMakeLists.txt — CMake project for the cpp-lsp-diff ad-hoc C++ fixture.
#
# Purpose: produce a compile_commands.json (via CMAKE_EXPORT_COMPILE_COMMANDS) that both the
# accuracy harness (clangd / mscppls) and an IDE (Visual Studio, or VS Code + CMake Tools)
# consume, so this folder can be opened and navigated for manual verification.
#
#   Configure + export the CDB:   cmake --preset cdb
#   Build (compiles every TU):    cmake --build --preset cdb
#   Or open this folder in an IDE with CMake support and pick the "cdb" preset.

cmake_minimum_required(VERSION 3.20)

# Compile-only compiler check (no link step): the fixture is freestanding and the box may not
# have a full MSVC link toolchain, so a link-based check would fail. A static library only
# compiles, which is all we need for compile_commands.json + IntelliSense.
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

project(cpp_lsp_diff LANGUAGES CXX)

# The fixture exercises C++20 features (concepts, abbreviated function templates).
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# Emit compile_commands.json into the build tree (Ninja / Makefile generators honor this).
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

# Every translation unit under src/ — the exact set the harness measures.
file(GLOB CPP_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")

# A STATIC library compiles each TU (populating the CDB and IDE IntelliSense) without a link
# step, so the freestanding fixture stays buildable regardless of its runtime entry point.
add_library(cpp_lsp_diff STATIC ${CPP_SOURCES})
target_include_directories(cpp_lsp_diff PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src")
