cmake_minimum_required(VERSION 3.16)
project(chatter VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_AUTOMOC ON)

# Per reMarkable's qt_epaper guide: pure Qt Quick (no Qt Widgets).
find_package(Qt6 REQUIRED COMPONENTS Quick Gui)

qt_standard_project_setup(REQUIRES 6.5)

qt_add_executable(chatter
    src/main.cpp
    src/PenDevice.h
    src/PenDevice.cpp
    src/AppControl.h
    src/AppControl.cpp
    src/InkEngine.h
    src/InkEngine.cpp
    src/FbCapture.h
    src/FbCapture.cpp
    src/epfb.h
)

qt_add_qml_module(chatter
    URI Chatter
    VERSION 1.0
    QML_FILES
        qml/Main.qml
)

target_link_libraries(chatter PRIVATE
    Qt6::Quick
    Qt6::Gui
    # EPFramebuffer::instance/swapBuffers live in the epaper scenegraph plugin.
    ${CMAKE_SYSROOT}/usr/lib/plugins/scenegraph/libqsgepaper.so
)

# Export the executable's dynamic symbols so our setBuffers interposer (in
# FbCapture.cpp) wins the cross-DSO call from the epaper platform plugin.
target_link_options(chatter PRIVATE -Wl,--export-dynamic)
