Permalink
Browse files

add ConfigureVersion [CMake]

  • Loading branch information...
1 parent ac08046 commit 57025a9738f38fda288ba2e566bdd7dffbe5d9ad @hoijui hoijui committed Sep 30, 2011
Showing with 89 additions and 0 deletions.
  1. +1 −0 VERSION.template
  2. +23 −0 rts/System/VersionGenerated.h.template
  3. +65 −0 rts/build/cmake/ConfigureVersion.cmake
View
@@ -0,0 +1 @@
+@SPRING_VERSION_ENGINE@
@@ -0,0 +1,23 @@
+/* This file is part of the Spring engine (GPL v2 or later), see LICENSE.html */
+
+/*
+ * Do NOT include this file directly, but include the wrapper instead.
+ * This prevents wastefull recompiling.
+ */
+
+#ifndef VERSION_GENERATED_H
+#define VERSION_GENERATED_H
+
+static const char* SPRING_VERSION_ENGINE_MAJOR = "@SPRING_VERSION_ENGINE_MAJOR@";
+
+static const char* SPRING_VERSION_ENGINE_MINOR = "@SPRING_VERSION_ENGINE_MINOR@";
+
+static const char* SPRING_VERSION_ENGINE_PATCH_SET = "@SPRING_VERSION_ENGINE_PATCH_SET@";
+
+static const char* SPRING_VERSION_ENGINE_ADDITIONAL = "@SPRING_VERSION_ENGINE_ADDITIONAL@";
+
+#endif // VERSION_GENERATED_H
+
+
+
+
@@ -0,0 +1,65 @@
+# This file is part of the Spring engine (GPL v2 or later), see LICENSE.html
+
+#
+# example usage:
+#Add_Custom_Command(
+# TARGET
+# configureVersion
+# COMMAND "${CMAKE_COMMAND}"
+# "-DSOURCE_ROOT=${CMAKE_SOURCE_DIR}"
+# "-DCMAKE_MODULES_SPRING=${CMAKE_MODULES_SPRING}"
+# "-DVERSION_ADDITIONAL=ABC"
+# "-DGENERATE_DIR=${CMAKE_BINARY_DIR}"
+# "-P" "${CMAKE_MODULES_SPRING}/ConfigureFile.cmake"
+# COMMENT
+# "Configure Version files" VERBATIM
+# )
+#
+
+Cmake_Minimum_Required(VERSION 2.6)
+
+List(APPEND CMAKE_MODULE_PATH "${CMAKE_MODULES_SPRING}")
+
+Include(UtilVersion)
+
+
+
+# Fetch through git or from the VERSION file
+FetchSpringVersion(${SOURCE_ROOT} SPRING_ENGINE)
+ParseSpringVersion(SPRING_VERSION_ENGINE "${SPRING_ENGINE_VERSION}")
+
+# We define this, so it may be used in the to-be-configured files
+Set(SPRING_VERSION_ENGINE "${SPRING_ENGINE_VERSION}")
+
+# This is supplied by -DVERSION_ADDITIONAL="abc"
+Set(SPRING_VERSION_ENGINE_ADDITIONAL "${VERSION_ADDITIONAL}")
+
+# Add the full version specifier to ADDITIONAL
+If (NOT "${SPRING_VERSION_ENGINE_ADDITIONAL}" STREQUAL "")
+ # Add a delimiter space
+ Set(SPRING_VERSION_ENGINE_ADDITIONAL "${SPRING_VERSION_ENGINE_ADDITIONAL} ")
+EndIf ()
+Set(SPRING_VERSION_ENGINE_ADDITIONAL "${SPRING_VERSION_ENGINE_ADDITIONAL}${SPRING_ENGINE_VERSION}")
+
+
+
+Message("Spring engine version: ${SPRING_ENGINE_VERSION} (${SPRING_VERSION_ENGINE_ADDITIONAL})")
+
+
+
+File(MAKE_DIRECTORY "${GENERATE_DIR}/src-generated/engine/System")
+Configure_File(
+ "${SOURCE_ROOT}/rts/System/VersionGenerated.h.template"
+ "${GENERATE_DIR}/src-generated/engine/System/VersionGenerated.h"
+ @ONLY
+ )
+
+File(MAKE_DIRECTORY "${GENERATE_DIR}")
+Configure_File(
+ "${SOURCE_ROOT}/VERSION.template"
+ "${GENERATE_DIR}/VERSION"
+ @ONLY
+ )
+
+
+

0 comments on commit 57025a9

Please sign in to comment.