#!/bin/sh
# autopkgtest check: Build and run a program against ign-transport, to verify that the
# headers and pkg-config file are installed correctly
# (C) 2012 Jose Luis Rivero
# Author: Jose Luis Rivero <jrivero@osrfoundation.org>

set -e

WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > igntest.cc
#include <ignition/transport.hh>

int main()
{
    // Create a transport node.
    ignition::transport::Uuid uuid;
    return 0;
}
EOF

g++ -o igntest igntest.cc `pkg-config --cflags --libs ignition-transport11`
echo "build: OK"
[ -x igntest ]
./igntest
echo "run: OK"

cat <<EOF > CMakeLists.txt
cmake_minimum_required(VERSION 3.5)

project(ign_test VERSION 1.0.0)

find_package(ignition-transport11 11.0.0 REQUIRED)
add_executable(igntest igntest.cc)
target_link_libraries(igntest
   PUBLIC
      ignition-transport11::ignition-transport11)
EOF

cmake .
echo "configure cmake with component: OK"
make
echo "build cmake component:OK"
[ -x igntest ]
./igntest
echo "run: OK"
