Browse Source

Merge topic 'version-macros'

f1ce50dc81 cmVersionMacros: Adopt CMake_VERSION_DEVEL
c5a1675436 cmVersionMacros: Adopt CMake_VERSION_ENCODE

Acked-by: Kitware Robot <[email protected]>
Merge-request: !11244
Brad King 3 months ago
parent
commit
7366ebb007

+ 2 - 2
Help/dev/maint.rst

@@ -263,12 +263,12 @@ Update ``Source/CMakeVersion.cmake`` to set the version to
   set(CMake_VERSION_PATCH 0)
   set(CMake_VERSION_RC 0)
 
-Replace uses of ``DEVEL_CMAKE_VERSION`` in the source tree with
+Replace uses of ``CMake_VERSION_DEVEL`` in the source tree with
 the literal release version number string ``"$major.$minor.0"``:
 
 .. code-block:: shell
 
-  $EDITOR $(git grep -l DEVEL_CMAKE_VERSION)
+  $EDITOR $(git grep -l CMake_VERSION_DEVEL)
 
 Commit with a message such as::
 

+ 1 - 1
Source/cmExportCMakeConfigGenerator.cxx

@@ -26,7 +26,7 @@
 #include "cmSystemTools.h"
 #include "cmTarget.h"
 #include "cmValue.h"
-#include "cmVersion.h"
+#include "cmVersionMacros.h"
 
 struct cmLinkInterface;
 

+ 0 - 10
Source/cmExportFileGenerator.h

@@ -18,16 +18,6 @@ class cmExportSet;
 class cmGeneratorTarget;
 class cmLocalGenerator;
 
-#define STRINGIFY_HELPER(X) #X
-#define STRINGIFY(X) STRINGIFY_HELPER(X)
-
-#define DEVEL_CMAKE_VERSION(major, minor)                                     \
-  (CMake_VERSION_ENCODE(major, minor, 0) >                                    \
-       CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, 0)      \
-     ? STRINGIFY(CMake_VERSION_MAJOR) "." STRINGIFY(                          \
-         CMake_VERSION_MINOR) "." STRINGIFY(CMake_VERSION_PATCH)              \
-     : #major "." #minor ".0")
-
 /** \class cmExportFileGenerator
  * \brief Generate files exporting targets from a build or install tree.
  *

+ 1 - 1
Source/cmFindPackageCommand.cxx

@@ -43,7 +43,7 @@
 #include "cmStringAlgorithms.h"
 #include "cmSystemTools.h"
 #include "cmValue.h"
-#include "cmVersion.h"
+#include "cmVersionMacros.h"
 #include "cmWindowsRegistry.h"
 
 #if defined(__HAIKU__)

+ 0 - 10
Source/cmVersion.h

@@ -2,8 +2,6 @@
    file LICENSE.rst or https://cmake.org/licensing for details.  */
 #pragma once
 
-#include <cm3p/kwiml/int.h>
-
 /** \class cmVersion
  * \brief Helper class for providing CMake and CTest version information.
  *
@@ -21,11 +19,3 @@ public:
   static unsigned int GetTweakVersion();
   static char const* GetCMakeVersion();
 };
-
-/* Encode with room for up to 1000 minor releases between major releases
-   and to encode dates until the year 10000 in the patch level.  */
-#define CMake_VERSION_ENCODE_BASE KWIML_INT_UINT64_C(100000000)
-#define CMake_VERSION_ENCODE(major, minor, patch)                             \
-  ((((major) * 1000u) * CMake_VERSION_ENCODE_BASE) +                          \
-   (((minor) % 1000u) * CMake_VERSION_ENCODE_BASE) +                          \
-   (((patch) % CMake_VERSION_ENCODE_BASE)))

+ 20 - 0
Source/cmVersionMacros.h

@@ -2,9 +2,29 @@
    file LICENSE.rst or https://cmake.org/licensing for details.  */
 #pragma once
 
+#include <cm3p/kwiml/int.h>
+
 #include "cmVersionConfig.h"
 
 #define CMake_VERSION_PATCH_IS_RELEASE(patch) ((patch) < 20000000)
 #if CMake_VERSION_PATCH_IS_RELEASE(CMake_VERSION_PATCH)
 #  define CMake_VERSION_IS_RELEASE 1
 #endif
+
+/* Encode with room for up to 1000 minor releases between major releases
+   and to encode dates until the year 10000 in the patch level.  */
+#define CMake_VERSION_ENCODE_BASE KWIML_INT_UINT64_C(100000000)
+#define CMake_VERSION_ENCODE(major, minor, patch)                             \
+  ((((major) * 1000u) * CMake_VERSION_ENCODE_BASE) +                          \
+   (((minor) % 1000u) * CMake_VERSION_ENCODE_BASE) +                          \
+   (((patch) % CMake_VERSION_ENCODE_BASE)))
+
+#define CMV_STRINGIFY(X) CMV_STRINGIFY_DELAY(X)
+#define CMV_STRINGIFY_DELAY(X) #X
+
+#define CMake_VERSION_DEVEL(major, minor)                                     \
+  (CMake_VERSION_ENCODE(major, minor, 0) >                                    \
+       CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, 0)      \
+     ? CMV_STRINGIFY(CMake_VERSION_MAJOR) "." CMV_STRINGIFY(                  \
+         CMake_VERSION_MINOR) "." CMV_STRINGIFY(CMake_VERSION_PATCH)          \
+     : #major "." #minor ".0")