CLI's main() scaffolding

Again, this is mostly a copy-paste from the other project.

Change-Id: Ic72aee3a46644afc91d9f1d7ca8ab22d477608ef
diff --git a/cmake/ProjectGitVersionRunner.cmake b/cmake/ProjectGitVersionRunner.cmake
new file mode 100644
index 0000000..38fdf28
--- /dev/null
+++ b/cmake/ProjectGitVersionRunner.cmake
@@ -0,0 +1,22 @@
+if(GIT_EXECUTABLE AND EXISTS ${PROJECT_SOURCE_DIR}/.git)
+    execute_process(COMMAND ${GIT_EXECUTABLE} describe --dirty --long --always --tags
+        WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
+        OUTPUT_VARIABLE ${VERSION_VARIABLE})
+    string(REPLACE "\n" "" "${VERSION_VARIABLE}" ${${VERSION_VARIABLE}})
+endif()
+
+if(${VERSION_VARIABLE})
+    set(${VERSION_VARIABLE}_H
+        "#define ${VERSION_VARIABLE} \"${${VERSION_VARIABLE}}\"\n"
+        )
+    message(STATUS "Building ${PROJECT_NAME} Git version ${${VERSION_VARIABLE}}")
+else()
+    set(${VERSION_VARIABLE}_H
+        "#define ${VERSION_VARIABLE} \"${FALLBACK_VERSION}\"\n"
+        )
+    message(STATUS "Building ${PROJECT_NAME} version: ${${VERSION_VARIABLE}}")
+endif()
+
+file(WRITE ${PROJECT_BINARY_DIR}/${VERSION_VARIABLE}.h.in ${${VERSION_VARIABLE}_H})
+execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
+    ${PROJECT_BINARY_DIR}/${VERSION_VARIABLE}.h.in ${PROJECT_BINARY_DIR}/${VERSION_VARIABLE}.h)