#!/bin/bash
set -e

tmpdir="$(mktemp -d)"
trap "rm -rf $tmpdir" EXIT
cd "$tmpdir"

cat >"CMakeLists.txt" << EOF
cmake_minimum_required(VERSION 3.1)
project(test)
find_package(TinyGLTF REQUIRED)
add_executable(test_tinygltf test_tinygltf.cpp)
target_link_libraries(test_tinygltf TinyGLTF::TinyGLTF)
EOF

cat >"test_tinygltf.cpp" << EOF
#include <tiny_gltf.h>

int main (int argc, char** argv)
{
	tinygltf::Model model;
	tinygltf::TinyGLTF ctx;
	return 0;
}
EOF
echo '$' cmake .
cmake .
echo '$' make VERBOSE=ON
make VERBOSE=ON
echo '$' ./test_tinygltf
./test_tinygltf
