Initial commit

Change-Id: I6a4444e3c193dae437cd7929f4c39aba7b749efa
diff --git a/cmake/Modules/GetVersionWithHg.cmake b/cmake/Modules/GetVersionWithHg.cmake
new file mode 100644
index 0000000..9fcf392
--- /dev/null
+++ b/cmake/Modules/GetVersionWithHg.cmake
@@ -0,0 +1,23 @@
+# This file is called at build time. It regenerates the version.h file based on the hg version.
+
+EXECUTE_PROCESS(
+	COMMAND ${HGCOMMAND} id -i
+	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+	RESULT_VARIABLE reshash
+	OUTPUT_VARIABLE verhash
+	ERROR_QUIET
+	OUTPUT_STRIP_TRAILING_WHITESPACE)
+EXECUTE_PROCESS(
+	COMMAND ${HGCOMMAND} id -n
+	WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+	RESULT_VARIABLE resval
+	OUTPUT_VARIABLE verval
+	ERROR_QUIET
+	OUTPUT_STRIP_TRAILING_WHITESPACE)
+	
+if (reshash EQUAL 0) 
+	SET(FD_PROJECT_VERSION_HG "${verval}(${verhash})")
+ 	message(STATUS "Source version: ${FD_PROJECT_VERSION_HG}")
+endif (reshash EQUAL 0)
+
+CONFIGURE_FILE(${SRC} ${DST})