cmake_minimum_required(VERSION 3.16)
project(UARTScope VERSION 1.0.0 LANGUAGES CXX)

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

find_package(Qt6 REQUIRED COMPONENTS
    Core
    Gui
    Widgets
    SerialPort
)

set(SOURCES
    src/main.cpp
    src/mainwindow.cpp
    src/serialworker.cpp
    src/rawview.cpp
    src/tableview.cpp
    src/tagwidget.cpp
    src/tagpanel.cpp
    src/connectdialog.cpp
)

set(HEADERS
    include/mainwindow.h
    include/serialworker.h
    include/rawview.h
    include/tableview.h
    include/tagwidget.h
    include/tagpanel.h
    include/connectdialog.h
)

add_executable(uartscope ${SOURCES} ${HEADERS})

target_include_directories(uartscope PRIVATE include)

target_link_libraries(uartscope PRIVATE
    Qt6::Core
    Qt6::Gui
    Qt6::Widgets
    Qt6::SerialPort
)

# Installation
install(TARGETS uartscope DESTINATION bin)

# Optional: create a .desktop file for Linux app launchers
configure_file(
    ${CMAKE_SOURCE_DIR}/uartscope.desktop.in
    ${CMAKE_BINARY_DIR}/uartscope.desktop
    @ONLY
)
install(FILES ${CMAKE_BINARY_DIR}/uartscope.desktop DESTINATION share/applications)
