add_imgui_app(process_explorer
    main.cpp
    http_client.cpp
    hosts_db.cpp
    samples_db.cpp
    agent_protocol.cpp
    # Funciones del registry usadas:
    ${CMAKE_SOURCE_DIR}/functions/viz/kpi_card.cpp
    ${CMAKE_SOURCE_DIR}/functions/viz/sparkline.cpp
    ${CMAKE_SOURCE_DIR}/functions/viz/line_plot.cpp
)
target_include_directories(process_explorer PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

# SQLite for hosts.db + samples.db. fn_framework already links sqlite3 transitively,
# but declaring it here is explicit.
find_package(SQLite3 QUIET)
if(SQLite3_FOUND)
    target_link_libraries(process_explorer PRIVATE SQLite::SQLite3)
endif()

# fn_table_viz: provides data_table::render(), viz_render, TQL engine, Lua, LLM.
# Guard keeps the app compilable in builds where vendor/lua is absent.
if(TARGET fn_table_viz)
    target_link_libraries(process_explorer PRIVATE fn_table_viz)
endif()

if(WIN32)
    target_link_libraries(process_explorer PRIVATE ws2_32 psapi)
    set_target_properties(process_explorer PROPERTIES WIN32_EXECUTABLE TRUE)
endif()
