include_directories(${ANDR_PROP_INCLUDE_DIRS})
include_directories(${DEVICEINFO_INCLUDE_DIRS})
include_directories(${GLIB_INCLUDE_DIRS})
include_directories(${GIO_INCLUDE_DIRS})
include_directories(${CLICK_INCLUDE_DIRS})
include_directories(${CLICK_INCLUDE_DIRS})
add_definitions(-DQT_NO_KEYWORDS)

if(DEVICEINFO_FOUND)
    add_definitions(-DENABLE_DEVICEINFO)
endif()

set(QML_SOURCES
    EntryComponent.qml
    License.qml
    PageComponent.qml
    SingleValueStacked.qml
    Software.qml
    Storage.qml
    StorageBar.qml
    StorageItem.qml
    Version.qml
    DevMode.qml
    fakepkgslist.xml
)

add_library(LomiriStorageAboutPanel MODULE
    plugin.cpp
    storageabout.cpp
    systeminfo.cpp
    click.cpp
    plugin.h
    storageabout.h
    click.h
    ${QML_SOURCES} # So they show up in Qt designer.
)

target_link_libraries(LomiriStorageAboutPanel Qt5::Qml Qt5::Quick Qt5::DBus
${ANDR_PROP_LDFLAGS} ${DEVICEINFO_LDFLAGS} ${GLIB_LDFLAGS} ${GIO_LDFLAGS} ${CLICK_LDFLAGS} LomiriSystemSettingsPrivate)

set(DISTRIBUTOR_LOGO "" CACHE PATH "Path to distributor logo file.")
set(DARK_MODE_DISTRIBUTOR_LOGO ""
    CACHE PATH "Path to distributor logo file for dark mode/dark background.")

if(NOT (DISTRIBUTOR_LOGO STREQUAL ""))
    target_compile_definitions(LomiriStorageAboutPanel PRIVATE
        -DDISTRIBUTOR_LOGO=\"${DISTRIBUTOR_LOGO}\")

    if(NOT (DARK_MODE_DISTRIBUTOR_LOGO STREQUAL ""))
        target_compile_definitions(LomiriStorageAboutPanel PRIVATE
            -DDARK_MODE_DISTRIBUTOR_LOGO=\"${DARK_MODE_DISTRIBUTOR_LOGO}\")
    endif()
elseif(NOT (DARK_MODE_DISTRIBUTOR_LOGO STREQUAL ""))
    message(FATAL_ERROR
        "DARK_MODE_DISTRIBUTOR_LOGO cannot be set without DISTRIBUTOR_LOGO")
endif()

set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Lomiri/SystemSettings/StorageAbout)
install(TARGETS LomiriStorageAboutPanel DESTINATION ${PLUG_DIR})
install(FILES qmldir DESTINATION ${PLUG_DIR})
install(FILES ${QML_SOURCES} DESTINATION ${PLUGIN_QML_DIR}/about)
install(FILES about.settings DESTINATION ${PLUGIN_MANIFEST_DIR})
