CMakeLists.txt
changeset 8090 38d9cc60b14c
parent 8089 56bf04303311
child 8093 2286a39140da
--- a/CMakeLists.txt	Wed Nov 21 15:03:33 2012 +0100
+++ b/CMakeLists.txt	Wed Nov 21 18:34:45 2012 +0100
@@ -11,34 +11,48 @@
 #use available modules, fallback to ours if not present (CMP0017 helps)
 set(CMAKE_MODULE_PATH "${CMAKE_ROOT}/Modules" "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules")
 
+#set some default values
+option(NOREVISION "Build Hedgewars without revision information" OFF)
+
+option(NOSERVER "Disable gameServer build [default: auto]" OFF)
+option(NOPNG "Disable screenshoot compression [default: auto]" OFF)
+option(NOVIDEOREC "Disable video recording [default: auto]" OFF)
+
+option(BUILD_ENGINE_LIBRARY "Enable hwengine library [default: off]" OFF)
+option(ANDROID "Enable Android build [default: off]" OFF)
+option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF)
+option(CROSSAPPLE "Enable OSX when not on OSX [default: off]" OFF)
+option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF)
 
 #detect Mercurial revision (if present)
-set(version_suffix "-dev") #UNSET THIS VARIABLE AT RELEASE TIME
-set(HGCHANGED "")
-IF(version_suffix MATCHES "-dev")
-    set(HW_DEV true)
+IF(NOT NOREVISION)
     set(default_build_type "DEBUG")
-    IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.hg)
-        FIND_PROGRAM(HGCOMMAND hg)
-        IF(HGCOMMAND)
-            exec_program(${HGCOMMAND}
-                     ARGS identify -in ${CMAKE_CURRENT_SOURCE_DIR}
-                     OUTPUT_VARIABLE version_suffix
-                     )
-            STRING(REGEX REPLACE "[^+]" "" HGCHANGED ${version_suffix})
-            STRING(REGEX REPLACE "([0-9a-zA-Z]+)(.*) ([0-9]+)(.*)" "\\3-\\1" version_suffix ${version_suffix})
-            IF (HGCHANGED)
-                MESSAGE(STATUS "Building revision ${version_suffix} (SOURCE CODE MODIFIED)")
-            ELSE()
-                MESSAGE(STATUS "Building revision ${version_suffix}")
-            ENDIF()
-            set(version_suffix "-${version_suffix}")
+    set(version_suffix "-development_version")
+    set(HW_DEV true)
+    FIND_PROGRAM(HGCOMMAND hg)
+    IF(HGCOMMAND AND (EXISTS ${CMAKE_SOURCE_DIR}/.hg))
+        execute_process(COMMAND ${HGCOMMAND} identify -in
+                        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+                        OUTPUT_VARIABLE internal_version
+                        ERROR_QUIET
+                    )
+        #check local repo status
+        STRING(REGEX REPLACE "[^+]" "" HGCHANGED ${internal_version})
+
+        STRING(REGEX REPLACE "[0-9a-zA-Z]+(.*) ([0-9]+)(.*)" "\\2" revision_number ${internal_version})
+        STRING(REGEX REPLACE "([0-9a-zA-Z]+)(.*) [0-9]+(.*)" "\\1" revision_hash ${internal_version})
+
+        MESSAGE(STATUS "Building revision ${revision_number} from hash ${revision_hash} ${HGCHANGED}")
+        IF(HGCHANGED)
+            MESSAGE(WARNING "You have uncommitted changes")
         ENDIF()
+        set(version_suffix "-${revision_number}${HGCHANGED}")
     ENDIF()
-ELSE()
-    set(HW_DEV false)
+ELSE(NOT NOREVISION)
     set(default_build_type "RELEASE")
-ENDIF()
+    set(HWDEV false)
+    MESSAGE(STATUS "Building distributable version")
+ENDIF(NOT NOREVISION)
 
 
 #versioning
@@ -49,17 +63,6 @@
 set(HEDGEWARS_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
 
 
-#set some default values
-option(NOSERVER "Disable gameServer build [default: auto]" OFF)
-option(NOPNG "Disable screenshoot compression [default: auto]" OFF)
-option(NOVIDEOREC "Disable video recording [default: auto]" OFF)
-
-option(BUILD_ENGINE_LIBRARY "Enable hwengine library [default: off]" OFF)
-option(ANDROID "Enable Android build [default: off]" OFF)
-option(NOAUTOUPDATE "Disable OS X Sparkle update checking" OFF)
-option(CROSSAPPLE "Enable OSX when not on OSX [default: off]" OFF)
-option(MINIMAL_FLAGS "Respect system flags as much as possible [default: off]" OFF)
-
 #bundle .app setup
 if(APPLE OR CROSSAPPLE)
     #paths for creating the bundle
@@ -82,7 +85,7 @@
     #detect on which system we are: if sw_vers cannot be found for any reason (re)use minimum_macosx_version
     find_program(sw_vers sw_vers)
     if(sw_vers)
-        exec_program(${sw_vers} ARGS "-productVersion" OUTPUT_VARIABLE current_macosx_version)
+        execute_process(COMMAND ${sw_vers} "-productVersion" OUTPUT_VARIABLE current_macosx_version)
         string(REGEX REPLACE "([0-9]+.[0-9]+).[0-9]+" "\\1" current_macosx_version ${current_macosx_version})
         else()
         if(NOT minimum_macosx_version)