cmake_minimum_required(VERSION 3.20)
project(pqc_interop_harness VERSION 25.0 LANGUAGES C)

find_package(liboqs CONFIG REQUIRED)

set(
    INTEROP_OQS_STATIC_LIBRARY
    "${CMAKE_CURRENT_SOURCE_DIR}/../liboqs/build-interop-tools/lib/liboqs.a"
    CACHE FILEPATH
    "Pinned static liboqs archive used by the native interoperability harness"
)
if(NOT EXISTS "${INTEROP_OQS_STATIC_LIBRARY}")
    message(FATAL_ERROR "Pinned static liboqs archive not found: ${INTEROP_OQS_STATIC_LIBRARY}")
endif()
get_target_property(INTEROP_OQS_INCLUDE_DIRECTORIES OQS::oqs INTERFACE_INCLUDE_DIRECTORIES)
add_library(interop_oqs_static STATIC IMPORTED GLOBAL)
set_target_properties(interop_oqs_static PROPERTIES
    IMPORTED_LOCATION "${INTEROP_OQS_STATIC_LIBRARY}"
    INTERFACE_INCLUDE_DIRECTORIES "${INTEROP_OQS_INCLUDE_DIRECTORIES}"
)
add_library(OQS::oqs_static ALIAS interop_oqs_static)

add_executable(pqc_interop_harness
    interop_harness.c
    interop_common.c
    artifact_store.c
    pqmagic_adapter.c
    liboqs_adapter.c
    interop_cases.c
    interop_vectors.c
    interop_replay.c
)

target_compile_features(pqc_interop_harness PRIVATE c_std_11)
target_include_directories(pqc_interop_harness PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/include")
target_link_libraries(pqc_interop_harness PRIVATE OQS::oqs_static)

if(MSVC)
    target_compile_options(pqc_interop_harness PRIVATE /W4 /WX)
else()
    target_compile_options(pqc_interop_harness PRIVATE -Wall -Wextra -Wpedantic -Werror)
endif()
