set_source_files_properties(2.0/LomiriColors.qml
    PROPERTIES
        QT_QML_SINGLETON_TYPE TRUE
)

set_source_files_properties(2.0/dateUtils.js
    PROPERTIES
        QT_QML_SOURCE_TYPENAME DateUtils
)

qt_add_qml_module(LomiriComponents
    URI Lomiri.Components
    VERSION 2.0
    PLUGIN_TARGET LomiriComponents
    CLASS_NAME LomiriComponentsPlugin
    OUTPUT_DIRECTORY "${QML_BUILD_DIR}/Lomiri/Components"
    NO_GENERATE_EXTRA_QMLDIRS
    NO_GENERATE_QMLTYPES
    NO_GENERATE_PLUGIN_SOURCE
    NO_PLUGIN_OPTIONAL
    SOURCES
        plugin/plugin.cpp
    QML_FILES
        2.0/ActionBar.qml
        2.0/ActionList.qml
        2.0/ActivityIndicator.qml
        2.0/AdaptivePageLayout.qml
        2.0/AnimatedItem.qml
        2.0/AppHeader.qml
        2.0/Button.qml
        2.0/Captions.qml
        2.0/CheckBox.qml
        2.0/ComboButton.qml
        2.0/CrossFadeImage.qml
        2.0/DraggingArea.qml
        2.0/Icon.qml
        2.0/InputHandler.qml
        2.0/Internal__Haptics.qml # fails to load in uchaptics.cpp if marked internal
        2.0/Internal__ListItemPopover.qml
        2.0/LomiriColors.qml
        2.0/LomiriListView.qml
        2.0/LomiriNumberAnimation.qml
        2.0/MainView.qml
        2.0/OptionSelector.qml
        2.0/OptionSelectorDelegate.qml
        2.0/OrientationHelper.qml
        2.0/Page.qml
        2.0/PageColumn.qml
        2.0/PageColumnsLayout.qml
        2.0/PageHeadConfiguration.qml
        2.0/PageHeader.qml
        2.0/PageHeadSections.qml
        2.0/PageHeadState.qml
        2.0/PageStack.qml
        2.0/Panel.qml
        2.0/ProgressBar.qml
        2.0/ProgressionSlot.qml
        2.0/PullToRefresh.qml
        2.0/Scrollbar.qml
        2.0/ScrollView.qml
        2.0/Sections.qml
        2.0/Slider.qml
        2.0/Switch.qml
        2.0/Tab.qml
        2.0/TabBar.qml
        2.0/Tabs.qml
        2.0/TextArea.qml
        2.0/TextCursor.qml
        2.0/TextField.qml
        2.0/TextInputPopover.qml
        2.0/Toolbar.qml
        2.0/ToolbarButton.qml
        2.0/ToolbarItems.qml
        2.0/dateUtils.js
        2.0/pageUtils.js
        2.0/stack.js
    RESOURCES
        artwork/back@18.png
        artwork/chevron@27.png
        artwork/delete@8.png
)

target_link_libraries(LomiriComponents PRIVATE
    LomiriToolkit
    Qt::Core
    Qt::CorePrivate
    Qt::Gui
    Qt::GuiPrivate
    Qt::Qml
    Qt::Quick
)

qt6_add_shaders(LomiriComponents "LomiriComponents_shaders"
    PRECOMPILE
    OPTIMIZED
    FILES
        "2.0/shaders/colorizeimage.frag"
        "2.0/shaders/colourshader.frag"
        "Themes/Ambiance/shaders/magnifier.frag"
        "Themes/Ambiance/shaders/magnifier.vert"
        "Themes/Ambiance/shaders/partialcolorize.frag"
)

install_qml_module(LomiriComponents)

# Woraround for https://qt-project.atlassian.net/browse/QTBUG-144829
# The qmldir "prefer" directive is ignored for scripts in some cases,
# so for now we install the JavaScript file.
install(FILES "2.0/dateUtils.js"
    DESTINATION "${QML_INSTALL_DIR}/Lomiri/Components/2.0"
)

add_subdirectory(Labs)
add_subdirectory(ListItems)
add_subdirectory(Pickers)
add_subdirectory(Popups)
add_subdirectory(Styles)
add_subdirectory(Themes)
