cmake_minimum_required(VERSION 3.16)

project(llink VERSION 0.1 LANGUAGES CXX)

set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

find_package(Qt6 REQUIRED COMPONENTS
        Core
        Gui
        Widgets
        Network
        Test
        Multimedia
        MultimediaWidgets
)

qt_standard_project_setup(REQUIRES 6.8)

enable_testing()

qt_add_executable(llink
        main.cpp
        src/MainWindow.cpp
        src/MainWindow.h
        src/widgets/VerticalLabel.cpp
        src/widgets/VerticalLabel.h
        src/authmanager.cpp
        src/networkmanager.cpp
        src/dialogs/authdialog.ui
        src/dialogs/authdialog.cpp
        src/dialogs/settingsdialog.h
        src/dialogs/settingsdialog.cpp
        src/models.h
        src/store.h
        src/store.cpp
        src/networkstreammodel.h
        src/networkstreammodel.cpp
        src/particlelistmodel.h
        src/particlelistmodel.cpp
        src/dialogs/textinputdialog.h
        src/dialogs/textinputdialog.cpp
        src/dialogs/createstreamdialog.h
        src/dialogs/createstreamdialog.cpp
        src/dialogs/memberpickerdialog.h
        src/dialogs/memberpickerdialog.cpp
        src/widgets/networkdetailwidget.h
        src/widgets/networkdetailwidget.cpp
        src/media/mediahandler.h
        src/media/mediahandler.cpp
        src/mediaparticlegenerator.h src/mediaparticlegenerator.cpp
        src/dialogs/mediapreviewdialog.h
        src/dialogs/mediapreviewdialog.cpp
        src/widgets/textparticlewidget.h
        src/widgets/textparticlewidget.cpp
        src/widgets/mediaparticlewidget.h
        src/widgets/mediaparticlewidget.cpp
)

qt_add_resources(llink
        PREFIX_PATH "/"
        FILES
        assets/icons/mono/basic/menu.svg
        assets/icons/mono/basic/plus.svg
        assets/FLOWY-4.png
        assets/logo.png
        styles/remarkable.qss
        assets/example_thumbnail.jpg
        assets/Plus_Jakarta_Sans/PlusJakartaSans-VariableFont_wght.ttf
        assets/Plus_Jakarta_Sans/PlusJakartaSans-Italic-VariableFont_wght.ttf
)

qt_add_ios_ffmpeg_libraries(llink)

# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though.
set_target_properties(llink PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER live.flowy.llink
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/macos/Info.plist"
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE $<NOT:$<CONFIG:Debug>>
)

target_link_libraries(llink
        PRIVATE
        Qt6::Core
        Qt6::Gui
        Qt6::Widgets
        Qt6::Network
        Qt6::Multimedia
        Qt6::MultimediaWidgets
)

add_subdirectory(tests)

include(GNUInstallDirs)
install(TARGETS llink
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

qt_generate_deploy_app_script(
        TARGET llink
        OUTPUT_SCRIPT deploy_script
        NO_UNSUPPORTED_PLATFORM_ERROR
)
install(SCRIPT ${deploy_script})
