#!/bin/sh
# Build the demo through the installed CMake package configuration, which is
# the other interface the development package ships.
set -e

TESTDIR=$(dirname "$0")
cp "$TESTDIR/calendar-demo.c" "$AUTOPKGTEST_TMP/"
cd "$AUTOPKGTEST_TMP"

cat > CMakeLists.txt <<'CMAKE'
cmake_minimum_required(VERSION 3.16)
project(calendar-demo LANGUAGES C)
find_package(libcalendars REQUIRED)
add_executable(demo calendar-demo.c)
target_link_libraries(demo PRIVATE calendars)
CMAKE

cmake -S . -B build
cmake --build build
./build/demo
