use rev info from the just created file when configuring without mercurial
authorkoda
Mon, 04 Mar 2013 13:44:33 +0100
changeset 8642 d7062e684466
parent 8641 f3aa0d48a600
child 8643 e4d1c21f8db0
use rev info from the just created file when configuring without mercurial
CMakeLists.txt
--- a/CMakeLists.txt	Mon Mar 04 13:30:33 2013 +0100
+++ b/CMakeLists.txt	Mon Mar 04 13:44:33 2013 +0100
@@ -61,9 +61,19 @@
     file(WRITE "${CMAKE_SOURCE_DIR}/share/version_info.txt" "Hedgewars versioning information, do not modify\nrev ${revision_number}\nhash ${hash_number}\n")
 else()
     set(default_build_type "RELEASE")
-    # TODO think of a better fallback when hg not found
-    set(revision_number "0000")
-    set(hash_number "unknown")
+    # when compiling outside rev control, fetch revision and hash information from version_info.txt
+    find_file(version_info version_info.txt PATH ${CMAKE_SOURCE_DIR}/share)
+    if(version_info)
+        file(STRINGS ${version_info} internal_version REGEX "rev")
+        string(REGEX REPLACE "rev ([0-9]*)" "\\1" revision_number ${internal_version})
+        file(STRINGS ${version_info} internal_version REGEX "hash")
+        string(REGEX REPLACE "hash: ([a-zA-Z0-9]*)" "\\1" hash_number ${internal_version})
+    else()
+        message(${WARNING} "${CMAKE_SOURCE_DIR}/share/version_info.txt not found, revision information "
+                           "will be incorrect!!! Contact your source provider to fix this!")
+        set(revision_number "0000")
+        set(hash_number "unknown")
+    endif()
 endif()