# A throwaway downstream project. It knows nothing about NeoGraph's source tree
# — it only sees an install prefix, exactly like a real consumer would.
#
# If this configures, builds and runs, then `find_package(NeoGraph)` works. If
# it does not, the library is not consumable no matter how green the unit tests
# are (issue #92).
cmake_minimum_required(VERSION 3.16)
project(neograph_consumer LANGUAGES CXX)

find_package(NeoGraph CONFIG REQUIRED)

if(DEFINED NEOGRAPH_EXPECTED_ABI_SOVERSION
   AND NOT NEOGRAPH_ABI_SOVERSION STREQUAL NEOGRAPH_EXPECTED_ABI_SOVERSION)
    message(FATAL_ERROR
        "NeoGraph ABI generation mismatch: package reports "
        "${NEOGRAPH_ABI_SOVERSION}, expected ${NEOGRAPH_EXPECTED_ABI_SOVERSION}")
endif()

add_executable(consumer main.cpp)
target_link_libraries(consumer PRIVATE neograph::core)
if(TARGET neograph::mcp_sqlite)
    target_link_libraries(consumer PRIVATE neograph::mcp_sqlite)
    target_compile_definitions(consumer PRIVATE NEOGRAPH_CONSUMER_HAS_MCP_SQLITE)
endif()
if(TARGET neograph::a2a)
    target_link_libraries(consumer PRIVATE neograph::a2a)
    target_compile_definitions(consumer PRIVATE NEOGRAPH_CONSUMER_HAS_A2A)
endif()
if(TARGET neograph::acp)
    target_link_libraries(consumer PRIVATE neograph::acp)
    target_compile_definitions(consumer PRIVATE NEOGRAPH_CONSUMER_HAS_ACP)
endif()
