# DpiWidgets: Qt Widgets equivalent of the Lazarus/Delphi "DpiControls"
# package found at ../../cevo/Packages/DpiControls. It provides a Dpi::
# namespace of thin wrappers around Qt widgets, following the same unit
# breakdown (Common, Graphics, PixelPointer, Controls, Forms, StdCtrls,
# ExtCtrls, ComCtrls, Grids, Menus, Spin), to ease porting the C-evo UI code.

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)

set(DPI_WIDGETS_HEADERS
    include/Dpi/DpiCommon.h
    include/Dpi/DpiPixelPointer.h
    include/Dpi/DpiGraphics.h
    include/Dpi/DpiControls.h
    include/Dpi/DpiForms.h
    include/Dpi/DpiStdCtrls.h
    include/Dpi/DpiExtCtrls.h
    include/Dpi/DpiComCtrls.h
    include/Dpi/DpiGrids.h
    include/Dpi/DpiMenus.h
    include/Dpi/DpiSpin.h
    include/Dpi/DpiWidgets.h
)

set(DPI_WIDGETS_SOURCES
    src/DpiCommon.cpp
    src/DpiPixelPointer.cpp
    src/DpiGraphics.cpp
    src/DpiControls.cpp
    src/DpiForms.cpp
    src/DpiStdCtrls.cpp
    src/DpiExtCtrls.cpp
    src/DpiComCtrls.cpp
    src/DpiGrids.cpp
    src/DpiMenus.cpp
    src/DpiSpin.cpp
)

add_library(dpiwidgets SHARED ${DPI_WIDGETS_SOURCES} ${DPI_WIDGETS_HEADERS})

target_include_directories(dpiwidgets PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(dpiwidgets PUBLIC Qt${QT_VERSION_MAJOR}::Widgets)

set_target_properties(dpiwidgets PROPERTIES
    AUTOMOC ON
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
)

# CevoWidgets: Qt equivalent of the C-evo-specific "CevoComponents" package
# (../../cevo/Packages/CevoComponents), built on top of Dpi:: above. Provides
# a Cevo:: namespace (Area, ButtonBase/A/B/C/G/N, EOTButton, ListBoxEx,
# DrawDlg/BaseMessgDlg, BufferedDrawDlg/FramedDlg, GraphicSet, Texture,
# ScreenTools' drawing helpers). Directories, StringTables, AsyncProcess2 and
# Sound are not ported: they are plain platform/data utilities (QProcess
# already covers AsyncProcess2's job; Sound is superseded by ../media).

set(CEVO_WIDGETS_HEADERS
    include/Cevo/CevoArea.h
    include/Cevo/CevoBaseWin.h
    include/Cevo/CevoButtonA.h
    include/Cevo/CevoButtonB.h
    include/Cevo/CevoButtonBase.h
    include/Cevo/CevoButtonC.h
    include/Cevo/CevoButtonG.h
    include/Cevo/CevoButtonN.h
    include/Cevo/CevoDrawDlg.h
    include/Cevo/CevoEOTButton.h
    include/Cevo/CevoGraphicSet.h
    include/Cevo/CevoListBoxEx.h
    include/Cevo/CevoScreenTools.h
    include/Cevo/CevoTexture.h
    include/Cevo/CevoWidgets.h
)

set(CEVO_WIDGETS_SOURCES
    src/CevoArea.cpp
    src/CevoBaseWin.cpp
    src/CevoButtonA.cpp
    src/CevoButtonB.cpp
    src/CevoButtonBase.cpp
    src/CevoButtonC.cpp
    src/CevoButtonG.cpp
    src/CevoButtonN.cpp
    src/CevoDrawDlg.cpp
    src/CevoEOTButton.cpp
    src/CevoGraphicSet.cpp
    src/CevoListBoxEx.cpp
    src/CevoScreenTools.cpp
    src/CevoTexture.cpp
)

add_library(cevowidgets SHARED ${CEVO_WIDGETS_SOURCES} ${CEVO_WIDGETS_HEADERS})

target_include_directories(cevowidgets PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/include
)

target_link_libraries(cevowidgets PUBLIC dpiwidgets Qt${QT_VERSION_MAJOR}::Widgets)

set_target_properties(cevowidgets PROPERTIES
    AUTOMOC ON
    CXX_STANDARD 17
    CXX_STANDARD_REQUIRED ON
)

include(GNUInstallDirs)
install(TARGETS dpiwidgets cevowidgets
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/cevo-evo
    RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}/cevo-evo
)
