[CMAKE]
authorSylvain Petreolle <spetreolle@yahoo.fr>
Fri, 21 Jan 2011 20:29:45 +0000 (20:29 +0000)
committerSylvain Petreolle <spetreolle@yahoo.fr>
Fri, 21 Jan 2011 20:29:45 +0000 (20:29 +0000)
Use cmake subversion capabilities to generate buildno.h and version.h.

svn path=/branches/cmake-bringup/; revision=50454

CMakeLists.txt
include/reactos/buildno.h.cmake [new file with mode: 0644]
include/reactos/version.cmake [new file with mode: 0644]
include/reactos/version.h.cmake [new file with mode: 0644]

index f38cf05..a9cb0d1 100644 (file)
@@ -2,6 +2,9 @@
 cmake_minimum_required(VERSION 2.6)
 project(REACTOS)
 
+#versioning
+include(include/reactos/version.cmake)
+
 # Don't escape preprocessor definition values added via add_definitions
 cmake_policy(SET CMP0005 OLD)
 
@@ -44,9 +47,9 @@ if(NOT CMAKE_CROSSCOMPILING)
     add_subdirectory(lib)
 
     if(NOT MSVC)
-        export(TARGETS widl nci buildno gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
+        export(TARGETS widl nci gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
     else()
-        export(TARGETS nci buildno gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
+        export(TARGETS nci gendib cabman cdmake mkhive spec2def geninc FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake NAMESPACE native- )
     endif()
 
 else()
@@ -221,11 +224,6 @@ if(CMAKE_CROSSCOMPILING)
 
     file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/include/reactos)
 
-    add_custom_command(
-        OUTPUT ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
-        COMMAND native-buildno ${REACTOS_BINARY_DIR}/include/reactos/buildno.h
-        DEPENDS ${REACTOS_SOURCE_DIR}/include/reactos/version.h)
-
     add_custom_target(buildno_header ALL DEPENDS ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)
 
     file(MAKE_DIRECTORY ${REACTOS_BINARY_DIR}/subsystems/win32/win32k/dib)
diff --git a/include/reactos/buildno.h.cmake b/include/reactos/buildno.h.cmake
new file mode 100644 (file)
index 0000000..ac47278
--- /dev/null
@@ -0,0 +1,18 @@
+/* Do not edit - Machine generated */\r
+#ifndef _INC_REACTOS_BUILDNO\r
+#define _INC_REACTOS_BUILDNO\r
+#define KERNEL_VERSION_BUILD   @KERNEL_VERSION_BUILD@\r
+#define KERNEL_VERSION_BUILD_HEX       0x@KERNEL_VERSION_BUILD_HEX@\r
+#define KERNEL_VERSION_BUILD_STR       "@KERNEL_VERSION_BUILD@@REVISION@"\r
+#define KERNEL_VERSION_BUILD_RC        "@KERNEL_VERSION_BUILD@@REVISION@\0"\r
+#define KERNEL_RELEASE_RC      "@KERNEL_VERSION@\0"\r
+#define KERNEL_RELEASE_STR     "@KERNEL_VERSION@"\r
+#define KERNEL_VERSION_RC      "@KERNEL_VERSION@\0"\r
+#define KERNEL_VERSION_STR     "@KERNEL_VERSION@"\r
+#define REACTOS_DLL_VERSION_MAJOR      @REACTOS_DLL_VERSION_MAJOR@\r
+#define REACTOS_DLL_RELEASE_RC "@DLL_VERSION_STR@\0"\r
+#define REACTOS_DLL_RELEASE_STR        "@DLL_VERSION_STR@"\r
+#define REACTOS_DLL_VERSION_RC "@DLL_VERSION_STR@\0"\r
+#define REACTOS_DLL_VERSION_STR        "@DLL_VERSION_STR@"\r
+#endif\r
+/* EOF */\r
diff --git a/include/reactos/version.cmake b/include/reactos/version.cmake
new file mode 100644 (file)
index 0000000..b01f246
--- /dev/null
@@ -0,0 +1,64 @@
+macro(today RESULT)\r
+    if (WIN32)\r
+        #execute_process(COMMAND "cmd" "/c" "date" "/T" OUTPUT_VARIABLE ${RESULT})\r
+        #string(REGEX REPLACE "(..)/(..)/(....).*" "\\3\\2\\1" ${RESULT} ${${RESULT}})\r
+        execute_process(COMMAND "${REACTOS_SOURCE_DIR}/tools/getdate.cmd" OUTPUT_VARIABLE ${RESULT})\r
+        string(STRIP ${${RESULT}} ${RESULT})\r
+    elseif(UNIX)\r
+        execute_process(COMMAND "date" "+%Y%m%d" OUTPUT_VARIABLE ${${RESULT}})\r
+    else (WIN32)\r
+        message(SEND_ERROR "date not implemented")\r
+        set(${RESULT} 00000000)\r
+    endif (WIN32)\r
+endmacro(today)\r
+\r
+macro(inttohex INTVALUE OUTPUT_VARIABLE)\r
+    list(APPEND HEXLIST 0 1 2 3 4 5 6 7 8 9 a b c d e f)\r
+    list(GET HEXLIST ${INTVALUE} ${OUTPUT_VARIABLE})\r
+endmacro()\r
+\r
+macro(converttohex INTVALUE OUTPUT_VARIABLE)\r
+    set(REMAINING ${INTVALUE})\r
+    while(REMAINING)\r
+        math(EXPR REMAINDER "${REMAINING}%16")\r
+        inttohex(${REMAINDER} HEXCHAR)\r
+        math(EXPR REMAINING "${REMAINING}/16")\r
+        set(${OUTPUT_VARIABLE} "${HEXCHAR}${${OUTPUT_VARIABLE}}")\r
+    endwhile()\r
+endmacro()\r
+\r
+today(KERNEL_VERSION_BUILD)\r
+\r
+set(KERNEL_VERSION_MAJOR "0")\r
+set(KERNEL_VERSION_MINOR "4")\r
+set(KERNEL_VERSION_PATCH_LEVEL "0")\r
+set(COPYRIGHT_YEAR "2011")\r
+# KERNEL_VERSION_BUILD_TYPE is "SVN", "RC1", "RC2" or "" (for the release)\r
+set(KERNEL_VERSION_BUILD_TYPE "SVN")\r
+\r
+\r
+set(KERNEL_VERSION "${KERNEL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}")\r
+if(KERNEL_VERSION_PATCH_LEVEL)\r
+    set(KERNEL_VERSION "${KERNEL_VERSION}.${KERNEL_VERSION_PATCH_LEVEL}-${KERNEL_VERSION_BUILD_TYPE}")\r
+else()\r
+    set(KERNEL_VERSION "${KERNEL_VERSION}-${KERNEL_VERSION_BUILD_TYPE}")\r
+endif()\r
+\r
+math(EXPR REACTOS_DLL_VERSION_MAJOR "${KERNEL_VERSION_MAJOR}+42")\r
+set(DLL_VERSION_STR "${REACTOS_DLL_VERSION_MAJOR}.${KERNEL_VERSION_MINOR}-${KERNEL_VERSION_BUILD_TYPE}")\r
+if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.svn")\r
+    find_package(Subversion)\r
+    if(Subversion_FOUND)\r
+        subversion_wc_info(${CMAKE_CURRENT_SOURCE_DIR} SVNINFO)\r
+        if(SVNINFO_WC_REVISION)\r
+            set(REVISION "-r${SVNINFO_WC_REVISION}")\r
+            converttohex(${SVNINFO_WC_REVISION} KERNEL_VERSION_BUILD_HEX)            \r
+        endif()\r
+    endif()\r
+else()\r
+    set(REVISION "-rUNKNOWN")\r
+    set(HEXREVISION "0x0")\r
+endif()\r
+\r
+configure_file(include/reactos/version.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/version.h)\r
+configure_file(include/reactos/buildno.h.cmake ${REACTOS_BINARY_DIR}/include/reactos/buildno.h)\r
diff --git a/include/reactos/version.h.cmake b/include/reactos/version.h.cmake
new file mode 100644 (file)
index 0000000..64dc2f3
--- /dev/null
@@ -0,0 +1,31 @@
+/*\r
+ * COPYRIGHT:   See COPYING in the top level directory\r
+ * PROJECT:     ReactOS kernel\r
+ * FILE:        include/internal/version.h\r
+ * PURPOSE:     Defines the current version\r
+ * PROGRAMMER:  David Welch (welch@mcmail.com)\r
+ * REVISIONS:\r
+ *     1999-11-06 (ea)\r
+ *             Moved from include/internal in include/reactos\r
+ *             to be used by buildno.\r
+ *     2002-01-17 (ea)\r
+ *             KERNEL_VERSION removed. Use\r
+ *             reactos/buildno.h:KERNEL_VERSION_STR instead.\r
+ */\r
+\r
+#ifndef __VERSION_H\r
+#define __VERSION_H\r
+\r
+#define KERNEL_VERSION_MAJOR @KERNEL_VERSION_MAJOR@\r
+#define KERNEL_VERSION_MINOR @KERNEL_VERSION_MINOR@\r
+#define KERNEL_VERSION_PATCH_LEVEL @KERNEL_VERSION_PATCH_LEVEL@\r
+\r
+#define COPYRIGHT_YEAR "@COPYRIGHT_YEAR@"\r
+\r
+/* KERNEL_VERSION_BUILD_TYPE is L"SVN", L"RC1", L"RC2" or L"" (for the release) */\r
+#define KERNEL_VERSION_BUILD_TYPE "@KERNEL_VERSION_BUILD_TYPE@"\r
+\r
+\r
+#endif\r
+\r
+/* EOF */\r