This is a very small demo on how I solved the problem of getting git information into my C application. This is partially based on a blog post by Matthew Keeter.
mkdir build
cd build
cmake ..
make
Then just execute it from the build directory:
./src/demo