cmake_minimum_required(VERSION 3.16)

project(GostGenerator VERSION 1.0.0 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(Qt5 REQUIRED COMPONENTS Core Widgets Sql Concurrent Quick QuickWidgets PrintSupport)

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")

# Исходные файлы
set(SOURCES
    main.cpp
    controller/maincontroller.cpp
    controller/altiumparser.cpp
    controller/databasecontroller.cpp
    model/componentmodel.cpp
    model/componenttablemodel.cpp
    model/paramtable.cpp
    model/projectparammodel.cpp
    model/projectparamtablemodel.cpp
    model/projectsettingsmodel.cpp
    model/titleinscriptionsmodel.cpp
    model/designatormappingmodel.cpp
    model/designatormappingtablemodel.cpp
    model/perechentablemodel.cpp
    model/specificationpcbtablemodel.cpp
    model/specificationtablemodel.cpp
    model/vedomosttablemodel.cpp
    model/pcbmaterialmodel.cpp
    view/adddesignatordialog.cpp
    view/basegosttable.cpp
    view/componentspreview.cpp
    view/columnsettingsdialog.cpp
    view/freezetablewidget.cpp
    view/pcbmaterialpreview.cpp
    view/designatormappingdialog.cpp
    view/documentprocessor.cpp
    controller/perechentablecontroller.cpp
    controller/specificationpcbcontroller.cpp
    controller/specificationcontroller.cpp
    controller/vedomostcontroller.cpp
    controller/csvexporter.cpp
    view/editpdfwidget.cpp
    view/importeddataview.cpp
    view/mainwindow.cpp
    view/previewpdfwidget.cpp
    view/projectparampreview.cpp
    view/projectsettingsdialog.cpp
    view/titleinscriptionsdialog.cpp
    view/documentsettingsdialog.cpp
    view/cellsettingsdialog.cpp
    view/pagebreakconfirmationdialog.cpp
)

# Заголовочные файлы
set(HEADERS
    controller/maincontroller.h
    controller/altiumparser.h
    controller/databasecontroller.h
    model/componentmodel.h
    model/componenttablemodel.h
    model/paramtable.h
    model/projectparammodel.h
    model/projectparamtablemodel.h
    model/projectsettingsmodel.h
    model/titleinscriptionsmodel.h
    model/designatormappingmodel.h
    model/designatormappingtablemodel.h
    model/perechentablemodel.h
    model/specificationpcbtablemodel.h
    model/specificationtablemodel.h
    model/vedomosttablemodel.h
    model/pcbmaterialmodel.h
    view/adddesignatordialog.h
    view/basegosttable.h
    view/columnsettingsdialog.h
    view/componentspreview.h
    view/freezetablewidget.h
    view/pcbmaterialpreview.h
    view/designatormappingdialog.h
    view/documentprocessor.h
    controller/perechentablecontroller.h
    controller/specificationpcbcontroller.h
    controller/specificationcontroller.h
    controller/vedomostcontroller.h
    controller/csvexporter.h
    view/editpdfwidget.h
    view/importeddataview.h
    view/mainwindow.h
    view/previewpdfwidget.h
    view/projectparampreview.h
    view/projectsettingsdialog.h
    view/titleinscriptionsdialog.h
    view/documentsettingsdialog.h
    view/cellsettingsdialog.h
    view/titleinscriptiontypes.h
    view/pagebreakconfirmationdialog.h
)

# Создание исполняемого файла
if(WIN32)
    add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}
        qml.qrc
        app_icon.rc
        controller/pdfcontroller.h controller/pdfcontroller.cpp)
else()
    add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}
        qml.qrc
        controller/pdfcontroller.h controller/pdfcontroller.cpp)
endif()

# Подключение Qt модулей
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Widgets Qt5::Sql Qt5::Concurrent Qt5::Quick Qt5::QuickWidgets Qt5::PrintSupport)

# Установка
install(TARGETS ${PROJECT_NAME}
    BUNDLE DESTINATION .
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
