cmake_minimum_required(VERSION 3.16)
project(multiviewport LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)

if(NOT DEFINED INSTALL_EXAMPLESDIR)
    set(INSTALL_EXAMPLESDIR "examples")
endif()

set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}")

find_package(Qt6 REQUIRED COMPONENTS 3DCore 3DInput 3DQuick 3DQuickExtras 3DRender Core Gui Qml Quick)

qt_add_executable(multiviewport
    main.cpp
)

set_target_properties(multiviewport PROPERTIES
    WIN32_EXECUTABLE TRUE
    MACOSX_BUNDLE TRUE
)

target_link_libraries(multiviewport PUBLIC
    Qt::3DCore
    Qt::3DInput
    Qt::3DQuick
    Qt::3DQuickExtras
    Qt::3DRender
    Qt::Core
    Qt::Gui
    Qt::Qml
    Qt::Quick
)

# Resources:
set(multiviewport_resource_files
    "Gear_scene.dae"
    "QuadViewportFrameGraph.qml"
    "SimpleCamera.qml"
    "main.qml"
)

qt6_add_resources(multiviewport "multiviewport"
    PREFIX
        "/"
    FILES
        ${multiviewport_resource_files}
)

set(test_scene_resource_files
    "../exampleresources/assets/test_scene.dae"
)

qt6_add_resources(multiviewport "test_scene"
    PREFIX
        "/"
    BASE
        "../exampleresources"
    FILES
        ${test_scene_resource_files}
)

install(TARGETS multiviewport
    RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
    BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
    LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
)
