# CMakeLists.txt Template für Ubuntu Touch Apps
# Basierend auf metime und Referenz-App (Version 1.7)
#
# VERWENDUNG:
# 1. Kopiere diese Datei nach CMakeLists.txt in deinem Projekt
# 2. Ersetze fortunecookie mit deinem App-Namen
#
# WICHTIG (1.7):
# - builder: pure-qml-cmake (für QML+Python-Apps)
# - architecture: all (pure-qml-cmake erzwingt das)
# - CMAKE_AUTOMOC ON (für Qt5)
#
# Für Apps MIT nativem C++-Code:
#   Füge zusätzliche Qt5-Komponenten hinzu

cmake_minimum_required(VERSION 3.0.0)
project(fortunecookie C CXX)

# Qt5
set(CMAKE_AUTOMOC ON)

# Architektur-Triplet (für Qt5-Bibliotheken)
execute_process(
    COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
    OUTPUT_VARIABLE ARCH_TRIPLET
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
set(QT_IMPORTS_DIR "lib/${ARCH_TRIPLET}")

# Projekt-Metadaten
set(PROJECT_NAME "fortunecookie")
set(FULL_PROJECT_NAME "fortunecookie.darklithium")
set(DATA_DIR /)

# Manifest und Desktop-Datei generieren
configure_file(manifest.json.in ${CMAKE_CURRENT_BINARY_DIR}/manifest.json)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/manifest.json DESTINATION ${CMAKE_INSTALL_PREFIX})
install(FILES ${PROJECT_NAME}.apparmor DESTINATION ${DATA_DIR})

# Desktop-Datei konfigurieren (ersetzt Variablen und entfernt Kommentare)
configure_file(${PROJECT_NAME}.desktop.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop DESTINATION ${DATA_DIR})

# Dateien installieren
install(DIRECTORY assets DESTINATION ${DATA_DIR})
install(DIRECTORY src DESTINATION ${DATA_DIR})
install(DIRECTORY qml DESTINATION ${DATA_DIR})

# ============================================================================
# OPTIONAL: Für Apps mit Übersetzungen (po/)
# ============================================================================
# Falls du Übersetzungen brauchst, entkommentiere die folgenden Zeilen:
#
# find_program(INTLTOOL_MERGE intltool-merge)
# if(NOT INTLTOOL_MERGE)
#     message(FATAL_ERROR "intltool-merge nicht gefunden, bitte intltool installieren")
# endif()
#
# find_program(INTLTOOL_EXTRACT intltool-extract)
# if(NOT INTLTOOL_EXTRACT)
#     message(FATAL_ERROR "intltool-extract nicht gefunden, bitte intltool installieren")
# endif()
#
# file(GLOB_RECURSE I18N_SRC_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}/po qml/*.qml)
# list(APPEND I18N_SRC_FILES ${PROJECT_NAME}.desktop.in.h)
#
# add_custom_target(${PROJECT_NAME}_desktop ALL
#     COMMENT "Generiere Desktop-Datei..."
#     COMMAND LC_ALL=C ${INTLTOOL_MERGE} -d -u ${CMAKE_SOURCE_DIR}/po ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.desktop.in ${PROJECT_NAME}.desktop
#     COMMAND sed -i 's/${PROJECT_NAME}-//g' ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop
# )
#
# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.desktop DESTINATION ${DATA_DIR})
# add_subdirectory(po)
