#!/bin/sh
# Usage: $0 <TARGET-NAME>

echo "# This file was autogenerated by 'gen_cmake_qt_sources.sh' - DO NOT EDIT"

echo "qt5_wrap_ui(${1}_FORMS_HEADERS"
find src -name "*.ui" \
  -printf "  \"\${CMAKE_CURRENT_SOURCE_DIR}/%p\"\n" | \
  sort || exit
echo ")"

echo "qt5_add_resources(${1}_RESOURCES_CPP"
find resources -name "*.qrc" \
  -printf "  \"\${CMAKE_CURRENT_SOURCE_DIR}/%p\"\n" | \
  sort || exit
echo ")"

echo "qt5_add_translation(${1}_TRANSLATIONS_QM"
find translations -name "*.ts" \
  -printf "  \"\${CMAKE_CURRENT_SOURCE_DIR}/%p\"\n" | \
  sort || exit
echo ")"

echo "target_sources($1"
echo "  PUBLIC"
echo "    \${${1}_FORMS_HEADERS}"
echo "  PRIVATE"
echo "    \${${1}_RESOURCES_CPP}"
echo "    \${${1}_TRANSLATIONS_QM}"
echo ")"
