cmake_minimum_required(VERSION 3.20)

# odr_console — lanzador GUI + bucle reactivo 5 pasos. Issue 0066.
# Stack: ImGui + SQLite (registry.db RO). DuckDB y jobs_pool: fases siguientes.

# SQLite3: prefer parent target. Fallback a vendored.
find_package(SQLite3 QUIET)
if(NOT SQLite3_FOUND AND NOT TARGET sqlite3_vendored)
    set(SQLITE3_AMALG_DIR ${CMAKE_SOURCE_DIR}/vendor/sqlite3)
    add_library(sqlite3_vendored STATIC ${SQLITE3_AMALG_DIR}/sqlite3.c)
    target_include_directories(sqlite3_vendored PUBLIC ${SQLITE3_AMALG_DIR})
    target_compile_definitions(sqlite3_vendored PRIVATE
        SQLITE_THREADSAFE=1
        SQLITE_ENABLE_FTS5
        SQLITE_ENABLE_JSON1
    )
    add_library(SQLite::SQLite3 ALIAS sqlite3_vendored)
endif()

add_imgui_app(odr_console
    main.cpp
    data_registry.cpp
    data_collectors.cpp
    runner.cpp
)

target_include_directories(odr_console PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}
    ${CMAKE_SOURCE_DIR}/vendor/sqlite3
)

target_link_libraries(odr_console PRIVATE SQLite::SQLite3)

# fn_module_data_table: declarative table rendering stack (issue 0081-J).
if(TARGET fn_module_data_table)
    target_link_libraries(odr_console PRIVATE fn_module_data_table)
endif()

if(WIN32)
    set_target_properties(odr_console PROPERTIES WIN32_EXECUTABLE TRUE)
endif()
