# SPDX-FileCopyrightText: 2026 Marco Allegretti
# SPDX-License-Identifier: EUPL-1.2

set(SHIFT_INSTALL_PREVIEW_QML_STUBS "AUTO" CACHE STRING "Install preview fallback QML stubs: AUTO, ON, or OFF")
set_property(CACHE SHIFT_INSTALL_PREVIEW_QML_STUBS PROPERTY STRINGS AUTO ON OFF)

if(NOT SHIFT_INSTALL_PREVIEW_QML_STUBS MATCHES "^(AUTO|ON|OFF)$")
    message(FATAL_ERROR "SHIFT_INSTALL_PREVIEW_QML_STUBS must be AUTO, ON, or OFF")
endif()

set(_shift_install_preview_qml_stubs OFF)
if(SHIFT_INSTALL_PREVIEW_QML_STUBS STREQUAL "ON")
    set(_shift_install_preview_qml_stubs ON)
elseif(SHIFT_INSTALL_PREVIEW_QML_STUBS STREQUAL "AUTO" AND CMAKE_INSTALL_PREFIX MATCHES "/\\.prefix$")
    set(_shift_install_preview_qml_stubs ON)
endif()

if(_shift_install_preview_qml_stubs)
    install(
        DIRECTORY qml/
        DESTINATION ${KDE_INSTALL_QMLDIR}
        FILES_MATCHING
            PATTERN "*.qml"
            PATTERN "qmldir"
    )
endif()