瀏覽代碼

Export: Fix internal CMake version test logic

Fix the internal DEVEL_CMAKE_VERSION macro to use CMake_VERSION_ENCODE
to compare version component-wise.  Otherwise an old invocation of the
macro may be tricked into using the current version when the requested
major version is smaller than the current version but the requested
minor version is larger.  It should use the requested (old) version in
that case.
Brad King 11 年之前
父節點
當前提交
9bcc1b21f0
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      Source/cmExportInstallFileGenerator.cxx

+ 6 - 4
Source/cmExportInstallFileGenerator.cxx

@@ -19,15 +19,17 @@
 #include "cmInstallExportGenerator.h"
 #include "cmInstallTargetGenerator.h"
 #include "cmTargetExport.h"
-#include "cmVersionConfig.h"
+#include "cmVersionMacros.h"
+#include "cmVersion.h"
 
 #define STRINGIFY_HELPER(X) #X
 #define STRINGIFY(X) STRINGIFY_HELPER(X)
 
 #define DEVEL_CMAKE_VERSION(maj, min, patch) \
-  (maj > CMake_VERSION_MAJOR \
-  || min > CMake_VERSION_MINOR \
-  || patch > CMake_VERSION_PATCH) ? \
+  (CMake_VERSION_ENCODE(maj, min, patch) > \
+   CMake_VERSION_ENCODE(CMake_VERSION_MAJOR, CMake_VERSION_MINOR, \
+                        CMake_VERSION_PATCH) \
+  ) ? \
     STRINGIFY(CMake_VERSION_MAJOR) "." STRINGIFY(CMake_VERSION_MINOR) "." \
     STRINGIFY(CMake_VERSION_PATCH) "." STRINGIFY(CMake_VERSION_TWEAK) \
   : #maj "." #min "." #patch