# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2025 ai-ad4 and the FreePDFEditor contributors
# spike/CMakeLists.txt
#
# M0 feasibility spikes (§14). Each spike is its own executable so it can be run
# independently and its results reported separately by CI. The spikes link only
# against the leaf libraries they exercise (QPDF here), not against Qt.

find_package(QPDF CONFIG QUIET)

if(NOT QPDF_FOUND)
    message(STATUS
        "QPDF not found — Spike A (verbatim round-trip) will not be built. "
        "Install qpdf (vcpkg, system package, or from source) to enable it.")
    return()
endif()

add_executable(spike_a_verbatim_roundtrip
    common/SpikeRunner.cpp
    common/SpikeRunner.h
    A_verbatim_roundtrip/main.cpp
    A_verbatim_roundtrip/Roundtrip.cpp
    A_verbatim_roundtrip/Roundtrip.h
)
target_link_libraries(spike_a_verbatim_roundtrip PRIVATE QPDF::qpdf)
target_compile_features(spike_a_verbatim_roundtrip PRIVATE cxx_std_20)
freepdfeditor_apply_warnings(spike_a_verbatim_roundtrip)
freepdfeditor_apply_hardening(spike_a_verbatim_roundtrip)

# Spike C (hb-subset growth of an existing subset font) is left as a placeholder
# until HarfBuzz is wired in; it is exercised from a standalone harness in CI.
if(FALSE)
    find_package(harfbuzz CONFIG QUIET)
    if(harfbuzz_FOUND)
        add_executable(spike_c_subset_growth
            common/SpikeRunner.cpp
            common/SpikeRunner.h
            C_subset_growth/main.cpp
        )
        target_link_libraries(spike_c_subset_growth PRIVATE harfbuzz::harfbuzz harfbuzz::harfbuzz-subset)
    endif()
endif()