cmake_minimum_required(VERSION 3.20)
project(photogallery_uploader LANGUAGES CXX)

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

find_package(Qt6 REQUIRED COMPONENTS Widgets Network Concurrent)
find_package(Qt6Keychain REQUIRED)

add_executable(uploader
    main.cpp
    mainwindow.cpp
    photoitemwidget.cpp
    settings.cpp
    uploadclient.cpp
    imageprep.cpp
    app.qrc
)

target_link_libraries(uploader PRIVATE
    Qt6::Widgets
    Qt6::Network
    Qt6::Concurrent
    Qt6Keychain::Qt6Keychain
)

# Installation — the binary, a desktop entry, and the app icon in the hicolor
# theme, so `nix profile install ./desktop` puts "Photog" in the app menu.
include(GNUInstallDirs)
install(TARGETS uploader RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES photog.desktop DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
foreach(sz 32 128 256 512)
    install(FILES icons/app-${sz}.png
            DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/${sz}x${sz}/apps
            RENAME photog.png)
endforeach()
