CMakeLists.txt
changeset 455 d99f47386d51
parent 423 ee393c1cf3b4
child 465 0a75f98f785b
--- a/CMakeLists.txt	Wed Sep 24 07:27:26 2008 -0400
+++ b/CMakeLists.txt	Wed Nov 05 20:53:05 2008 -0500
@@ -1,6 +1,33 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
 PROJECT(MojoShader)
 
+EXECUTE_PROCESS(
+    COMMAND hg tip --template {rev}
+    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+    RESULT_VARIABLE HGVERSION_RC
+    OUTPUT_VARIABLE MOJOSHADER_VERSION
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+EXECUTE_PROCESS(
+    COMMAND hg tip --template hg-{rev}:{node|short}
+    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
+    RESULT_VARIABLE HGVERSION_RC
+    OUTPUT_VARIABLE MOJOSHADER_CHANGESET
+    ERROR_QUIET
+    OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+
+WRITE_FILE(
+    "${CMAKE_CURRENT_SOURCE_DIR}/mojoshader_version.h"
+    "/* This file was autogenerated. Do not edit! */\n"
+    "#ifndef _INCL_MOJOSHADER_VERSION_H_\n"
+    "#define _INCL_MOJOSHADER_VERSION_H_\n"
+    "#define MOJOSHADER_VERSION ${MOJOSHADER_VERSION}\n"
+    "#define MOJOSHADER_CHANGESET \"${MOJOSHADER_CHANGESET}\"\n"
+    "#endif\n"
+)
+
 IF(CMAKE_COMPILER_IS_GNUCC)
     ADD_DEFINITIONS(-Wall -ggdb3)
 ENDIF(CMAKE_COMPILER_IS_GNUCC)